Comparing version 3.0.3 to 3.0.4
/** | ||
* @packageDocumentation | ||
* | ||
* For when you only want a few values out of an (async)iterable. | ||
* | ||
* @example | ||
* | ||
* ```javascript | ||
* import take from 'it-take' | ||
* import all from 'it-all' | ||
* | ||
* // This can also be an iterator, generator, etc | ||
* const values = [0, 1, 2, 3, 4] | ||
* | ||
* const arr = all(take(values, 2)) | ||
* | ||
* console.info(arr) // 0, 1 | ||
* ``` | ||
* | ||
* Async sources must be awaited: | ||
* | ||
* ```javascript | ||
* import take from 'it-take' | ||
* import all from 'it-all' | ||
* | ||
* const values = async function * () { | ||
* yield * [0, 1, 2, 3, 4] | ||
* } | ||
* | ||
* const arr = await all(take(values(), 2)) | ||
* | ||
* console.info(arr) // 0, 1 | ||
* ``` | ||
*/ | ||
/** | ||
* Stop iteration after n items have been received | ||
@@ -3,0 +37,0 @@ */ |
@@ -0,1 +1,35 @@ | ||
/** | ||
* @packageDocumentation | ||
* | ||
* For when you only want a few values out of an (async)iterable. | ||
* | ||
* @example | ||
* | ||
* ```javascript | ||
* import take from 'it-take' | ||
* import all from 'it-all' | ||
* | ||
* // This can also be an iterator, generator, etc | ||
* const values = [0, 1, 2, 3, 4] | ||
* | ||
* const arr = all(take(values, 2)) | ||
* | ||
* console.info(arr) // 0, 1 | ||
* ``` | ||
* | ||
* Async sources must be awaited: | ||
* | ||
* ```javascript | ||
* import take from 'it-take' | ||
* import all from 'it-all' | ||
* | ||
* const values = async function * () { | ||
* yield * [0, 1, 2, 3, 4] | ||
* } | ||
* | ||
* const arr = await all(take(values(), 2)) | ||
* | ||
* console.info(arr) // 0, 1 | ||
* ``` | ||
*/ | ||
function isAsyncIterable(thing) { | ||
@@ -2,0 +36,0 @@ return thing[Symbol.asyncIterator] != null; |
{ | ||
"name": "it-take", | ||
"version": "3.0.3", | ||
"version": "3.0.4", | ||
"description": "Stop iteration after n items have been received", | ||
@@ -32,2 +32,3 @@ "author": "Alex Potsides <alex@achingbrain.net>", | ||
"parserOptions": { | ||
"project": true, | ||
"sourceType": "module" | ||
@@ -135,5 +136,5 @@ } | ||
"devDependencies": { | ||
"aegir": "^40.0.11", | ||
"aegir": "^41.1.9", | ||
"it-all": "^3.0.0" | ||
} | ||
} |
@@ -1,3 +0,1 @@ | ||
# it-take <!-- omit in toc --> | ||
[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) | ||
@@ -8,28 +6,8 @@ [![CI](https://img.shields.io/github/actions/workflow/status/achingbrain/it/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml?query=branch%3Amaster) | ||
## Table of contents <!-- omit in toc --> | ||
# About | ||
- [Install](#install) | ||
- [Browser `<script>` tag](#browser-script-tag) | ||
- [Usage](#usage) | ||
- [License](#license) | ||
- [Contribution](#contribution) | ||
For when you only want a few values out of an (async)iterable. | ||
## Install | ||
## Example | ||
```console | ||
$ npm i it-take | ||
``` | ||
### Browser `<script>` tag | ||
Loading this module through a script tag will make it's exports available as `ItTake` in the global namespace. | ||
```html | ||
<script src="https://unpkg.com/it-take/dist/index.min.js"></script> | ||
``` | ||
For when you only want a few values out of an iterable. | ||
## Usage | ||
```javascript | ||
@@ -62,4 +40,18 @@ import take from 'it-take' | ||
## License | ||
# Install | ||
```console | ||
$ npm i it-take | ||
``` | ||
## Browser `<script>` tag | ||
Loading this module through a script tag will make it's exports available as `ItTake` in the global namespace. | ||
```html | ||
<script src="https://unpkg.com/it-take/dist/index.min.js"></script> | ||
``` | ||
# License | ||
Licensed under either of | ||
@@ -70,4 +62,4 @@ | ||
## Contribution | ||
# Contribution | ||
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. |
@@ -0,1 +1,36 @@ | ||
/** | ||
* @packageDocumentation | ||
* | ||
* For when you only want a few values out of an (async)iterable. | ||
* | ||
* @example | ||
* | ||
* ```javascript | ||
* import take from 'it-take' | ||
* import all from 'it-all' | ||
* | ||
* // This can also be an iterator, generator, etc | ||
* const values = [0, 1, 2, 3, 4] | ||
* | ||
* const arr = all(take(values, 2)) | ||
* | ||
* console.info(arr) // 0, 1 | ||
* ``` | ||
* | ||
* Async sources must be awaited: | ||
* | ||
* ```javascript | ||
* import take from 'it-take' | ||
* import all from 'it-all' | ||
* | ||
* const values = async function * () { | ||
* yield * [0, 1, 2, 3, 4] | ||
* } | ||
* | ||
* const arr = await all(take(values(), 2)) | ||
* | ||
* console.info(arr) // 0, 1 | ||
* ``` | ||
*/ | ||
function isAsyncIterable <T> (thing: any): thing is AsyncIterable<T> { | ||
@@ -2,0 +37,0 @@ return thing[Symbol.asyncIterator] != null |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11622
186
63