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

chainit

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chainit - npm Package Compare versions

Comparing version 2.0.4 to 2.1.0

2

index.js

@@ -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();
});
});
});
});
});
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