-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Brian Boyko
committed
Mar 13, 2021
1 parent
c9635a6
commit f018845
Showing
60 changed files
with
662 additions
and
596 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
export const cartesianProduct = <T, U>(a: T[], b: U[]): [T, U][] => { | ||
const output: [T, U][] = []; | ||
for(const aElem of a){ | ||
for(const bElem of b){ | ||
const output: [T, U][] = []; | ||
for (const aElem of a) { | ||
for (const bElem of b) { | ||
output.push([aElem, bElem]); | ||
} | ||
} | ||
return output; | ||
} | ||
}; | ||
|
||
export default cartesianProduct; | ||
|
||
/* | ||
cartesianProduct(['x', 'y'], [1, 2]); | ||
// [['x', 1], ['x', 2], ['y', 1], ['y', 2]] | ||
*/ | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import chunk from './chunk.ts'; | ||
import chunk from "./chunk.ts"; | ||
|
||
export const chunkIntoParts = <T>(arr: T[], parts = 1): T[][] => { | ||
const size = Math.ceil(arr.length / parts); | ||
return chunk(arr, size); | ||
} | ||
const size = Math.ceil(arr.length / parts); | ||
return chunk(arr, size); | ||
}; | ||
|
||
export default chunkIntoParts; | ||
export default chunkIntoParts; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import flattenDepth from './flattenDepth.ts'; | ||
import flattenDepth from "./flattenDepth.ts"; | ||
|
||
export const flatten = (arr: any[]) => flattenDepth(arr, 1); | ||
|
||
export default flatten; | ||
export default flatten; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import flattenDepth from './flattenDepth.ts'; | ||
import flattenDepth from "./flattenDepth.ts"; | ||
|
||
export const flattenDeep = (arr: any[]) => | ||
flattenDepth(arr, Number.MAX_SAFE_INTEGER); | ||
|
||
export default flattenDeep; | ||
export default flattenDeep; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.