Comparing version 2.0.4 to 2.1.0
@@ -82,3 +82,3 @@ module.exports = chainit; | ||
.forEach(function(name) { | ||
Chain[name] = new Function(Constructor[name]); | ||
Chain[name] = Constructor[name]; | ||
}); | ||
@@ -85,0 +85,0 @@ |
{ | ||
"name": "chainit", | ||
"version": "2.0.4", | ||
"version": "2.1.0", | ||
"description": "Turn an asynchronous JavaScript api into an asynchronous chainable JavaScript api.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -73,2 +73,3 @@ # chainit [![Build Status](https://travis-ci.org/vvo/chainit.png)](https://travis-ci.org/vvo/chainit) [![Dependency Status](https://david-dm.org/vvo/chainit.svg?theme=shields.io)](https://david-dm.org/vvo/chainit) [![devDependency Status](https://david-dm.org/vvo/chainit/dev-status.svg?theme=shields.io)](https://david-dm.org/vvo/chainit#info=devDependencies) | ||
* supports (crazy) nested calls | ||
* supports static and prototype methods | ||
* preserve nested calls order | ||
@@ -75,0 +76,0 @@ * preserve context in cb() |
@@ -395,2 +395,101 @@ describe('chaining an Api', function() { | ||
describe('should be able to chain', function() { | ||
describe('static', function() { | ||
it('anonymous function expressions', function() { | ||
var Class = function() {}; | ||
var executed = false; | ||
Class.method = function() { | ||
executed = true; | ||
}; | ||
var NewClass = chainit(Class); | ||
var o = new NewClass(); | ||
// should exist | ||
assert.ok(NewClass.method); | ||
NewClass.method(); | ||
assert.ok(executed); | ||
// should not exists because method is static | ||
assert.strictEqual(typeof o.method,'undefined'); | ||
}); | ||
it('named function expressions', function() { | ||
var Class = function() {}; | ||
var executed = false; | ||
Class.method = function method() { | ||
executed = true; | ||
}; | ||
var NewClass = chainit(Class); | ||
var o = new NewClass(); | ||
// should exist | ||
assert.ok(NewClass.method); | ||
NewClass.method(); | ||
assert.ok(executed); | ||
// should not exists because method is static | ||
assert.strictEqual(typeof o.method,'undefined'); | ||
}); | ||
}); | ||
describe('prototypical', function() { | ||
it('anonymous function expressions', function(done) { | ||
var Class = function() {}; | ||
var executed = false; | ||
Class.prototype.method = function(obsolete,cb) { | ||
executed = true; | ||
cb(); | ||
}; | ||
var NewClass = chainit(Class); | ||
var o = new NewClass(); | ||
// should not exist because method is a prototype function | ||
assert.strictEqual(typeof NewClass.method, 'undefined'); | ||
// should exists | ||
assert.ok(o.method); | ||
o.method('obsolete', function() { | ||
assert.ok(executed); | ||
done(); | ||
}); | ||
}); | ||
it('named function expressions', function(done) { | ||
var Class = function() {}; | ||
var executed = false; | ||
Class.prototype.method = function method(obsolete,cb) { | ||
executed = true; | ||
cb(); | ||
}; | ||
var NewClass = chainit(Class); | ||
var o = new NewClass(); | ||
// should not exist because method is a prototype function | ||
assert.strictEqual(typeof NewClass.method, 'undefined'); | ||
// should exists | ||
assert.ok(o.method); | ||
o.method('obsolete', function() { | ||
assert.ok(executed); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
24956
645
125
0