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

function-loop

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

function-loop - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

x.js

17

index.js

@@ -7,2 +7,12 @@ module.exports = loop

function once (cb) {
var called = false
return function (er) {
if (called)
return
called = true
return cb.call(this, er)
}
}
function loop (self, arr, cb, onerr, i) {

@@ -14,11 +24,12 @@ if (!i)

while (i < arr.length && !running) {
var onceNext = once(next)
running = true
var sync = true
try {
var ret = arr[i].call(self, next)
var ret = arr[i].call(self, onceNext)
} catch (er) {
return onerr.call(self,er)
return onerr.call(self, er)
}
if (ret && typeof ret.then === 'function')
ret.then(next.bind(self, null), onerr.bind(self))
ret.then(onceNext.bind(self, null), onerr.bind(self))
i++

@@ -25,0 +36,0 @@ sync = false

2

package.json
{
"name": "function-loop",
"version": "1.0.1",
"version": "1.0.2",
"main": "index.js",

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

@@ -108,1 +108,16 @@ var t = require('tap')

})
t.test('cb and also promise resolve', function (t) {
t.plan(1)
loop(obj, [
function (cb) {
return Promise.resolve('foo').then(function () {
cb()
})
}
], function () {
t.pass('finished one time')
}, function (er) {
throw er
})
})
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