Skip to content

Commit 999467c

Browse files
First commit
0 parents  commit 999467c

20 files changed

+5888
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
coverage
2+
dist
3+
node_modules

README.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# @codecb/iterator
2+
3+
🌡 An implementation of the [Iterator helpers proposal](https://github.com/tc39/proposal-iterator-helpers).
4+
5+
**Note:** This implementation does not strictly follow the proposal. It creates a new base class and works on interfaces (`Iterator`, `AsyncIterator`, `Iterable`, and `AsyncIterable`) rather than inheriting from the real, native [`%IteratorPrototype%` object](https://tc39.es/ecma262/#sec-%iteratorprototype%-object) which is quite awkward to access.
6+
7+
The interesting aspect of this project is it uses `Generator` and `AsyncGenerator` which makes it super easy to handle iteration operations comparing to writing a `next` function ourselves.
8+
9+
See [test cases](./test) to have a taste of what these helpers do and how to use them.
10+
11+
## References
12+
13+
1. [[GitHub] tc39/proposal-iterator-helpers](https://github.com/tc39/proposal-iterator-helpers)
14+
1. [[tc39.es] Iterator Helpers](https://tc39.es/proposal-iterator-helpers/)
15+
1. [[2ality] ECMAScript proposal: iterator helpers](https://2ality.com/2022/12/iterator-helpers.html)
16+
1. [[GitHub] nvie/itertools.js](https://github.com/nvie/itertools.js)
17+
1. [[GitHub] more-itertools/more-itertools](https://github.com/more-itertools/more-itertools)
18+
1. [[Rust] Trait std::iter::Iterator](https://doc.rust-lang.org/std/iter/trait.Iterator.html)
19+
1. [[Python] itertools — Functions creating iterators for efficient looping](https://docs.python.org/3/library/itertools.html)

jest.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('@codecb/jest-config-ts').config;

package.json

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"name": "@codecb/iterator",
3+
"version": "0.0.1",
4+
"description": "🌡 An implementation of the Iterator helpers proposal",
5+
"type": "module",
6+
"license": "MIT",
7+
"author": {
8+
"email": "[email protected]",
9+
"name": "ICodeMyOwnLife"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "https://github.com/code-cb/iterator"
14+
},
15+
"homepage": "https://github.com/code-cb/iterator",
16+
"files": [
17+
"./dist"
18+
],
19+
"main": "./dist/index.js",
20+
"types": "./dist/index.d.ts",
21+
"exports": "./dist/index.js",
22+
"scripts": {
23+
"build": "rollup -c rollup.config.ts --configPlugin=rollup-plugin-ts --bundleConfigAsCjs",
24+
"prepublishOnly": "yarn build",
25+
"test": "jest --coverage",
26+
"typecheck": "tsc --noEmit"
27+
},
28+
"devDependencies": {
29+
"@babel/core": "^7.20",
30+
"@babel/preset-env": "^7.20",
31+
"@babel/preset-typescript": "^7.18",
32+
"@codecb/babel-jest": "0.0.4",
33+
"@codecb/jest-config-ts": "0.0.5",
34+
"@codecb/prettierrc": "0.0.1",
35+
"@codecb/ts-utils": "0.6.5",
36+
"@codecb/tsconfigs": "0.0.10",
37+
"@rollup/plugin-terser": "0.2.0",
38+
"@types/jest": "^29.2",
39+
"@types/node": "^18.11",
40+
"jest": "^29.3",
41+
"prettier": "^2.8",
42+
"rollup": "^3.7",
43+
"rollup-plugin-ts": "^3.0",
44+
"typescript": "^4.9"
45+
},
46+
"prettier": "@codecb/prettierrc"
47+
}

rollup.config.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import terser from '@rollup/plugin-terser';
2+
import { defineConfig } from 'rollup';
3+
import ts from 'rollup-plugin-ts';
4+
5+
const config = defineConfig({
6+
input: './src/index.ts',
7+
output: {
8+
dir: './dist',
9+
format: 'esm',
10+
},
11+
plugins: [ts(), terser({ compress: { passes: 2 } })],
12+
});
13+
14+
export default config;

0 commit comments

Comments
 (0)