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

kew

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kew - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

11

kew.js

@@ -15,4 +15,10 @@ /**

this._failFn = onFail
this._context = undefined
}
Promise.prototype.setContext = function (context) {
this._context = context
return this
}
/**

@@ -105,2 +111,3 @@ * Resolve this promise with a specified value

var promise = new Promise(onSuccess, onFail)
if (this._context) promise.setContext(this._context)

@@ -168,3 +175,3 @@ if (this._child) this._child._chainPromise(promise)

try {
this.resolve(this._successFn(data))
this.resolve(this._successFn(data, this._context))
} catch (e) {

@@ -184,3 +191,3 @@ this.reject(e)

try {
this.resolve(this._failFn(e))
this.resolve(this._failFn(e, this._context))
} catch (e) {

@@ -187,0 +194,0 @@ this.reject(e)

2

package.json
{
"name": "kew"
, "description": "a lightweight promise library for node"
, "version": "0.1.1"
, "version": "0.1.2"
, "homepage": "https://github.com/Obvious/kew"

@@ -6,0 +6,0 @@ , "authors": [

@@ -337,2 +337,35 @@ var Q = require('../kew')

})
}
// test that contexts work
exports.testContext = function (test) {
var matches = 0
var originalContext = {name: "Jeremy"}
Q.resolve("hello")
.setContext(originalContext)
.then(function (val, context) {
test.equal(context, originalContext, "Context matches")
matches++
throw new Error("now to fail")
})
.fail(function (e, context) {
test.equal(context, originalContext, "Context matches")
matches++
return Q.all([Q.resolve("a"), Q.resolve("b")])
})
.then(function (vals, context) {
test.equal(context, originalContext, "Context matches")
matches++
return Q.all([Q.resolve("a"), Q.reject(new Error("no"))])
})
.fail(function (e, context) {
test.equal(context, originalContext, "Context matches")
matches++
return Q.all([Q.resolve("a"), Q.resolve("b")])
})
.fin(function () {
test.equal(matches, 4, "Should have matched the context 4 times")
test.done()
})
}
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