2.1.0 • Published 4 years ago

@extra-lists/submaps v2.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Lists all possible submaps. :running: :package: :ledger:

Similar: subobject, subobjects, isSubobject. This is part of package extra-lists.

lists.submaps(x, [n]);
// x: lists
// n: number of entries (-1 => any)
const lists = require('extra-lists');

var x = [['a', 'b'], [1, 2]];
[...lists.submaps(x)].map(a => [[...a[0]], [...a[1]]]);
// [
//   [ [], [] ],
//   [ [ 'a' ], [ 1 ] ],
//   [ [ 'b' ], [ 2 ] ],
//   [ [ 'a', 'b' ], [ 1, 2 ] ]
// ]

var x = [['a', 'b', 'c'], [1, 2, 3]];
[...lists.submaps(x)].map(a => [[...a[0]], [...a[1]]]);
// [
//   [ [], [] ],
//   [ [ 'a' ], [ 1 ] ],
//   [ [ 'b' ], [ 2 ] ],
//   [ [ 'a', 'b' ], [ 1, 2 ] ],
//   [ [ 'c' ], [ 3 ] ],
//   [ [ 'a', 'c' ], [ 1, 3 ] ],
//   [ [ 'b', 'c' ], [ 2, 3 ] ],
//   [ [ 'a', 'b', 'c' ], [ 1, 2, 3 ] ]
// ]

references

2.0.91

4 years ago

2.1.0

4 years ago

2.0.89

4 years ago

2.0.90

4 years ago

2.0.88

4 years ago