New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fluxury

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fluxury - npm Package Compare versions

Comparing version 0.8.0 to 1.0.0

lib/Dispatcher.js

50

dist/fluxury.js
(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);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.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(require,module,exports){
"use strict";function dispatch(e,t){if("string"==typeof e)dispatcher.dispatch({type:e,data:t});else{if("object"!==("undefined"==typeof e?"undefined":_typeof(e)))throw"type must be string or object";dispatcher.dispatch(e)}}function createStore(e,t,r){var n=arguments.length<=3||void 0===arguments[3]?{}:arguments[3],o=Object.freeze(t),i=new _fbemitter.EventEmitter,c={},a=void 0;if("object"===("undefined"==typeof r?"undefined":_typeof(r)))a=function(e,t){return t&&"string"==typeof t.type&&r.hasOwnProperty(t.type)?r[t.type](e,t.data,waitFor):e},c=Object.keys(r).reduce(function(e,t){return e[t]=function(e){return dispatcher.dispatch({type:t,data:e})},e},{});else{if("function"!=typeof r)throw new Error("reducer must be object or function");a=r}var f=Object.keys(n).reduce(function(e,t,r){var i={};return i[t]=function(){for(var e=arguments.length,r=Array(e),i=0;e>i;i++)r[i]=arguments[i];return n[t].apply(n,[o].concat(r))},Object.assign(e,i)},{});return Object.freeze(Object.assign({},f,c,{name:e,dispatchToken:dispatcher.register(function(e){var t=a(o,e,waitFor);o!==t&&(o=Object.freeze(t),i.emit(changedEvent))}),addListener:function(e){if("function"!=typeof e)throw"Callback must be a function";return i.addListener(changedEvent,e)},getState:function(e){return o}}))}Object.defineProperty(exports,"__esModule",{value:!0});var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};exports.dispatch=dispatch,exports.createStore=createStore;var _fbemitter=require("fbemitter"),_flux=require("flux");Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(void 0===e||null===e)throw new TypeError("Cannot convert first argument to object");for(var t=Object(e),r=1;r<arguments.length;r++){var n=arguments[r];if(void 0!==n&&null!==n){n=Object(n);for(var o=Object.keys(n),i=0,c=o.length;c>i;i++){var a=o[i],f=Object.getOwnPropertyDescriptor(n,a);void 0!==f&&f.enumerable&&(t[a]=n[a])}}}return t}}),Object.freeze||(Object.freeze=function(e){if(Object(e)!==e)throw new TypeError("Object.freeze can only be called on Objects.");return e});var dispatcher=new _flux.Dispatcher,changedEvent="change",waitFor=dispatcher.waitFor.bind(dispatcher);
},{"fbemitter":3,"flux":10}],2:[function(require,module,exports){
function cleanUpNextTick(){draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue()}function drainQueue(){if(!draining){var e=setTimeout(cleanUpNextTick);draining=!0;for(var n=queue.length;n;){for(currentQueue=queue,queue=[];++queueIndex<n;)currentQueue&&currentQueue[queueIndex].run();queueIndex=-1,n=queue.length}currentQueue=null,draining=!1,clearTimeout(e)}}function Item(e,n){this.fun=e,this.array=n}function noop(){}var process=module.exports={},queue=[],draining=!1,currentQueue,queueIndex=-1;process.nextTick=function(e){var n=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)n[r-1]=arguments[r];queue.push(new Item(e,n)),1!==queue.length||draining||setTimeout(drainQueue,0)},Item.prototype.run=function(){this.fun.apply(null,this.array)},process.title="browser",process.browser=!0,process.env={},process.argv=[],process.version="",process.versions={},process.on=noop,process.addListener=noop,process.once=noop,process.off=noop,process.removeListener=noop,process.removeAllListeners=noop,process.emit=noop,process.binding=function(e){throw new Error("process.binding is not supported")},process.cwd=function(){return"/"},process.chdir=function(e){throw new Error("process.chdir is not supported")},process.umask=function(){return 0};
"use strict";function _classCallCheck(i,a){if(!(i instanceof a))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function i(i,a){for(var t=0;t<a.length;t++){var n=a[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(i,n.key,n)}}return function(a,t,n){return t&&i(a.prototype,t),n&&i(a,n),a}}(),invariant=require("./invariant"),_lastID=1,_prefix="ID_",Dispatcher=function(){function i(){_classCallCheck(this,i),this._callbacks={},this._isPending={},this._isHandled={},this._isDispatching=!1,this._pendingPayload=null}return _createClass(i,[{key:"register",value:function(i){var a=_prefix+_lastID++;return this._callbacks[a]=i,a}},{key:"unregister",value:function(i){invariant(this._callbacks[i],"Dispatcher.unregister(...): `%s` does not map to a registered callback.",i),delete this._callbacks[i]}},{key:"waitFor",value:function(i){invariant(this._isDispatching,"Dispatcher.waitFor(...): Must be invoked while dispatching.");for(var a=0;a<i.length;a++){var t=i[a];this._isPending[t]?invariant(this._isHandled[t],"Dispatcher.waitFor(...): Circular dependency detected while waiting for `%s`.",t):(invariant(this._callbacks[t],"Dispatcher.waitFor(...): `%s` does not map to a registered callback.",t),this._invokeCallback(t))}}},{key:"dispatch",value:function(i){invariant(!this._isDispatching,"Dispatch.dispatch(...): Cannot dispatch in the middle of a dispatch."),this._startDispatching(i);try{for(var a in this._callbacks)this._isPending[a]||this._invokeCallback(a)}finally{this._stopDispatching()}}},{key:"isDispatching",value:function(){return this._isDispatching}},{key:"_invokeCallback",value:function(i){this._isPending[i]=!0,this._callbacks[i](this._pendingPayload),this._isHandled[i]=!0}},{key:"_startDispatching",value:function(i){for(var a in this._callbacks)this._isPending[a]=!1,this._isHandled[a]=!1;this._pendingPayload=i,this._isDispatching=!0}},{key:"_stopDispatching",value:function(){this._pendingPayload=null,this._isDispatching=!1}}]),i}();module.exports=Dispatcher;
},{}],3:[function(require,module,exports){
var fbemitter={EventEmitter:require("./lib/BaseEventEmitter")};module.exports=fbemitter;
},{"./invariant":3}],2:[function(require,module,exports){
"use strict";function dispatch(e,t){if("string"==typeof e)dispatcher.dispatch({type:e,data:t});else{if("object"!==("undefined"==typeof e?"undefined":_typeof(e)))throw"type must be string or object";dispatcher.dispatch(e)}}function createStore(e,t,r){var n=arguments.length<=3||void 0===arguments[3]?{}:arguments[3],o="function"!=typeof t?Object.freeze(t):Object.freeze({}),c=new EventEmitter,i={},a=void 0;if("function"==typeof t&&(n=r,r=t),"object"===("undefined"==typeof r?"undefined":_typeof(r)))a=function(e,t){return t&&"string"==typeof t.type&&r.hasOwnProperty(t.type)?r[t.type](e,t.data,waitFor):e},i=Object.keys(r).reduce(function(e,t){return e[t]=function(e){return dispatcher.dispatch({type:t,data:e})},e},{});else{if("function"!=typeof r)throw new Error("reducer must be object or function");a=r}var f=Object.keys(n).reduce(function(e,t,r){var c={};return c[t]=function(){for(var e,r=arguments.length,c=Array(r),i=0;r>i;i++)c[i]=arguments[i];return(e=n)[t].apply(e,[o].concat(c))},Object.assign(e,c)},{});return Object.freeze(Object.assign({},f,i,{name:e,dispatchToken:dispatcher.register(function(e){var t=a(o,e,waitFor);o!==t&&(o=Object.freeze(t),c.emit("changed"))}),addListener:function(e){if("function"!=typeof e)throw"Callback must be a function";return c.addListener("changed",e),count+=1,{id:count,remove:function(){c.removeListener("changed",e)}}},getState:function(e){return o}}))}Object.defineProperty(exports,"__esModule",{value:!0});var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};exports.dispatch=dispatch,exports.createStore=createStore;var EventEmitter=require("events").EventEmitter,Dispatcher=require("./Dispatcher"),count=0;Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(void 0===e||null===e)throw new TypeError("Cannot convert first argument to object");for(var t=Object(e),r=1;r<arguments.length;r++){var n=arguments[r];if(void 0!==n&&null!==n){n=Object(n);for(var o=Object.keys(n),c=0,i=o.length;i>c;c++){var a=o[c],f=Object.getOwnPropertyDescriptor(n,a);void 0!==f&&f.enumerable&&(t[a]=n[a])}}}return t}}),Object.freeze||(Object.freeze=function(e){if(Object(e)!==e)throw new TypeError("Object.freeze can only be called on Objects.");return e});var dispatcher=new Dispatcher,waitFor=dispatcher.waitFor.bind(dispatcher);
},{"./Dispatcher":1,"events":4}],3:[function(require,module,exports){
"use strict";var invariant=function(r,e,n,i,o,a,t,f){if(!r){var s;if(void 0===e)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var d=[n,i,o,a,t,f],l=0;s=new Error("Invariant Violation: "+e.replace(/%s/g,function(){return d[l++]}))}throw s.framesToPop=1,s}};module.exports=invariant;
},{"./lib/BaseEventEmitter":4}],4:[function(require,module,exports){
(function (process){
"use strict";function _classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}var EmitterSubscription=require("./EmitterSubscription"),EventSubscriptionVendor=require("./EventSubscriptionVendor"),emptyFunction=require("fbjs/lib/emptyFunction"),invariant=require("fbjs/lib/invariant"),BaseEventEmitter=function(){function t(){_classCallCheck(this,t),this._subscriber=new EventSubscriptionVendor,this._currentSubscription=null}return t.prototype.addListener=function(t,r,i){return this._subscriber.addSubscription(t,new EmitterSubscription(this._subscriber,r,i))},t.prototype.once=function(t,r,i){var e=this;return this.addListener(t,function(){e.removeCurrentListener(),r.apply(i,arguments)})},t.prototype.removeAllListeners=function(t){this._subscriber.removeAllSubscriptions(t)},t.prototype.removeCurrentListener=function(){this._currentSubscription?void 0:"production"!==process.env.NODE_ENV?invariant(!1,"Not in an emitting cycle; there is no current subscription"):invariant(!1),this._subscriber.removeSubscription(this._currentSubscription)},t.prototype.listeners=function(t){var r=this._subscriber.getSubscriptionsForType(t);return r?r.filter(emptyFunction.thatReturnsTrue).map(function(t){return t.listener}):[]},t.prototype.emit=function(t){var r=this._subscriber.getSubscriptionsForType(t);if(r){for(var i=Object.keys(r),e=0;e<i.length;e++){var n=i[e],s=r[n];s&&(this._currentSubscription=s,this.__emitToSubscription.apply(this,[s].concat(Array.prototype.slice.call(arguments))))}this._currentSubscription=null}},t.prototype.__emitToSubscription=function(t,r){var i=Array.prototype.slice.call(arguments,2);t.listener.apply(t.context,i)},t}();module.exports=BaseEventEmitter;
},{}],4:[function(require,module,exports){
function EventEmitter(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function isFunction(e){return"function"==typeof e}function isNumber(e){return"number"==typeof e}function isObject(e){return"object"==typeof e&&null!==e}function isUndefined(e){return void 0===e}module.exports=EventEmitter,EventEmitter.EventEmitter=EventEmitter,EventEmitter.prototype._events=void 0,EventEmitter.prototype._maxListeners=void 0,EventEmitter.defaultMaxListeners=10,EventEmitter.prototype.setMaxListeners=function(e){if(!isNumber(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},EventEmitter.prototype.emit=function(e){var t,i,n,s,r,o;if(this._events||(this._events={}),"error"===e&&(!this._events.error||isObject(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(i=this._events[e],isUndefined(i))return!1;if(isFunction(i))switch(arguments.length){case 1:i.call(this);break;case 2:i.call(this,arguments[1]);break;case 3:i.call(this,arguments[1],arguments[2]);break;default:s=Array.prototype.slice.call(arguments,1),i.apply(this,s)}else if(isObject(i))for(s=Array.prototype.slice.call(arguments,1),o=i.slice(),n=o.length,r=0;n>r;r++)o[r].apply(this,s);return!0},EventEmitter.prototype.addListener=function(e,t){var i;if(!isFunction(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,isFunction(t.listener)?t.listener:t),this._events[e]?isObject(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,isObject(this._events[e])&&!this._events[e].warned&&(i=isUndefined(this._maxListeners)?EventEmitter.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[e].length>i&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())),this},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.once=function(e,t){function i(){this.removeListener(e,i),n||(n=!0,t.apply(this,arguments))}if(!isFunction(t))throw TypeError("listener must be a function");var n=!1;return i.listener=t,this.on(e,i),this},EventEmitter.prototype.removeListener=function(e,t){var i,n,s,r;if(!isFunction(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(i=this._events[e],s=i.length,n=-1,i===t||isFunction(i.listener)&&i.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(isObject(i)){for(r=s;r-- >0;)if(i[r]===t||i[r].listener&&i[r].listener===t){n=r;break}if(0>n)return this;1===i.length?(i.length=0,delete this._events[e]):i.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},EventEmitter.prototype.removeAllListeners=function(e){var t,i;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(i=this._events[e],isFunction(i))this.removeListener(e,i);else if(i)for(;i.length;)this.removeListener(e,i[i.length-1]);return delete this._events[e],this},EventEmitter.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?isFunction(this._events[e])?[this._events[e]]:this._events[e].slice():[]},EventEmitter.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(isFunction(t))return 1;if(t)return t.length}return 0},EventEmitter.listenerCount=function(e,t){return e.listenerCount(t)};
}).call(this,require('_process'))
},{"./EmitterSubscription":5,"./EventSubscriptionVendor":7,"_process":2,"fbjs/lib/emptyFunction":8,"fbjs/lib/invariant":9}],5:[function(require,module,exports){
"use strict";function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var EventSubscription=require("./EventSubscription"),EmitterSubscription=function(t){function e(n,r,o){_classCallCheck(this,e),t.call(this,n),this.listener=r,this.context=o}return _inherits(e,t),e}(EventSubscription);module.exports=EmitterSubscription;
},{"./EventSubscription":6}],6:[function(require,module,exports){
"use strict";function _classCallCheck(s,t){if(!(s instanceof t))throw new TypeError("Cannot call a class as a function")}var EventSubscription=function(){function s(t){_classCallCheck(this,s),this.subscriber=t}return s.prototype.remove=function(){this.subscriber&&(this.subscriber.removeSubscription(this),this.subscriber=null)},s}();module.exports=EventSubscription;
},{}],7:[function(require,module,exports){
(function (process){
"use strict";function _classCallCheck(i,s){if(!(i instanceof s))throw new TypeError("Cannot call a class as a function")}var invariant=require("fbjs/lib/invariant"),EventSubscriptionVendor=function(){function i(){_classCallCheck(this,i),this._subscriptionsForType={},this._currentSubscription=null}return i.prototype.addSubscription=function(i,s){s.subscriber!==this?"production"!==process.env.NODE_ENV?invariant(!1,"The subscriber of the subscription is incorrectly set."):invariant(!1):void 0,this._subscriptionsForType[i]||(this._subscriptionsForType[i]=[]);var t=this._subscriptionsForType[i].length;return this._subscriptionsForType[i].push(s),s.eventType=i,s.key=t,s},i.prototype.removeAllSubscriptions=function(i){void 0===i?this._subscriptionsForType={}:delete this._subscriptionsForType[i]},i.prototype.removeSubscription=function(i){var s=i.eventType,t=i.key,r=this._subscriptionsForType[s];r&&delete r[t]},i.prototype.getSubscriptionsForType=function(i){return this._subscriptionsForType[i]},i}();module.exports=EventSubscriptionVendor;
}).call(this,require('_process'))
},{"_process":2,"fbjs/lib/invariant":9}],8:[function(require,module,exports){
"use strict";function makeEmptyFunction(t){return function(){return t}}function emptyFunction(){}emptyFunction.thatReturns=makeEmptyFunction,emptyFunction.thatReturnsFalse=makeEmptyFunction(!1),emptyFunction.thatReturnsTrue=makeEmptyFunction(!0),emptyFunction.thatReturnsNull=makeEmptyFunction(null),emptyFunction.thatReturnsThis=function(){return this},emptyFunction.thatReturnsArgument=function(t){return t},module.exports=emptyFunction;
},{}],9:[function(require,module,exports){
(function (process){
"use strict";function invariant(r,e,n,i,o,a,t,s){if("production"!==process.env.NODE_ENV&&void 0===e)throw new Error("invariant requires an error message argument");if(!r){var u;if(void 0===e)u=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var d=[n,i,o,a,t,s],f=0;u=new Error(e.replace(/%s/g,function(){return d[f++]})),u.name="Invariant Violation"}throw u.framesToPop=1,u}}module.exports=invariant;
}).call(this,require('_process'))
},{"_process":2}],10:[function(require,module,exports){
module.exports.Dispatcher=require("./lib/Dispatcher");
},{"./lib/Dispatcher":11}],11:[function(require,module,exports){
(function (process){
"use strict";function _classCallCheck(i,t){if(!(i instanceof t))throw new TypeError("Cannot call a class as a function")}exports.__esModule=!0;var invariant=require("fbjs/lib/invariant"),_prefix="ID_",Dispatcher=function(){function i(){_classCallCheck(this,i),this._callbacks={},this._isDispatching=!1,this._isHandled={},this._isPending={},this._lastID=1}return i.prototype.register=function(i){var t=_prefix+this._lastID++;return this._callbacks[t]=i,t},i.prototype.unregister=function(i){this._callbacks[i]?void 0:"production"!==process.env.NODE_ENV?invariant(!1,"Dispatcher.unregister(...): `%s` does not map to a registered callback.",i):invariant(!1),delete this._callbacks[i]},i.prototype.waitFor=function(i){this._isDispatching?void 0:"production"!==process.env.NODE_ENV?invariant(!1,"Dispatcher.waitFor(...): Must be invoked while dispatching."):invariant(!1);for(var t=0;t<i.length;t++){var s=i[t];this._isPending[s]?this._isHandled[s]?void 0:"production"!==process.env.NODE_ENV?invariant(!1,"Dispatcher.waitFor(...): Circular dependency detected while waiting for `%s`.",s):invariant(!1):(this._callbacks[s]?void 0:"production"!==process.env.NODE_ENV?invariant(!1,"Dispatcher.waitFor(...): `%s` does not map to a registered callback.",s):invariant(!1),this._invokeCallback(s))}},i.prototype.dispatch=function(i){this._isDispatching?"production"!==process.env.NODE_ENV?invariant(!1,"Dispatch.dispatch(...): Cannot dispatch in the middle of a dispatch."):invariant(!1):void 0,this._startDispatching(i);try{for(var t in this._callbacks)this._isPending[t]||this._invokeCallback(t)}finally{this._stopDispatching()}},i.prototype.isDispatching=function(){return this._isDispatching},i.prototype._invokeCallback=function(i){this._isPending[i]=!0,this._callbacks[i](this._pendingPayload),this._isHandled[i]=!0},i.prototype._startDispatching=function(i){for(var t in this._callbacks)this._isPending[t]=!1,this._isHandled[t]=!1;this._pendingPayload=i,this._isDispatching=!0},i.prototype._stopDispatching=function(){delete this._pendingPayload,this._isDispatching=!1},i}();module.exports=Dispatcher;
}).call(this,require('_process'))
},{"_process":2,"fbjs/lib/invariant":12}],12:[function(require,module,exports){
(function (process){
"use strict";var invariant=function(r,e,n,i,o,a,t,s){if("production"!==process.env.NODE_ENV&&void 0===e)throw new Error("invariant requires an error message argument");if(!r){var u;if(void 0===e)u=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var v=[n,i,o,a,t,s],d=0;u=new Error("Invariant Violation: "+e.replace(/%s/g,function(){return v[d++]}))}throw u.framesToPop=1,u}};module.exports=invariant;
}).call(this,require('_process'))
},{"_process":2}]},{},[1]);
},{}]},{},[2]);

@@ -5,4 +5,3 @@ import {createStore} from '../index';

increment: (state) => state + 1,
decrement: (state) => state - 1,
set: (state, action) => action.data
decrement: (state) => state - 1
})

@@ -7,12 +7,12 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; /* fluxury - Copyright 2015 Peter Moresi */
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
exports.dispatch = dispatch;
exports.createStore = createStore;
/* fluxury - Copyright 2015 Peter Moresi */
var EventEmitter = require('events').EventEmitter;
var Dispatcher = require('./Dispatcher');
var _fbemitter = require('fbemitter');
var count = 0;
var _flux = require('flux');
/*

@@ -71,4 +71,3 @@ Object.assign polyfill copied from MDN

var dispatcher = new _flux.Dispatcher(),
changedEvent = 'change',
var dispatcher = new Dispatcher(),
waitFor = dispatcher.waitFor.bind(dispatcher);

@@ -89,7 +88,13 @@

var currentState = Object.freeze(initialState);
var emitter = new _fbemitter.EventEmitter();
var currentState = typeof initialState !== 'function' ? Object.freeze(initialState) : Object.freeze({});
var emitter = new EventEmitter();
var actions = {};
var reduce = undefined;
if (typeof initialState === 'function') {
methods = reducer;
reducer = initialState;
}
if ((typeof reducer === 'undefined' ? 'undefined' : _typeof(reducer)) === 'object') {

@@ -124,2 +129,4 @@

newFunc[b] = function () {
var _methods;
for (var _len = arguments.length, params = Array(_len), _key = 0; _key < _len; _key++) {

@@ -129,3 +136,3 @@ params[_key] = arguments[_key];

return methods[b].apply(methods, [currentState].concat(params));
return (_methods = methods)[b].apply(_methods, [currentState].concat(params));
};

@@ -141,3 +148,3 @@ return Object.assign(a, newFunc);

currentState = Object.freeze(newState);
emitter.emit(changedEvent);
emitter.emit('changed');
}

@@ -149,3 +156,13 @@ }),

}
return emitter.addListener(changedEvent, cb);
emitter.addListener('changed', cb);
count += 1;
return {
id: count,
remove: function remove() {
emitter.removeListener('changed', cb);
}
};
},

@@ -152,0 +169,0 @@ getState: function getState(cb) {

{
"name": "fluxury",
"version": "0.8.0",
"version": "1.0.0",
"description": "Add luxury sugar to simplify implementing Facebook's flavor of Flux architecture.",

@@ -8,11 +8,9 @@ "main": "./lib/index.js",

"scripts": {
"build": "babel index.js -o lib/index.js && browserify -g uglifyify ./lib/index.js > dist/fluxury.js",
"test": "node test"
"build": "babel src/invariant.js -o lib/invariant.js && babel src/Dispatcher.js -o lib/Dispatcher.js && babel src/index.js -o lib/index.js",
"bundle": "browserify -g uglifyify ./lib/index.js > dist/fluxury.js",
"test": "node test",
"all": "npm run build && npm test && npm run bundle"
},
"author": "Peter Moresi",
"license": "MIT",
"dependencies": {
"fbemitter": "^2.0.0",
"flux": "^2.1.1"
},
"devDependencies": {

@@ -19,0 +17,0 @@ "babel-cli": "^6.1.2",

# fluxury
[![Circle CI](https://circleci.com/gh/FunctionFoundry/fluxury/tree/master.svg?style=svg)](https://circleci.com/gh/fluxury/fluxury/tree/master)
[![Circle CI](https://circleci.com/gh/FunctionFoundry/fluxury/tree/master.svg?style=svg)](https://circleci.com/gh/FunctionFoundry/fluxury/tree/master)

@@ -17,12 +17,12 @@ Quick start:

This library adds 2 functions to Facebook's flux implementation to guide you into the `(state, action) -> state` pattern.
This library adds 2 functions to Facebook's flux implementation to guide you into the `(state, action) -> state` pattern. This library forks Flux 2.0.2.
In flux@2.1, Facebook added 3 new abstract ES 2015 classes (FluxMapStore -> FluxReduceStore -> FluxStore). These stores guide you into the reducer pattern but, unfortunately, they also lead you into classes. This library reimplements the FluxReduceStore in Douglas Crockford's class-free object oriented programming style. The FluxMapStore can be implemented using defensive copies or with immutable data structures. Examples for both techniques are included below.
This library is similar to Reflux and Redux except that this library doesn't try to eliminate the dispatcher concept.
This library is similar to Reflux and Redux except that this library doesn't try to replace the dispatcher with a new implementation. The library encourages you into simple patterns but doesn't try to change the core concepts. The flux/Dispatcher and fbemitter/EventEmitter modules are the key to Flux and this project depends directly on Facebook's implementations.
This Flux flavor adds a surface area of 2 new functions:
This new "Flux framework" adds a surface area of 2 new functions:
- dispatch(action) or dispatch(type, data)
- createStore(name, actionHandler, selectors) or createStore(name, defaultValue, actionHandler, selectors)
- dispatch
- createStore
You may see that this is compatible with Redux. Please see [Fluxury-Redux](https://github.com/FunctionFoundry/fluxury-redux) for integration.

@@ -60,3 +60,3 @@ Enjoy!

// a simple counting store
export default createStore('CountStore', 0, (state, action) => {
export default createStore('CountStore', (state=0, action) => {
switch (action.type)

@@ -76,10 +76,10 @@ case INC:

export default createStore('CountStore', 0, {
INC: (state) => state + 1
})
// To trigger an increment action use:
// dispatch('INC') or dispatch({ type: 'INC' })
// Additionally you can use this form then sugar methods are added:
// CountStore.INC()
export default createStore(
'Count Store',
0,
{
increment: (state) => state + 1,
decrement: (state) => state + 1
}
)
```

@@ -105,4 +105,4 @@

var countStore = createStore('CountStore', 0, {
INC: (state) => state + 1,
DEC: (state) => state - 1
increment: (state) => state + 1,
decrement: (state) => state - 1
});

@@ -126,3 +126,3 @@

/* Call dispatch to submit the action to the stores */
countStore.INC())
countStore.increment())
},

@@ -132,3 +132,3 @@

/* Call dispatch to submit the action to the stores */
countStore.DEC()
countStore.decrement()
},

@@ -187,3 +187,2 @@

```js
const {SET, DELETE} = ['SET', 'DELETE'];
var {dispatch, createStore } = require('fluxury');

@@ -193,3 +192,3 @@ var {Map} = require('Immutable');

var store = createStore('MapStore', Map(), {
SET: (state, data) => state.merge(data)
set: (state, data) => state.merge(data)
}, {

@@ -196,0 +195,0 @@ get: (state, param) => state.get(param),

@@ -15,3 +15,5 @@ var test = require('tape');

var store = fluxury.createStore('MapStore', {}, function(state, action) {
var store = fluxury.createStore('MapStore', function(state, action) {
state = typeof state === 'undefined' ? {} : state
switch (action.type) {

@@ -132,3 +134,3 @@ case SET:

t.plan(10)
t.plan(12)

@@ -157,6 +159,9 @@ var MessageStore = createStore('MessageStore', [], function(state, action) {

MessageStore.addListener(function() {
var token = MessageStore.addListener(function() {
dispatchCount += 1
})
t.equals( typeof token, 'object')
t.equals( typeof token.remove, 'function')
dispatch('loadMessage', 'Test')

@@ -172,2 +177,4 @@ t.equals(MessageStore.getState().length, 1)

token.remove()
dispatch('loadMessage', 'Test3')

@@ -178,4 +185,4 @@ t.equals(MessageStore.getState().length, 3)

t.equal(dispatchCount, 3)
t.equal(dispatchCount, 2)
})
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