deep-combination
v0.0.2
Published
Generate pair of all combination with type-safe.
Downloads
7
Maintainers
Readme
deep-combination
Generate pair of all combination with type-safe.
Install
npm install deep-combination
Usage
import { createCombinator } from "deep-combination";
const browsers = ["chrome", "firefox", "webkit"];
const devices = ["laptop", "mobile"];
const locales = ["en-US", "ja-JP"];
const combinator = createCombinator()
.addDimention(browsers)
.addDimention(devices)
.addDimention(locales);
// You can get pairs via for-of statement
for (let [browser, device, locale] of combinator) {
console.log([browser, device, locale]);
// => ['chrome', 'laptop', 'en-US'], ['chrome', 'laptop', 'ja-JP']...
}
// Or you can get list of pairs from Array.from
const pairs = Array.from(combinator);
// => [['chrome', 'laptop', 'en-US'], ['chrome', 'laptop', 'ja-JP'], ...]
Limitation
Currently, type definition supports less than 20 dimentions.
Runtime is OK but type is not recognized.
Contribution
- Fork this repository
- Write your code
- Run tests
- Create pull request to master branch
Development
git clone [email protected]:Leko/deep-combination.git
cd deep-combination
npm i
License
This package under MIT license.