Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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 1.0.1 to 1.0.2

.travis.yml

4

index.js
'use strict'
async function * batch (source, size) {
if (isNaN(size)) {
size = parseInt(size)
if (isNaN(size) || size < 1) {
size = 1

@@ -6,0 +8,0 @@ }

{
"name": "it-batch",
"version": "1.0.1",
"version": "1.0.2",
"description": "Takes an async iterator that emits things and emits them as fixed size batches",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -19,1 +19,33 @@ import batch from './'

})
test('Should batch up entries with negative batch size', async (t) => {
const values = [0, 1, 2, 3, 4]
const batchSize = -1
const res = await all(batch(values, batchSize))
t.deepEqual(res, [[0], [1], [2], [3], [4]])
})
test('Should batch up entries with zero batch size', async (t) => {
const values = [0, 1, 2, 3, 4]
const batchSize = 0
const res = await all(batch(values, batchSize))
t.deepEqual(res, [[0], [1], [2], [3], [4]])
})
test('Should batch up entries with string batch size', async (t) => {
const values = [0, 1, 2, 3, 4]
const batchSize = '2'
const res = await all(batch(values, batchSize))
t.deepEqual(res, [[0, 1], [2, 3], [4]])
})
test('Should batch up entries with non-integer batch size', async (t) => {
const values = [0, 1, 2, 3, 4]
const batchSize = 2.5
const res = await all(batch(values, batchSize))
t.deepEqual(res, [[0, 1], [2, 3], [4]])
})
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