-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(just-cartesian-product): enable esm #315
Merged
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4d147c7
feat(just-cartesian-product): enable esm
raulfdm eb1a17d
chore: add rollup as comparison
raulfdm 3cb4db3
chore: remove esbuild
raulfdm a1acc12
feat: create rollup config factory
raulfdm 43cd2c2
chore: replace index.esm with rollup output
raulfdm 972ac9f
chore: create rollup config for all packages
raulfdm d2de48e
temp npmrc
raulfdm c335065
feat: add support to ESM
raulfdm 4ace013
chore: remove .npmrc
raulfdm 3371b32
Merge branch 'master' into backup-master
raulfdm b011476
Merge pull request #1 from raulfdm/backup-master
raulfdm File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
var __commonJS = (cb, mod) => function __require() { | ||
return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; | ||
}; | ||
|
||
// index.js | ||
var require_array_cartesian_product = __commonJS({ | ||
"index.js"(exports, module) { | ||
module.exports = cartesianProduct; | ||
function isArray(item) { | ||
if (Object.prototype.toString.call(item) === "[object Array]") { | ||
return true; | ||
} | ||
return false; | ||
} | ||
function baseProduct(prevProduct, arr2) { | ||
var newProduct = new Array(prevProduct.length * arr2.length); | ||
for (var i = 0; i < prevProduct.length; i++) { | ||
for (var j = 0; j < arr2.length; j++) { | ||
newProduct[i * arr2.length + j] = prevProduct[i].concat([arr2[j]]); | ||
} | ||
} | ||
return newProduct; | ||
} | ||
function cartesianProduct(arr) { | ||
if (!isArray(arr)) { | ||
throw new Error("just-cartesian-product expects an array"); | ||
} | ||
if (!arr.length) { | ||
return []; | ||
} | ||
if (!isArray(arr[0])) { | ||
throw new Error("set at index 0 must be an array"); | ||
} | ||
var product = arr[0].map(function(v) { | ||
return [v]; | ||
}); | ||
for (var i = 1; i < arr.length; i++) { | ||
if (!isArray(product)) { | ||
throw new Error("set at index " + i + " must be an array"); | ||
} | ||
product = baseProduct(product, arr[i]); | ||
} | ||
return product; | ||
} | ||
} | ||
}); | ||
export default require_array_cartesian_product(); |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this command allow us to run: