Comparing version 0.0.4 to 0.1.0
{ | ||
"name": "reflux", | ||
"version": "0.0.4", | ||
"version": "0.1.0", | ||
"homepage": "https://github.com/spoike/reflux", | ||
@@ -29,4 +29,3 @@ "authors": [ | ||
"dependencies": { | ||
"lodash": "~2.4.1" | ||
} | ||
} |
@@ -345,5 +345,4 @@ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Reflux=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){ | ||
},{"events":1}],3:[function(_dereq_,module,exports){ | ||
(function (global){ | ||
var EventEmitter = _dereq_('events').EventEmitter, | ||
_ = (typeof window !== "undefined" ? window._ : typeof global !== "undefined" ? global._ : null); | ||
_ = _dereq_('./utils'); | ||
@@ -364,3 +363,3 @@ /** | ||
} | ||
_.assign(Store.prototype, definition); | ||
_.extend(Store.prototype, definition); | ||
Store.prototype.listenTo = function(listenable, callback) { | ||
@@ -390,9 +389,34 @@ if (!_.isFunction(listenable.listen)) { | ||
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{"events":1}],4:[function(_dereq_,module,exports){ | ||
},{"./utils":5,"events":1}],4:[function(_dereq_,module,exports){ | ||
exports.createAction = _dereq_('./createAction'); | ||
exports.createStore = _dereq_('./createStore'); | ||
},{"./createAction":2,"./createStore":3}]},{},[4]) | ||
},{"./createAction":2,"./createStore":3}],5:[function(_dereq_,module,exports){ | ||
/* | ||
* isObject, extend and isFunction are taken from undescore/lodash in | ||
* order to remove the dependency | ||
*/ | ||
var isObject = module.exports.isObject = function(obj) { | ||
var type = typeof obj; | ||
return type === 'function' || type === 'object' && !!obj; | ||
}; | ||
module.exports.extend = function(obj) { | ||
if (!isObject(obj)) return obj; | ||
var source, prop; | ||
for (var i = 1, length = arguments.length; i < length; i++) { | ||
source = arguments[i]; | ||
for (prop in source) { | ||
obj[prop] = source[prop]; | ||
} | ||
} | ||
return obj; | ||
}; | ||
module.exports.isFunction = function(value) { | ||
return typeof value === 'function'; | ||
}; | ||
},{}]},{},[4]) | ||
(4) | ||
}); |
@@ -1,1 +0,1 @@ | ||
!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.Reflux=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b){function c(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function d(a){return"function"==typeof a}function e(a){return"number"==typeof a}function f(a){return"object"==typeof a&&null!==a}function g(a){return void 0===a}b.exports=c,c.EventEmitter=c,c.prototype._events=void 0,c.prototype._maxListeners=void 0,c.defaultMaxListeners=10,c.prototype.setMaxListeners=function(a){if(!e(a)||0>a||isNaN(a))throw TypeError("n must be a positive number");return this._maxListeners=a,this},c.prototype.emit=function(a){var b,c,e,h,i,j;if(this._events||(this._events={}),"error"===a&&(!this._events.error||f(this._events.error)&&!this._events.error.length))throw b=arguments[1],b instanceof Error?b:TypeError('Uncaught, unspecified "error" event.');if(c=this._events[a],g(c))return!1;if(d(c))switch(arguments.length){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(e=arguments.length,h=new Array(e-1),i=1;e>i;i++)h[i-1]=arguments[i];c.apply(this,h)}else if(f(c)){for(e=arguments.length,h=new Array(e-1),i=1;e>i;i++)h[i-1]=arguments[i];for(j=c.slice(),e=j.length,i=0;e>i;i++)j[i].apply(this,h)}return!0},c.prototype.addListener=function(a,b){var e;if(!d(b))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,d(b.listener)?b.listener:b),this._events[a]?f(this._events[a])?this._events[a].push(b):this._events[a]=[this._events[a],b]:this._events[a]=b,f(this._events[a])&&!this._events[a].warned){var e;e=g(this._maxListeners)?c.defaultMaxListeners:this._maxListeners,e&&e>0&&this._events[a].length>e&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),"function"==typeof console.trace&&console.trace())}return this},c.prototype.on=c.prototype.addListener,c.prototype.once=function(a,b){function c(){this.removeListener(a,c),e||(e=!0,b.apply(this,arguments))}if(!d(b))throw TypeError("listener must be a function");var e=!1;return c.listener=b,this.on(a,c),this},c.prototype.removeListener=function(a,b){var c,e,g,h;if(!d(b))throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(c=this._events[a],g=c.length,e=-1,c===b||d(c.listener)&&c.listener===b)delete this._events[a],this._events.removeListener&&this.emit("removeListener",a,b);else if(f(c)){for(h=g;h-->0;)if(c[h]===b||c[h].listener&&c[h].listener===b){e=h;break}if(0>e)return this;1===c.length?(c.length=0,delete this._events[a]):c.splice(e,1),this._events.removeListener&&this.emit("removeListener",a,b)}return this},c.prototype.removeAllListeners=function(a){var b,c;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[a]&&delete this._events[a],this;if(0===arguments.length){for(b in this._events)"removeListener"!==b&&this.removeAllListeners(b);return this.removeAllListeners("removeListener"),this._events={},this}if(c=this._events[a],d(c))this.removeListener(a,c);else for(;c.length;)this.removeListener(a,c[c.length-1]);return delete this._events[a],this},c.prototype.listeners=function(a){var b;return b=this._events&&this._events[a]?d(this._events[a])?[this._events[a]]:this._events[a].slice():[]},c.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?d(a._events[b])?1:a._events[b].length:0}},{}],2:[function(a,b){var c=a("events").EventEmitter;b.exports=function(){var a,b=new c,d="action";return a=function(){b.emit(d,Array.prototype.slice.call(arguments,0))},a.listen=function(a,c){var e=function(b){a.apply(c,b)};return b.addListener(d,e),function(){b.removeListener(d,e)}},a}},{events:1}],3:[function(a,b){(function(c){var d=a("events").EventEmitter,e="undefined"!=typeof window?window._:"undefined"!=typeof c?c._:null;b.exports=function(a){function b(){this.init&&e.isFunction(this.init)&&this.init()}var c=new d,f="change";return e.assign(b.prototype,a),b.prototype.listenTo=function(a,b){if(!e.isFunction(a.listen))throw new TypeError(a+" is missing a listen method");return a.listen(b,this)},b.prototype.listen=function(a,b){var d=function(c){a.apply(b,c)};return c.addListener(f,d),function(){action.removeListener(f,d)}},b.prototype.trigger=function(){var a=Array.prototype.slice.call(arguments,0);c.emit(f,a)},new b}}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{events:1}],4:[function(a,b,c){c.createAction=a("./createAction"),c.createStore=a("./createStore")},{"./createAction":2,"./createStore":3}]},{},[4])(4)}); | ||
!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.Reflux=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b){function c(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function d(a){return"function"==typeof a}function e(a){return"number"==typeof a}function f(a){return"object"==typeof a&&null!==a}function g(a){return void 0===a}b.exports=c,c.EventEmitter=c,c.prototype._events=void 0,c.prototype._maxListeners=void 0,c.defaultMaxListeners=10,c.prototype.setMaxListeners=function(a){if(!e(a)||0>a||isNaN(a))throw TypeError("n must be a positive number");return this._maxListeners=a,this},c.prototype.emit=function(a){var b,c,e,h,i,j;if(this._events||(this._events={}),"error"===a&&(!this._events.error||f(this._events.error)&&!this._events.error.length))throw b=arguments[1],b instanceof Error?b:TypeError('Uncaught, unspecified "error" event.');if(c=this._events[a],g(c))return!1;if(d(c))switch(arguments.length){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(e=arguments.length,h=new Array(e-1),i=1;e>i;i++)h[i-1]=arguments[i];c.apply(this,h)}else if(f(c)){for(e=arguments.length,h=new Array(e-1),i=1;e>i;i++)h[i-1]=arguments[i];for(j=c.slice(),e=j.length,i=0;e>i;i++)j[i].apply(this,h)}return!0},c.prototype.addListener=function(a,b){var e;if(!d(b))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,d(b.listener)?b.listener:b),this._events[a]?f(this._events[a])?this._events[a].push(b):this._events[a]=[this._events[a],b]:this._events[a]=b,f(this._events[a])&&!this._events[a].warned){var e;e=g(this._maxListeners)?c.defaultMaxListeners:this._maxListeners,e&&e>0&&this._events[a].length>e&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),"function"==typeof console.trace&&console.trace())}return this},c.prototype.on=c.prototype.addListener,c.prototype.once=function(a,b){function c(){this.removeListener(a,c),e||(e=!0,b.apply(this,arguments))}if(!d(b))throw TypeError("listener must be a function");var e=!1;return c.listener=b,this.on(a,c),this},c.prototype.removeListener=function(a,b){var c,e,g,h;if(!d(b))throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(c=this._events[a],g=c.length,e=-1,c===b||d(c.listener)&&c.listener===b)delete this._events[a],this._events.removeListener&&this.emit("removeListener",a,b);else if(f(c)){for(h=g;h-->0;)if(c[h]===b||c[h].listener&&c[h].listener===b){e=h;break}if(0>e)return this;1===c.length?(c.length=0,delete this._events[a]):c.splice(e,1),this._events.removeListener&&this.emit("removeListener",a,b)}return this},c.prototype.removeAllListeners=function(a){var b,c;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[a]&&delete this._events[a],this;if(0===arguments.length){for(b in this._events)"removeListener"!==b&&this.removeAllListeners(b);return this.removeAllListeners("removeListener"),this._events={},this}if(c=this._events[a],d(c))this.removeListener(a,c);else for(;c.length;)this.removeListener(a,c[c.length-1]);return delete this._events[a],this},c.prototype.listeners=function(a){var b;return b=this._events&&this._events[a]?d(this._events[a])?[this._events[a]]:this._events[a].slice():[]},c.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?d(a._events[b])?1:a._events[b].length:0}},{}],2:[function(a,b){var c=a("events").EventEmitter;b.exports=function(){var a,b=new c,d="action";return a=function(){b.emit(d,Array.prototype.slice.call(arguments,0))},a.listen=function(a,c){var e=function(b){a.apply(c,b)};return b.addListener(d,e),function(){b.removeListener(d,e)}},a}},{events:1}],3:[function(a,b){var c=a("events").EventEmitter,d=a("./utils");b.exports=function(a){function b(){this.init&&d.isFunction(this.init)&&this.init()}var e=new c,f="change";return d.extend(b.prototype,a),b.prototype.listenTo=function(a,b){if(!d.isFunction(a.listen))throw new TypeError(a+" is missing a listen method");return a.listen(b,this)},b.prototype.listen=function(a,b){var c=function(c){a.apply(b,c)};return e.addListener(f,c),function(){action.removeListener(f,c)}},b.prototype.trigger=function(){var a=Array.prototype.slice.call(arguments,0);e.emit(f,a)},new b}},{"./utils":5,events:1}],4:[function(a,b,c){c.createAction=a("./createAction"),c.createStore=a("./createStore")},{"./createAction":2,"./createStore":3}],5:[function(a,b){var c=b.exports.isObject=function(a){var b=typeof a;return"function"===b||"object"===b&&!!a};b.exports.extend=function(a){if(!c(a))return a;for(var b,d,e=1,f=arguments.length;f>e;e++){b=arguments[e];for(d in b)a[d]=b[d]}return a},b.exports.isFunction=function(a){return"function"==typeof a}},{}]},{},[4])(4)}); |
{ | ||
"name": "reflux", | ||
"version": "0.0.4", | ||
"version": "0.1.0", | ||
"description": "A simple library for uni-directional dataflow application architecture inspired by ReactJS Flux", | ||
@@ -20,8 +20,4 @@ "main": "src/index.js", | ||
}, | ||
"browserify-shim": { | ||
"lodash": "global:_" | ||
}, | ||
"dependencies": { | ||
"lodash": "~2.4.1" | ||
}, | ||
"browserify-shim": {}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
@@ -31,2 +27,3 @@ "browserify": "^4.2.0", | ||
"chai": "^1.9.1", | ||
"chai-as-promised": "^4.1.1", | ||
"grunt": "^0.4.5", | ||
@@ -33,0 +30,0 @@ "grunt-browserify": "^2.1.2", |
@@ -5,2 +5,4 @@ # Reflux | ||
[![Build Status](https://travis-ci.org/spoike/reflux.svg?branch=master)](https://travis-ci.org/spoike/reflux) | ||
You can read an overview of Flux [here](http://facebook.github.io/react/docs/flux-overview.html), however the gist of it is to introduce a more functional programming style architecture by eschewing MVC like pattern and adopting a single data flow pattern. | ||
@@ -41,4 +43,2 @@ | ||
It will also download lodash as a dependency. | ||
## Usage | ||
@@ -45,0 +45,0 @@ |
var EventEmitter = require('events').EventEmitter, | ||
_ = require('lodash'); | ||
_ = require('./utils'); | ||
@@ -18,3 +18,3 @@ /** | ||
} | ||
_.assign(Store.prototype, definition); | ||
_.extend(Store.prototype, definition); | ||
Store.prototype.listenTo = function(listenable, callback) { | ||
@@ -21,0 +21,0 @@ if (!_.isFunction(listenable.listen)) { |
@@ -1,5 +0,8 @@ | ||
var assert = require('chai').assert, | ||
var chai = require('chai'), | ||
assert = chai.assert, | ||
Reflux = require('../src'), | ||
Q = require('q'); | ||
chai.use(require('chai-as-promised')); | ||
describe('Creating action', function() { | ||
@@ -37,8 +40,4 @@ | ||
it('should receive the correct arguments', function(done) { | ||
promise.then(function(args) { | ||
assert.equal(args[0], testArgs[0]); | ||
assert.equal(args[1], testArgs[1]); | ||
done(); | ||
}).catch(done); | ||
it('should receive the correct arguments', function() { | ||
return assert.eventually.deepEqual(promise, testArgs); | ||
}); | ||
@@ -45,0 +44,0 @@ |
@@ -1,5 +0,8 @@ | ||
var assert = require('chai').assert, | ||
var chai = require('chai'), | ||
assert = chai.assert, | ||
Reflux = require('../src'), | ||
Q = require('q'); | ||
chai.use(require('chai-as-promised')); | ||
var slice = Array.prototype.slice; | ||
@@ -35,18 +38,12 @@ | ||
it('should get argument given by action', function(done) { | ||
it('should get argument given by action', function() { | ||
action('my argument'); | ||
promise.then(function(args) { | ||
assert.deepEqual(args, ['my argument']); | ||
done(); | ||
}).catch(done); | ||
return assert.eventually.deepEqual(promise, ['my argument']); | ||
}); | ||
it('should get any arbitrary arguments given on action', function(done) { | ||
it('should get any arbitrary arguments given on action', function() { | ||
action(1337, 'ninja'); | ||
promise.then(function(args){ | ||
assert.deepEqual(args, [1337, 'ninja']); | ||
done(); | ||
}).catch(done); | ||
return assert.eventually.deepEqual(promise, [1337, 'ninja']); | ||
}); | ||
@@ -53,0 +50,0 @@ }); |
@@ -1,5 +0,8 @@ | ||
var assert = require('chai').assert, | ||
var chai = require('chai'), | ||
assert = chai.assert, | ||
Reflux = require('../src'), | ||
Q = require('q'); | ||
chai.use(require('chai-as-promised')); | ||
describe('Creating stores', function() { | ||
@@ -10,3 +13,4 @@ | ||
store, | ||
promise; | ||
promise, | ||
unsubCallback; | ||
@@ -18,3 +22,3 @@ beforeEach(function() { | ||
init: function() { | ||
this.listenTo(action, this.actionCalled); | ||
unsubCallback = this.listenTo(action, this.actionCalled); | ||
}, | ||
@@ -28,22 +32,33 @@ actionCalled: function() { | ||
it('should get argument given on action', function(done) { | ||
it('should get argument given on action', function() { | ||
action('my argument'); | ||
promise.then(function(args) { | ||
assert.equal(args[0], 'my argument'); | ||
done(); | ||
}).catch(done); | ||
return assert.eventually.equal(promise, 'my argument'); | ||
}); | ||
it('should get any arbitrary arguments given on action', function(done) { | ||
it('should get any arbitrary arguments given on action', function() { | ||
action(1337, 'ninja'); | ||
promise.then(function(args){ | ||
assert.equal(args[0], 1337); | ||
assert.equal(args[1], 'ninja'); | ||
done(); | ||
}).catch(done); | ||
return assert.eventually.deepEqual(promise, [1337, 'ninja']); | ||
}); | ||
describe('and with listener unsubscribed', function() { | ||
beforeEach(function() { | ||
unsubCallback(); | ||
}); | ||
it('shouldn\'t have been called when action is called', function(done) { | ||
action(1337, 'ninja'); | ||
promise.then(function() { | ||
assert.fail(); | ||
}); | ||
setTimeout(done, 200); | ||
}); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37407
0
17
695
12
- Removedlodash@~2.4.1
- Removedlodash@2.4.2(transitive)