Skip to content

Commit

Permalink
feat: add util functions
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasKruckenberg committed Mar 15, 2021
1 parent f86bb5a commit c36d840
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/core/src/util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import sharp from "sharp";

export function loadImageFromDisk(path: string) {
return sharp(path)
}

export function loadImageFromBuffer(buf: Buffer) {
return sharp(buf)
}

/**
* This function calculates the cartesian product of two or more array and is straight from stackoverflow ;)
* Should be replaced with something more legible but works for now.
* @internal
*/
export const cartesian = (...a: any[]) => a.reduce((a: any, b: any) => a.flatMap((d: any) => b.map((e: any) => [d, e].flat())))

0 comments on commit c36d840

Please sign in to comment.