Skip to content

Commit

Permalink
build(deps-dev): bump prettier from 1.18.2 to 1.19.0 (#176)
Browse files Browse the repository at this point in the history
* build(deps-dev): bump prettier from 1.18.2 to 1.19.0

Bumps [prettier](https://github.com/prettier/prettier) from 1.18.2 to 1.19.0.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/master/CHANGELOG.md)
- [Commits](prettier/prettier@1.18.2...1.19.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* style: prettier 1.19
  • Loading branch information
dependabot-preview[bot] authored and fisker committed Nov 9, 2019
1 parent 43173d9 commit 7fdfabc
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"markdownlint-cli": "0.19.0",
"npm-run-all": "4.1.5",
"nyc": "14.1.1",
"prettier": "1.18.2",
"prettier": "1.19.0",
"rimraf": "3.0.0",
"rollup": "1.26.3",
"rollup-plugin-babel": "4.3.3",
Expand Down
25 changes: 20 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ this module was named `fast-cartesian-product` before `v0.0.3`, now it's split i
```js
import PowerCartesianProduct from 'power-cartesian-product'

const inputs = [[0, 1], ['A', 'B']]
const inputs = [
[0, 1],
['A', 'B'],
]

for (const combination of new PowerCartesianProduct(inputs)) {
console.log(combination)
Expand Down Expand Up @@ -105,7 +108,10 @@ Returns: `array`

```js
// 3rd combination
new PowerCartesianProduct([[0, 1], ['A', 'B']]).get(2)
new PowerCartesianProduct([
[0, 1],
['A', 'B'],
]).get(2)
// -> [1, 'A']
```

Expand All @@ -117,7 +123,10 @@ Returns: `array<number>`

```js
// 3rd combination indexes
new PowerCartesianProduct([[0, 1], ['A', 'B']]).getIndexes(2)
new PowerCartesianProduct([
[0, 1],
['A', 'B'],
]).getIndexes(2)
// -> [1, 0]
```

Expand All @@ -128,7 +137,10 @@ a getter to get `size` of combinations, this might be `Infinity` for big combina
Returns: `int | infinity`

```js
new PowerCartesianProduct([[0, 1], ['A', 'B']]).size
new PowerCartesianProduct([
[0, 1],
['A', 'B'],
]).size
// -> 4

new PowerCartesianProduct(new Array(256).fill(new Array(16))).size
Expand All @@ -142,7 +154,10 @@ a getter to get BigInt `size` of combinations.
Returns: `BigInt`

```js
new PowerCartesianProduct([[0, 1], ['A', 'B']]).bigSize
new PowerCartesianProduct([
[0, 1],
['A', 'B'],
]).bigSize
// -> 4n

new PowerCartesianProduct(new Array(33).fill(new Array(2 ** 32 - 1))).bigSize
Expand Down
22 changes: 18 additions & 4 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@ import FastCartesianProduct from '../src'
const product = sets => new FastCartesianProduct(sets)

test('main', t => {
const combinations = product([[0, 1], ['A', 'B']])
const result = [[0, 'A'], [0, 'B'], [1, 'A'], [1, 'B']]
const combinations = product([
[0, 1],
['A', 'B'],
])
const result = [
[0, 'A'],
[0, 'B'],
[1, 'A'],
[1, 'B'],
]

t.deepEqual(Array.from(combinations).join(), result.join())

Expand Down Expand Up @@ -91,7 +99,10 @@ test('size & bigSize', t => {
const MAX_ARRAY_LENGTH = 2 ** 32 - 1
const element = new Array(MAX_ARRAY_LENGTH)
const {bigSize, size} = product(Array.from({length: 33}, () => element))
const combinations = product([[0, 1], ['A', 'B']])
const combinations = product([
[0, 1],
['A', 'B'],
])

t.is(combinations.size, 4)
t.is(combinations.bigSize, BigInt(4))
Expand All @@ -108,7 +119,10 @@ test('size & bigSize', t => {
})

test('get & getIndexes', t => {
const combinations = product([[0, 1], ['A', 'B']])
const combinations = product([
[0, 1],
['A', 'B'],
])

t.deepEqual(combinations.get(2), [1, 'A'])
t.deepEqual(combinations.getIndexes(2), [1, 0])
Expand Down

0 comments on commit 7fdfabc

Please sign in to comment.