New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

array-chunk-reader

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-chunk-reader - npm Package Compare versions

Comparing version 0.1.7 to 0.1.8

9

array-chunk-reader.js

@@ -68,6 +68,7 @@ (function () {

if (info.from >= length) {
if (info.from >= length || this.__stopped) {
let result = {};
result.avgChunkTime = lastInfo.avgTime || 0;
result.chunkCount = lastInfo.iteration || 0;
this.__stopped && this.options.log && console.log("Array chunk reader has been stopped");
return callback(null, info, result);

@@ -140,6 +141,10 @@ }

rej(new Error("Array chunk reader failed"));
rej(new Error("Array chunk reader is failed"));
});
});
}
stop() {
this.__stopped = true;
}
}

@@ -146,0 +151,0 @@

{
"name": "array-chunk-reader",
"version": "0.1.7",
"version": "0.1.8",
"description": "Module for reading array by chunks using promise",

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

@@ -38,1 +38,4 @@ # Install

returns the current chunk size
### .stop()
cancel all next chunks after the current

@@ -17,3 +17,3 @@ "use strict";

describe('api', function() {
describe('#constructor', function () {
describe('.constructor', function () {
it('check instance', function () {

@@ -25,3 +25,3 @@ reader = new ArrayChunkReader(array, {log: false, size: size});

describe('#start()', function () {
describe('.start()', function () {
it('check returned fn value', function () {

@@ -55,3 +55,22 @@ let counter = 1;

describe('#getCurrentChunkSize()', function () {
describe('.stop()', function () {
it('check returned fn value', function () {
let counter = 0;
let size = 5;
reader = new ArrayChunkReader(array, {size: size, log: false});
return reader.start(() => {
counter++;
if(counter == 3) {
reader.stop();
}
}).then((res) => {
assert.equal(counter, size);
});
});
});
describe('.getCurrentChunkSize()', function () {
it('check chunk size in every fnChunk', function () {

@@ -67,3 +86,3 @@ let fn = (value) => {

});
});
});
});

@@ -70,0 +89,0 @@

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