https://github.com/brecert/esnext-utils
utils made with esnext proposals in mind
https://github.com/brecert/esnext-utils
Last synced: 8 months ago
JSON representation
utils made with esnext proposals in mind
- Host: GitHub
- URL: https://github.com/brecert/esnext-utils
- Owner: brecert
- License: mit
- Created: 2020-12-09T01:46:42.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-12-14T16:40:27.000Z (over 5 years ago)
- Last Synced: 2025-02-23T07:33:04.653Z (over 1 year ago)
- Language: JavaScript
- Size: 38.1 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# esnext-utils
utils made with esnext proposals in mind
todo: create runtime babel tool for using plugins dynamically with the esnext pragma
## Example
While using [exca](exca/package.json) and given the following import map.
```json
{
"imports": {
"esnext-utils/": "https://raw.githubusercontent.com/Brecert/esnext-utils/main/src/"
}
}
```
Then
```js
// @esnext use https://github.com/tc39/proposal-bind-operator
// @esnext use https://github.com/tc39/proposal-iterator-helpers
import { repeatedCombinations, repeatedPermutations } from 'esnext-utils/algorithm.js'
import { collect, range } from 'esnext-utils/iterator.js'
import { comb } from 'esnext-utils/math.js'
import { dbg } from 'esnext-utils/util.js'
comb(5, 3);
// 10
['iced', 'jam', 'plain']::repeatedCombinations(2)::dbg();
// [
// [ 'plain', 'plain' ],
// [ 'plain', 'jam' ],
// [ 'jam', 'jam' ],
// [ 'plain', 'iced' ],
// [ 'jam', 'iced' ],
// [ 'iced', 'iced' ]
// ]
range(1, 3)::repeatedPermutations(2)::collect()::dbg();
// [
// [ 1, 1 ], [ 1, 2 ],
// [ 1, 3 ], [ 2, 1 ],
// [ 2, 2 ], [ 2, 3 ],
// [ 3, 1 ], [ 3, 2 ],
// [ 3, 3 ]
// ]
```