Skip to content

Commit

Permalink
♻️ refactor: Fix function signature and avoid regenerator-runtime.
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed May 1, 2021
1 parent 2f13e63 commit b7b8c72
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 21 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
Iterable consumption for JavaScript.
See [docs](https://iterable-iterator.github.io/consume/index.html).

> :warning: Depending on your environment, the code may require
> `regeneratorRuntime` to be defined, for instance by importing
> [regenerator-runtime/runtime](https://www.npmjs.com/package/regenerator-runtime).
```js
import {exhaust} from '@iterable-iterator/consume';
import {map} from '@iterable-iterator/map';
Expand Down
17 changes: 3 additions & 14 deletions doc/manual/usage.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
# Usage

> :warning: Depending on your environment, the code may require
> `regeneratorRuntime` to be defined, for instance by importing
> [regenerator-runtime/runtime](https://www.npmjs.com/package/regenerator-runtime).
First, require the polyfill at the entry point of your application
```js
require( 'regenerator-runtime/runtime' ) ;
// or
import 'regenerator-runtime/runtime.js' ;
```

Then, import the library where needed
Import the library where needed
```js
const consume = require( '@iterable-iterator/consume' ) ;
const {consume, exhaust} = require( '@iterable-iterator/consume' ) ;
// or
import * as consume from '@iterable-iterator/consume' ;
import {consume, exhaust} from '@iterable-iterator/consume' ;
```
2 changes: 1 addition & 1 deletion src/consume.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Consumes a given number of iterations of the input iterator.
*
* @param {Iterator} iterator - The input iterator.
* @param {Number} n - The number of iterations to consume.
* @param {number} n - The number of iterations to consume.
*
*/
export default function consume(iterator, n) {
Expand Down
4 changes: 2 additions & 2 deletions src/exhaust.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
*
*/
export default function exhaust(iterator) {
// eslint-disable-next-line no-empty,no-unused-vars,prettier/prettier
for (const item of iterator) {}
// eslint-disable-next-line no-empty
while (!iterator.next().done) {}
}

0 comments on commit b7b8c72

Please sign in to comment.