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

eden-class

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eden-class - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

LICENSE

100

class.js
module.exports = require('classified-magic')(function(prototype) {
/* Require
-------------------------------*/
var argument = require('argument');
var argument = require('argument');
var sync = require('syncopate');

@@ -16,8 +17,2 @@ /* Constants

-------------------------------*/
prototype.__sequence = {
stack : [],
working : false,
args : [],
loop : [] };
var __states = {};

@@ -157,22 +152,13 @@

prototype.sync = function(callback, unshift) {
/**
* Starts a synchronous thread
*
* @param *function
* @return [Syncopate]
*/
prototype.sync = function(callback) {
//argument 1 must be a function
argument.test(1, 'function');
var sequence = this.__sequence;
if(!unshift) {
sequence.stack.push(callback);
} else {
sequence.stack.unshift(callback);
}
if(!sequence.working) {
sequence.working = true;
sequence.scope = this;
this.__next.apply(sequence, sequence.args);
}
return this;
return sync().scope(this).then(callback);
};

@@ -220,69 +206,3 @@

-------------------------------*/
prototype.__next = function() {
var args = Array.prototype.slice.apply(arguments);
//if there is something in the loop
if(this.loop.length) {
//save the last called args
if(!this.last) {
this.last = args;
}
var item = this.loop.shift();
//push in next()
//this function will recurse call
//so no need to parse the loop
item.args.push(arguments.callee.bind(this));
//async call
process.nextTick(function() {
//do the callback
item.callback.apply(this.scope, item.args);
}.bind(this));
return;
}
if(this.last) {
args = this.last;
delete this.last;
}
if(!this.stack.length) {
this.working = false;
this.args = args;
return;
}
var callback = this.stack.shift(),
next = arguments.callee.bind(this);
next.loop = __loop.bind(this);
args.push(next);
//async call
process.nextTick(function() {
//do the callback
callback.apply(this.scope, args);
}.bind(this));
};
var __loop = function() {
if(!this.stack.length) {
return;
}
var item = {args: Array.prototype.slice.apply(arguments) };
//if loop is empty
if(!this.loop.length) {
item.callback = this.stack.shift();
} else {
item.callback = this.loop[0].callback;
}
this.loop.push(item);
};
var _isNative = function(value) {

@@ -289,0 +209,0 @@ //do the easy ones first

{
"name": "eden-class",
"description": "Eden JS Base Class",
"version": "0.0.3",
"version": "0.0.4",
"author": {

@@ -18,2 +18,3 @@ "name": "Christian Blanquera",

"argument": "0.0.2",
"syncopate": "0.0.1",
"classified-magic": "0.0.13"

@@ -20,0 +21,0 @@ },

@@ -27,10 +27,2 @@ var assert = require('assert');

var Member = User.extend({});
var member = Member.load();
var Person = Member.extend({});
var person = Person.load();
describe('Class Test Suite', function() {

@@ -48,80 +40,3 @@ describe('Extending Tests', function() {

});
it('should sync methods', function(done) {
user.sync(function(next) {
next(1);
}).sync(function(value, next) {
this.syncTest = value;
next();
}).sync(function(next) {
assert.equal(1, this.syncTest);
next();
done();
});
});
it('should sync methods in tree', function(done) {
user.sync(function(next) {
next(1);
}).sync(function(value, next) {
this.syncTest = value;
next();
}).sync(function(next) {
assert.equal(1, this.syncTest);
next();
member.sync(function(next) {
next(1);
}).sync(function(value, next) {
this.syncTest = value;
next();
}).sync(function(next) {
assert.equal(1, this.syncTest);
next();
person.sync(function(next) {
next(1);
}).sync(function(value, next) {
this.syncTest = value;
next();
}).sync(function(next) {
assert.equal(1, this.syncTest);
next();
done();
});
});
});
});
it('should loop sync methods', function(done) {
user.sync(function(next) {
for(var i = 0; i < 5; i++) {
next.loop(i);
}
next('yes');
}).sync(function(i, next) {
assert.equal('number', typeof i);
next();
}).sync(function(string, next) {
assert.equal('yes', string);
next();
}).sync(function(next) {
for(var i = 5; i < 10; i++) {
next.loop(i);
}
next([1,2,3,4]);
}).sync(function(i, next) {
assert.equal('number', typeof i);
next();
}).sync(function(list, next) {
assert.equal(true, list instanceof Array);
done();
next();
});
});
});
});
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