Skip to content
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 11 commits into from
Oct 31, 2021
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
"test": "test"
},
"devDependencies": {
"esbuild": "0.13.8",
"eslint": "6.8.0",
"lerna": "3.20.2",
"tap-spec": "5.0.0",
"tape": "^4.0.0",
"typescript": "^4.2.3"
},
"scripts": {
"build": "lerna run build --stream $@",
Copy link
Contributor Author

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:

# for all packages
yarn build

# or filtering by package name
yarn build --scope=just-cartesian-product

"lint": "eslint .",
"test": "npm run lint && tape ./test/**/index.js | tap-spec; npm run test-types",
"test-types": "tsc packages/**/*.tests.ts --noEmit --strictNullChecks"
Expand All @@ -37,4 +39,4 @@
"dependencies": {
"test": "^0.6.0"
}
}
}
47 changes: 47 additions & 0 deletions packages/array-cartesian-product/index.esm.js
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();
11 changes: 10 additions & 1 deletion packages/array-cartesian-product/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@
"name": "just-cartesian-product",
"version": "3.0.0",
"description": "Cartesian product of arrays",
"type": "commonjs",
"main": "index.js",
"module": "index.esm.js",
"exports": {
".": {
"require": "./index.js",
"default": "./index.esm.js"
}
},
"types": "index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"build": "esbuild index.js --bundle --platform=browser --format=esm --outfile=index.esm.js"
},
"repository": "https://github.com/angus-c/just",
"keywords": [
Expand Down
108 changes: 108 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1806,6 +1806,114 @@ es6-promisify@^5.0.0:
dependencies:
es6-promise "^4.0.3"

esbuild-android-arm64@0.13.8:
version "0.13.8"
resolved "https://registry.yarnpkg.com/esbuild-android-arm64/-/esbuild-android-arm64-0.13.8.tgz#c20e875c3c98164b1ffba9b28637bdf96f5e9e7c"
integrity sha512-AilbChndywpk7CdKkNSZ9klxl+9MboLctXd9LwLo3b0dawmOF/i/t2U5d8LM6SbT1Xw36F8yngSUPrd8yPs2RA==

esbuild-darwin-64@0.13.8:
version "0.13.8"
resolved "https://registry.yarnpkg.com/esbuild-darwin-64/-/esbuild-darwin-64-0.13.8.tgz#f46e6b471ddbf62265234808a6a1aa91df18a417"
integrity sha512-b6sdiT84zV5LVaoF+UoMVGJzR/iE2vNUfUDfFQGrm4LBwM/PWXweKpuu6RD9mcyCq18cLxkP6w/LD/w9DtX3ng==

esbuild-darwin-arm64@0.13.8:
version "0.13.8"
resolved "https://registry.yarnpkg.com/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.13.8.tgz#a991157a6013facd4f2e14159b7da52626c90154"
integrity sha512-R8YuPiiJayuJJRUBG4H0VwkEKo6AvhJs2m7Tl0JaIer3u1FHHXwGhMxjJDmK+kXwTFPriSysPvcobXC/UrrZCQ==

esbuild-freebsd-64@0.13.8:
version "0.13.8"
resolved "https://registry.yarnpkg.com/esbuild-freebsd-64/-/esbuild-freebsd-64-0.13.8.tgz#301601d2e443ad458960e359b402a17d9500be9d"
integrity sha512-zBn6urrn8FnKC+YSgDxdof9jhPCeU8kR/qaamlV4gI8R3KUaUK162WYM7UyFVAlj9N0MyD3AtB+hltzu4cysTw==

esbuild-freebsd-arm64@0.13.8:
version "0.13.8"
resolved "https://registry.yarnpkg.com/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.13.8.tgz#039a63acc12ec0892006c147ea221e55f9125a9f"
integrity sha512-pWW2slN7lGlkx0MOEBoUGwRX5UgSCLq3dy2c8RIOpiHtA87xAUpDBvZK10MykbT+aMfXc0NI2lu1X+6kI34xng==

esbuild-linux-32@0.13.8:
version "0.13.8"
resolved "https://registry.yarnpkg.com/esbuild-linux-32/-/esbuild-linux-32-0.13.8.tgz#c537b67d7e694b60bfa2786581412838c6ba0284"
integrity sha512-T0I0ueeKVO/Is0CAeSEOG9s2jeNNb8jrrMwG9QBIm3UU18MRB60ERgkS2uV3fZ1vP2F8i3Z2e3Zju4lg9dhVmw==

esbuild-linux-64@0.13.8:
version "0.13.8"
resolved "https://registry.yarnpkg.com/esbuild-linux-64/-/esbuild-linux-64-0.13.8.tgz#0092fc8a064001a777bfa0e3b425bb8be8f96e6a"
integrity sha512-Bm8SYmFtvfDCIu9sjKppFXzRXn2BVpuCinU1ChTuMtdKI/7aPpXIrkqBNOgPTOQO9AylJJc1Zw6EvtKORhn64w==

esbuild-linux-arm64@0.13.8:
version "0.13.8"
resolved "https://registry.yarnpkg.com/esbuild-linux-arm64/-/esbuild-linux-arm64-0.13.8.tgz#5cd3f2bb924212971482e8dbc25c4afd09b28110"
integrity sha512-X4pWZ+SL+FJ09chWFgRNO3F+YtvAQRcWh0uxKqZSWKiWodAB20flsW/OWFYLXBKiVCTeoGMvENZS/GeVac7+tQ==

esbuild-linux-arm@0.13.8:
version "0.13.8"
resolved "https://registry.yarnpkg.com/esbuild-linux-arm/-/esbuild-linux-arm-0.13.8.tgz#ad634f96bf2975536907aeb9fdb75a3194f4ddce"
integrity sha512-4/HfcC40LJ4GPyboHA+db0jpFarTB628D1ifU+/5bunIgY+t6mHkJWyxWxAAE8wl/ZIuRYB9RJFdYpu1AXGPdg==

esbuild-linux-mips64le@0.13.8:
version "0.13.8"
resolved "https://registry.yarnpkg.com/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.13.8.tgz#57857edfebf9bf65766dc8be1637f2179c990572"
integrity sha512-o7e0D+sqHKT31v+mwFircJFjwSKVd2nbkHEn4l9xQ1hLR+Bv8rnt3HqlblY3+sBdlrOTGSwz0ReROlKUMJyldA==

esbuild-linux-ppc64le@0.13.8:
version "0.13.8"
resolved "https://registry.yarnpkg.com/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.13.8.tgz#fdb82a059a5b86bb10fb42091b4ebcf488b9cd46"
integrity sha512-eZSQ0ERsWkukJp2px/UWJHVNuy0lMoz/HZcRWAbB6reoaBw7S9vMzYNUnflfL3XA6WDs+dZn3ekHE4Y2uWLGig==

esbuild-netbsd-64@0.13.8:
version "0.13.8"
resolved "https://registry.yarnpkg.com/esbuild-netbsd-64/-/esbuild-netbsd-64-0.13.8.tgz#d7879e7123d3b2c04754ece8bd061aa6866deeff"
integrity sha512-gZX4kP7gVvOrvX0ZwgHmbuHczQUwqYppxqtoyC7VNd80t5nBHOFXVhWo2Ad/Lms0E8b+wwgI/WjZFTCpUHOg9Q==

esbuild-openbsd-64@0.13.8:
version "0.13.8"
resolved "https://registry.yarnpkg.com/esbuild-openbsd-64/-/esbuild-openbsd-64-0.13.8.tgz#88b280b6cb0a3f6adb60abf27fc506c506a35cf0"
integrity sha512-afzza308X4WmcebexbTzAgfEWt9MUkdTvwIa8xOu4CM2qGbl2LanqEl8/LUs8jh6Gqw6WsicEK52GPrS9wvkcw==

esbuild-sunos-64@0.13.8:
version "0.13.8"
resolved "https://registry.yarnpkg.com/esbuild-sunos-64/-/esbuild-sunos-64-0.13.8.tgz#229ae7c7703196a58acd0f0291ad9bebda815d63"
integrity sha512-mWPZibmBbuMKD+LDN23LGcOZ2EawMYBONMXXHmbuxeT0XxCNwadbCVwUQ/2p5Dp5Kvf6mhrlIffcnWOiCBpiVw==

esbuild-windows-32@0.13.8:
version "0.13.8"
resolved "https://registry.yarnpkg.com/esbuild-windows-32/-/esbuild-windows-32-0.13.8.tgz#892d093e32a21c0c9135e5a0ffdc380aeb70e763"
integrity sha512-QsZ1HnWIcnIEApETZWw8HlOhDSWqdZX2SylU7IzGxOYyVcX7QI06ety/aDcn437mwyO7Ph4RrbhB+2ntM8kX8A==

esbuild-windows-64@0.13.8:
version "0.13.8"
resolved "https://registry.yarnpkg.com/esbuild-windows-64/-/esbuild-windows-64-0.13.8.tgz#7defd8d79ae3bb7e6f53b65a7190be7daf901686"
integrity sha512-76Fb57B9eE/JmJi1QmUW0tRLQZfGo0it+JeYoCDTSlbTn7LV44ecOHIMJSSgZADUtRMWT9z0Kz186bnaB3amSg==

esbuild-windows-arm64@0.13.8:
version "0.13.8"
resolved "https://registry.yarnpkg.com/esbuild-windows-arm64/-/esbuild-windows-arm64-0.13.8.tgz#e59ae004496fd8a5ab67bfc7945a2e47480d6fb9"
integrity sha512-HW6Mtq5eTudllxY2YgT62MrVcn7oq2o8TAoAvDUhyiEmRmDY8tPwAhb1vxw5/cdkbukM3KdMYtksnUhF/ekWeg==

esbuild@0.13.8:
version "0.13.8"
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.13.8.tgz#bd7cc51b881ab067789f88e17baca74724c1ec4f"
integrity sha512-A4af7G7YZLfG5OnARJRMtlpEsCkq/zHZQXewgPA864l9D6VjjbH1SuFYK/OSV6BtHwDGkdwyRrX0qQFLnMfUcw==
optionalDependencies:
esbuild-android-arm64 "0.13.8"
esbuild-darwin-64 "0.13.8"
esbuild-darwin-arm64 "0.13.8"
esbuild-freebsd-64 "0.13.8"
esbuild-freebsd-arm64 "0.13.8"
esbuild-linux-32 "0.13.8"
esbuild-linux-64 "0.13.8"
esbuild-linux-arm "0.13.8"
esbuild-linux-arm64 "0.13.8"
esbuild-linux-mips64le "0.13.8"
esbuild-linux-ppc64le "0.13.8"
esbuild-netbsd-64 "0.13.8"
esbuild-openbsd-64 "0.13.8"
esbuild-sunos-64 "0.13.8"
esbuild-windows-32 "0.13.8"
esbuild-windows-64 "0.13.8"
esbuild-windows-arm64 "0.13.8"

escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
Expand Down