Socket
Socket
Sign inDemoInstall

it-batch

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

it-batch - npm Package Compare versions

Comparing version 3.0.3 to 3.0.4

36

dist/src/index.d.ts
/**
* @packageDocumentation
*
* The final batch may be smaller than the max.
*
* @example
*
* ```javascript
* import batch from 'it-batch'
* import all from 'it-all'
*
* // This can also be an iterator, generator, etc
* const values = [0, 1, 2, 3, 4]
* const batchSize = 2
*
* const result = all(batch(values, batchSize))
*
* console.info(result) // [0, 1], [2, 3], [4]
* ```
*
* Async sources must be awaited:
*
* ```javascript
* import batch from 'it-batch'
* import all from 'it-all'
*
* const values = async function * () {
* yield * [0, 1, 2, 3, 4]
* }
*
* const batchSize = 2
* const result = await all(batch(values(), batchSize))
*
* console.info(result) // [0, 1], [2, 3], [4]
* ```
*/
/**
* Takes an (async) iterable that emits things and returns an async iterable that

@@ -3,0 +39,0 @@ * emits those things in fixed-sized batches

@@ -0,1 +1,37 @@

/**
* @packageDocumentation
*
* The final batch may be smaller than the max.
*
* @example
*
* ```javascript
* import batch from 'it-batch'
* import all from 'it-all'
*
* // This can also be an iterator, generator, etc
* const values = [0, 1, 2, 3, 4]
* const batchSize = 2
*
* const result = all(batch(values, batchSize))
*
* console.info(result) // [0, 1], [2, 3], [4]
* ```
*
* Async sources must be awaited:
*
* ```javascript
* import batch from 'it-batch'
* import all from 'it-all'
*
* const values = async function * () {
* yield * [0, 1, 2, 3, 4]
* }
*
* const batchSize = 2
* const result = await all(batch(values(), batchSize))
*
* console.info(result) // [0, 1], [2, 3], [4]
* ```
*/
function isAsyncIterable(thing) {

@@ -2,0 +38,0 @@ return thing[Symbol.asyncIterator] != null;

5

package.json
{
"name": "it-batch",
"version": "3.0.3",
"version": "3.0.4",
"description": "Takes an async iterator that emits things and emits them as fixed size batches",

@@ -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"
}
}

46

README.md

@@ -1,3 +0,1 @@

# it-batch <!-- omit in toc -->
[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it)

@@ -8,27 +6,7 @@ [![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)
## Install
```console
$ npm i it-batch
```
### Browser `<script>` tag
Loading this module through a script tag will make it's exports available as `ItBatch` in the global namespace.
```html
<script src="https://unpkg.com/it-batch/dist/index.min.js"></script>
```
The final batch may be smaller than the max.
## Usage
## Example

@@ -57,4 +35,4 @@ ```javascript

}
const batchSize = 2
const result = await all(batch(values(), batchSize))

@@ -65,4 +43,18 @@

## License
# Install
```console
$ npm i it-batch
```
## Browser `<script>` tag
Loading this module through a script tag will make it's exports available as `ItBatch` in the global namespace.
```html
<script src="https://unpkg.com/it-batch/dist/index.min.js"></script>
```
# License
Licensed under either of

@@ -73,4 +65,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,38 @@

/**
* @packageDocumentation
*
* The final batch may be smaller than the max.
*
* @example
*
* ```javascript
* import batch from 'it-batch'
* import all from 'it-all'
*
* // This can also be an iterator, generator, etc
* const values = [0, 1, 2, 3, 4]
* const batchSize = 2
*
* const result = all(batch(values, batchSize))
*
* console.info(result) // [0, 1], [2, 3], [4]
* ```
*
* Async sources must be awaited:
*
* ```javascript
* import batch from 'it-batch'
* import all from 'it-all'
*
* const values = async function * () {
* yield * [0, 1, 2, 3, 4]
* }
*
* const batchSize = 2
* const result = await all(batch(values(), batchSize))
*
* console.info(result) // [0, 1], [2, 3], [4]
* ```
*/
function isAsyncIterable <T> (thing: any): thing is AsyncIterable<T> {

@@ -2,0 +39,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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc