Socket
Socket
Sign inDemoInstall

items

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

items - npm Package Compare versions

Comparing version 1.1.1 to 2.0.0

49

lib/index.js

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

'use strict';
// Load modules

@@ -6,3 +8,3 @@

var internals = {};
const internals = {};

@@ -12,11 +14,10 @@

var il = array.length;
if (!il) {
if (!array.length) {
callback();
}
else {
var i = 0;
var iterate = function () {
let i = 0;
const iterate = function () {
var done = function (err) {
const done = function (err) {

@@ -27,4 +28,4 @@ if (err) {

else {
i += 1;
if (i < il) {
i = i + 1;
if (i < array.length) {
iterate();

@@ -48,11 +49,10 @@ }

var il = array.length;
if (!il) {
if (!array.length) {
callback();
}
else {
var count = 0;
var errored = false;
let count = 0;
let errored = false;
var done = function (err) {
const done = function (err) {

@@ -65,3 +65,3 @@ if (!errored) {

else {
count += 1;
count = count + 1;
if (count === array.length) {

@@ -74,3 +74,3 @@ callback();

for (var i = 0; i < il; ++i) {
for (let i = 0; i < array.length; ++i) {
method(array[i], done);

@@ -84,3 +84,3 @@ }

var result = {};
const result = {};
if (!fnObj) {

@@ -90,12 +90,11 @@ return callback(null, result);

var keys = Object.keys(fnObj);
var count = 0;
var il = keys.length;
var errored = false;
const keys = Object.keys(fnObj);
let count = 0;
let errored = false;
if (!il) {
if (!keys.length) {
return callback(null, result);
}
var done = function (key) {
const done = function (key) {

@@ -111,3 +110,3 @@ return function (err, val) {

result[key] = val;
if (++count === il) {
if (++count === keys.length) {
callback(null, result);

@@ -120,5 +119,5 @@ }

for (var i = 0; i < il; ++i) {
for (let i = 0; i < keys.length; ++i) {
if (!errored) {
var key = keys[i];
const key = keys[i];
fnObj[key](done(key));

@@ -125,0 +124,0 @@ }

{
"name": "items",
"description": "Bare minimum async methods",
"version": "1.1.1",
"version": "2.0.0",
"repository": "git://github.com/hapijs/items",

@@ -13,3 +13,3 @@ "main": "lib/index.js",

"engines": {
"node": ">=0.10.40"
"node": ">=4.0.0"
},

@@ -19,4 +19,4 @@ "dependencies": {

"devDependencies": {
"lab": "5.x.x",
"code": "1.x.x"
"code": "2.x.x",
"lab": "7.x.x"
},

@@ -23,0 +23,0 @@ "scripts": {

@@ -0,6 +1,8 @@

'use strict';
// Load modules
var Code = require('code');
var Lab = require('lab');
var Items = require('../');
const Code = require('code');
const Lab = require('lab');
const Items = require('../');

@@ -10,3 +12,3 @@

var internals = {};
const internals = {};

@@ -16,17 +18,17 @@

var lab = exports.lab = Lab.script();
var describe = lab.experiment;
var it = lab.it;
var expect = Code.expect;
const lab = exports.lab = Lab.script();
const describe = lab.experiment;
const it = lab.it;
const expect = Code.expect;
describe('Items', function () {
describe('Items', () => {
describe('serial()', function () {
describe('serial()', () => {
it('calls methods in serial', function (done) {
it('calls methods in serial', (done) => {
var called = [];
var array = [1, 2, 3, 4, 5];
var method = function (item, next) {
const called = [];
const array = [1, 2, 3, 4, 5];
const method = function (item, next) {

@@ -37,3 +39,3 @@ called.push(item);

Items.serial(array, method, function (err) {
Items.serial(array, method, (err) => {

@@ -46,7 +48,7 @@ expect(err).to.not.exist();

it('skips on empty array', function (done) {
it('skips on empty array', (done) => {
var called = [];
var array = [];
var method = function (item, next) {
const called = [];
const array = [];
const method = function (item, next) {

@@ -57,3 +59,3 @@ called.push(item);

Items.serial(array, method, function (err) {
Items.serial(array, method, (err) => {

@@ -66,7 +68,7 @@ expect(err).to.not.exist();

it('aborts with error', function (done) {
it('aborts with error', (done) => {
var called = [];
var array = [1, 2, 3, 4, 5];
var method = function (item, next) {
const called = [];
const array = [1, 2, 3, 4, 5];
const method = function (item, next) {

@@ -81,3 +83,3 @@ called.push(item);

Items.serial(array, method, function (err) {
Items.serial(array, method, (err) => {

@@ -91,11 +93,11 @@ expect(err).to.equal('error');

describe('parallel()', function () {
describe('parallel()', () => {
it('calls methods in parallel', function (done) {
it('calls methods in parallel', (done) => {
var called = [];
var array = [[1, 1], [2, 4], [3, 2], [4, 3], [5, 5]];
var method = function (item, next) {
const called = [];
const array = [[1, 1], [2, 4], [3, 2], [4, 3], [5, 5]];
const method = function (item, next) {
setTimeout(function () {
setTimeout(() => {

@@ -107,3 +109,3 @@ called.push(item[0]);

Items.parallel(array, method, function (err) {
Items.parallel(array, method, (err) => {

@@ -116,9 +118,9 @@ expect(err).to.not.exist();

it('skips on empty array', function (done) {
it('skips on empty array', (done) => {
var called = [];
var array = [];
var method = function (item, next) {
const called = [];
const array = [];
const method = function (item, next) {
setTimeout(function () {
setTimeout(() => {

@@ -130,3 +132,3 @@ called.push(item[0]);

Items.parallel(array, method, function (err) {
Items.parallel(array, method, (err) => {

@@ -139,9 +141,9 @@ expect(err).to.not.exist();

it('aborts with error', function (done) {
it('aborts with error', (done) => {
var called = [];
var array = [[1, 1], [2, 4], [3, 2], [4, 3], [5, 5]];
var method = function (item, next) {
const called = [];
const array = [[1, 1], [2, 4], [3, 2], [4, 3], [5, 5]];
const method = function (item, next) {
setTimeout(function () {
setTimeout(() => {

@@ -157,3 +159,3 @@ if (item[0] === 3) {

Items.parallel(array, method, function (err) {
Items.parallel(array, method, (err) => {

@@ -163,3 +165,3 @@ expect(err).to.equal('error');

setTimeout(function () {
setTimeout(() => {

@@ -173,7 +175,7 @@ expect(called).to.deep.equal([1, 4, 2, 5]);

describe('parallel.execute()', function () {
describe('parallel.execute()', () => {
it('calls methods in parallel and returns the result', function (done) {
it('calls methods in parallel and returns the result', (done) => {
var fns = {
const fns = {
fn1: function (next) {

@@ -189,3 +191,3 @@

Items.parallel.execute(fns, function (err, result) {
Items.parallel.execute(fns, (err, result) => {

@@ -199,7 +201,7 @@ expect(err).to.not.exist();

it('returns an empty object to the callback when passed an empty object', function (done) {
it('returns an empty object to the callback when passed an empty object', (done) => {
var fns = {};
const fns = {};
Items.parallel.execute(fns, function (err, result) {
Items.parallel.execute(fns, (err, result) => {

@@ -212,5 +214,5 @@ expect(err).to.not.exist();

it('returns an empty object to the callback when passed a null object', function (done) {
it('returns an empty object to the callback when passed a null object', (done) => {
Items.parallel.execute(null, function (err, result) {
Items.parallel.execute(null, (err, result) => {

@@ -223,8 +225,8 @@ expect(err).to.not.exist();

it('exits early and result object is missing when an error is passed to callback', function (done) {
it('exits early and result object is missing when an error is passed to callback', (done) => {
var fns = {
const fns = {
fn1: function (next) {
setImmediate(function () {
setImmediate(() => {

@@ -236,3 +238,3 @@ next(null, 'hello');

setImmediate(function () {
setImmediate(() => {

@@ -245,3 +247,3 @@ next(new Error('This is my error'));

setImmediate(function () {
setImmediate(() => {

@@ -253,3 +255,3 @@ next(null, 'bye');

Items.parallel.execute(fns, function (err, result) {
Items.parallel.execute(fns, (err, result) => {

@@ -262,6 +264,6 @@ expect(err).to.exist();

it('exits early and doesn\'t execute other functions on an error', function (done) {
it('exits early and doesn\'t execute other functions on an error', (done) => {
var fn2Executed = false;
var fns = {
let fn2Executed = false;
const fns = {
fn1: function (next) {

@@ -273,3 +275,3 @@

setImmediate(function () {
setImmediate(() => {

@@ -282,3 +284,3 @@ fn2Executed = true;

Items.parallel.execute(fns, function (err, result) {
Items.parallel.execute(fns, (err, result) => {

@@ -292,5 +294,5 @@ expect(err).to.exist();

it('handles multiple errors being returned by sending first error', function (done) {
it('handles multiple errors being returned by sending first error', (done) => {
var fns = {
const fns = {
fn1: function (next) {

@@ -311,3 +313,3 @@

Items.parallel.execute(fns, function (err, result) {
Items.parallel.execute(fns, (err, result) => {

@@ -314,0 +316,0 @@ expect(err).to.exist();

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