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

arkhamjs

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arkhamjs - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

2

lib/Flux.js

@@ -1,1 +0,1 @@

'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,'value'in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();var _events=require('events'),_events2=_interopRequireDefault(_events),_immutable=require('immutable'),_immutable2=_interopRequireDefault(_immutable);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError('Cannot call a class as a function')}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return call&&('object'==typeof call||'function'==typeof call)?call:self}function _inherits(subClass,superClass){if('function'!=typeof superClass&&null!==superClass)throw new TypeError('Super expression must either be null or a function, not '+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}var Flux=function(_EventEmitter){function Flux(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};_classCallCheck(this,Flux);var _this=_possibleConstructorReturn(this,(Flux.__proto__||Object.getPrototypeOf(Flux)).call(this));return _this._window=window||{},a=_immutable2.default.fromJS(a),_this._debug=!!a.get('debug',!1),_this._name='arkhamjs',_this._store=_this.getSessionData(_this._name)||(0,_immutable.Map)(),_this._storeClasses=(0,_immutable.Map)(),_this._useCache=!!a.get('cache',!0),_this._window=window||{},_this}return _inherits(Flux,_EventEmitter),_createClass(Flux,[{key:'off',value:function off(a,b){this.removeListener(a,b)}},{key:'dispatch',value:function dispatch(a){var _this2=this,b=1<arguments.length&&void 0!==arguments[1]&&arguments[1];a=_immutable2.default.fromJS(a);var c=a.get('type'),d=a.filter(function(f,g){return'type'!==g});if(c){var _e=this._store;if(this._storeClasses.forEach(function(f){var g=f.name,h=_this2._store.get(g)||_immutable2.default.fromJS(f.initialState())||(0,_immutable.Map)();_this2._store=_this2._store.set(g,f.onAction(c,d,h)||h),f.state=_this2._store.get(g)}),this._debug){var f=!this._store.equals(_e),g=f?'Changed State':'Unchanged State',h=f?'#00d484':'#959595';console.groupCollapsed?(console.groupCollapsed('FLUX DISPATCH: '+c),console.log('%c Action: ','color: #00C4FF',a.toJS()),console.log('%c Last State: ','color: #959595',_e.toJS()),console.log('%c '+g+': ','color: '+h,this._store.toJS()),console.groupEnd()):(console.log('FLUX DISPATCH: '+c),console.log('Action: '+a.toJS()),console.log('Last State: ',_e.toJS()),console.log(g+': ',this._store.toJS()))}return this._useCache&&this.setSessionData(this._name,this._store),b||this.emit(c,d),a}}},{key:'getStore',value:function getStore(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:'',b=arguments[1];return Array.isArray(a)?this._store.getIn(a,b):''===a?this._store||(0,_immutable.Map)():this._store.get(a,b)}},{key:'setStore',value:function setStore(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:'',b=arguments[1];return Array.isArray(a)?this._store.setIn(a,b):''===a?this._store||(0,_immutable.Map)():this._store.set(a,b)}},{key:'registerStore',value:function registerStore(a){var _this3=this;return Array.isArray(a)?a.map(function(b){return _this3._register(b)}):this._register(a)}},{key:'_register',value:function _register(a){if(!a)throw Error('Class is undefined. Cannot register with Flux.');var b=a.constructor.toString().substr(0,5);if('class'!==b&&'funct'!==b)throw Error(a+' is not a class. Cannot register with Flux.');var c=new a,d=c.name;if(!this._storeClasses.get(d)){this._storeClasses=this._storeClasses.set(d,c);var e=this.getSessionData(this._name),f=this._useCache&&_immutable.Map.isMap(e)?e:(0,_immutable.Map)(),g=this._store.get(d)||f.get(d)||_immutable2.default.fromJS(c.initialState())||(0,_immutable.Map)();this._store=this._store.set(d,g),this._useCache&&this.setSessionData(this._name,this._store)}return this._storeClasses.get(d)}},{key:'deregisterStore',value:function deregisterStore(a){var _this4=this;Array.isArray(a)?a.forEach(function(b){_this4._deregister(b)}):this._deregister(a)}},{key:'_deregister',value:function _deregister(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:'';this._storeClasses=this._storeClasses.delete(a),this._store=this._store.delete(a)}},{key:'getClass',value:function getClass(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:'';return this._storeClasses.get(a)}},{key:'setSessionData',value:function setSessionData(a,b){if(this._window&&this._window.sessionStorage)try{return _immutable2.default.Iterable.isIterable(b)&&(b=b.toJS()),b=JSON.stringify(b),this._window.sessionStorage.setItem(a,b),!0}catch(c){return!1}else return!1}},{key:'getSessionData',value:function getSessionData(a){if(this._window&&this._window.sessionStorage)try{var b=this._window.sessionStorage.getItem(a);return b?_immutable2.default.fromJS(JSON.parse(b)):null}catch(b){return null}else return null}},{key:'delSessionData',value:function delSessionData(a){if(this._window&&this._window.sessionStorage)try{return this._window.sessionStorage.removeItem(a),!0}catch(b){return!1}else return!1}},{key:'clearAppData',value:function clearAppData(){this.delSessionData(this._name)}},{key:'setLocalData',value:function setLocalData(a,b){if(this._window&&this._window.localStorage)try{return _immutable2.default.Iterable.isIterable(b)&&(b=b.toJS()),b=JSON.stringify(b),this._window.localStorage.setItem(a,b),!0}catch(c){return!1}else return!1}},{key:'getLocalData',value:function getLocalData(a){if(this._window&&this._window.localStorage)try{var b=this._window.localStorage.getItem(a);return b?_immutable2.default.fromJS(JSON.parse(b)):null}catch(b){return null}else return null}},{key:'delLocalData',value:function delLocalData(a){if(this._window&&this._window.localStorage)try{return this._window.localStorage.removeItem(a),!0}catch(b){return!1}else return!1}},{key:'enableDebugger',value:function enableDebugger(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:!0;this._debug=a}}]),Flux}(_events2.default);var flux=new Flux((window||{}).arkhamjs);exports.default=flux;
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,'value'in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();var _events=require('events'),_events2=_interopRequireDefault(_events),_immutable=require('immutable'),_immutable2=_interopRequireDefault(_immutable);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError('Cannot call a class as a function')}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return call&&('object'==typeof call||'function'==typeof call)?call:self}function _inherits(subClass,superClass){if('function'!=typeof superClass&&null!==superClass)throw new TypeError('Super expression must either be null or a function, not '+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}var Flux=function(_EventEmitter){function Flux(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};_classCallCheck(this,Flux);var _this=_possibleConstructorReturn(this,(Flux.__proto__||Object.getPrototypeOf(Flux)).call(this));return _this._window=window||{},a=_immutable2.default.fromJS(a),_this._debug=!!a.get('debug',!1),_this._name='arkhamjs',_this._store=_this.getSessionData(_this._name)||(0,_immutable.Map)(),_this._storeClasses=(0,_immutable.Map)(),_this._useCache=!!a.get('cache',!0),_this._window=window||{},_this}return _inherits(Flux,_EventEmitter),_createClass(Flux,[{key:'off',value:function off(a,b){this.removeListener(a,b)}},{key:'dispatch',value:function dispatch(a){var _this2=this,b=1<arguments.length&&void 0!==arguments[1]&&arguments[1];a=_immutable2.default.fromJS(a);var c=a.get('type'),d=a.filter(function(f,g){return'type'!==g});if(c){var _e=this._store;if(this._storeClasses.forEach(function(f){var g=f.name,h=_this2._store.get(g)||f.getInitialState()||(0,_immutable.Map)();_this2._store=_this2._store.set(g,f.onAction(c,d,h)||h),f.state=_this2._store.get(g)}),this._debug){var f=!this._store.equals(_e),g=f?'Changed State':'Unchanged State',h=f?'#00d484':'#959595';console.groupCollapsed?(console.groupCollapsed('FLUX DISPATCH: '+c),console.log('%c Action: ','color: #00C4FF',a.toJS()),console.log('%c Last State: ','color: #959595',_e.toJS()),console.log('%c '+g+': ','color: '+h,this._store.toJS()),console.groupEnd()):(console.log('FLUX DISPATCH: '+c),console.log('Action: '+a.toJS()),console.log('Last State: ',_e.toJS()),console.log(g+': ',this._store.toJS()))}return this._useCache&&this.setSessionData(this._name,this._store),b||this.emit(c,d),a}}},{key:'getStore',value:function getStore(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:'',b=arguments[1];return Array.isArray(a)?this._store.getIn(a,b):''===a?this._store||(0,_immutable.Map)():this._store.get(a,b)}},{key:'setStore',value:function setStore(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:'',b=arguments[1];return Array.isArray(a)?this._store=this._store.setIn(a,b):''===a?this._store||(0,_immutable.Map)():this._store=this._store.set(a,b)}},{key:'registerStore',value:function registerStore(a){var _this3=this;return Array.isArray(a)?a.map(function(b){return _this3._register(b)}):this._register(a)}},{key:'_register',value:function _register(a){if(!a)throw Error('Class is undefined. Cannot register with Flux.');var b=a.constructor.toString().substr(0,5);if('class'!==b&&'funct'!==b)throw Error(a+' is not a class. Cannot register with Flux.');var c=new a,d=c.name;if(!this._storeClasses.get(d)){this._storeClasses=this._storeClasses.set(d,c);var e=this.getSessionData(this._name),f=this._useCache&&_immutable.Map.isMap(e)?e:(0,_immutable.Map)(),g=this._store.get(d)||f.get(d)||c.getInitialState()||(0,_immutable.Map)();this._store=this._store.set(d,g),this._useCache&&this.setSessionData(this._name,this._store)}return this._storeClasses.get(d)}},{key:'deregisterStore',value:function deregisterStore(a){var _this4=this;Array.isArray(a)?a.forEach(function(b){_this4._deregister(b)}):this._deregister(a)}},{key:'_deregister',value:function _deregister(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:'';this._storeClasses=this._storeClasses.delete(a),this._store=this._store.delete(a)}},{key:'getClass',value:function getClass(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:'';return this._storeClasses.get(a)}},{key:'setSessionData',value:function setSessionData(a,b){if(this._window&&this._window.sessionStorage)try{return _immutable2.default.Iterable.isIterable(b)&&(b=b.toJS()),b=JSON.stringify(b),this._window.sessionStorage.setItem(a,b),!0}catch(c){return!1}else return!1}},{key:'getSessionData',value:function getSessionData(a){if(this._window&&this._window.sessionStorage)try{var b=this._window.sessionStorage.getItem(a);return b?_immutable2.default.fromJS(JSON.parse(b)):null}catch(b){return null}else return null}},{key:'delSessionData',value:function delSessionData(a){if(this._window&&this._window.sessionStorage)try{return this._window.sessionStorage.removeItem(a),!0}catch(b){return!1}else return!1}},{key:'clearAppData',value:function clearAppData(){this.delSessionData(this._name)}},{key:'setLocalData',value:function setLocalData(a,b){if(this._window&&this._window.localStorage)try{return _immutable2.default.Iterable.isIterable(b)&&(b=b.toJS()),b=JSON.stringify(b),this._window.localStorage.setItem(a,b),!0}catch(c){return!1}else return!1}},{key:'getLocalData',value:function getLocalData(a){if(this._window&&this._window.localStorage)try{var b=this._window.localStorage.getItem(a);return b?_immutable2.default.fromJS(JSON.parse(b)):null}catch(b){return null}else return null}},{key:'delLocalData',value:function delLocalData(a){if(this._window&&this._window.localStorage)try{return this._window.localStorage.removeItem(a),!0}catch(b){return!1}else return!1}},{key:'enableDebugger',value:function enableDebugger(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:!0;this._debug=a}}]),Flux}(_events2.default);var flux=new Flux((window||{}).arkhamjs);exports.default=flux;

@@ -1,1 +0,1 @@

'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,'value'in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();var _immutable=require('immutable');function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError('Cannot call a class as a function')}var Store=function(){function Store(a){_classCallCheck(this,Store),this.state=(0,_immutable.Map)(),this.name=(a||'store').toLowerCase()}return _createClass(Store,[{key:'initialState',value:function initialState(){return{}}},{key:'onAction',value:function onAction(a,b,c){return c}}]),Store}();exports.default=Store;
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,'value'in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();var _immutable=require('immutable'),_immutable2=_interopRequireDefault(_immutable);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError('Cannot call a class as a function')}var Store=function(){function Store(a){_classCallCheck(this,Store),this.state=(0,_immutable.Map)(),this.name=(a||'store').toLowerCase()}return _createClass(Store,[{key:'initialState',value:function initialState(){return{}}},{key:'getInitialState',value:function getInitialState(){return _immutable2.default.fromJS(this.initialState())}},{key:'onAction',value:function onAction(a,b,c){return c}}]),Store}();exports.default=Store;
{
"name": "arkhamjs",
"version": "1.3.0",
"version": "1.3.1",
"description": "An ES6 Flux library for ReactJS",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -149,3 +149,3 @@ ![ArkhamJS](https://nitrogenlabs.com/logos/gh-arkhamjs.png "ArkhamJS")

## API
## Flux API

@@ -184,3 +184,3 @@ ### Events

#### `setStore(name, value)`
Set a store value. If only a particular store or property needs to be set, it can be specified.
Used for unit testing. Set a store value. If only a particular store or property needs to be set, it can be specified.
* [`name`] \(*String*/*Array*): A store name. May also use an array to get a nested property value.

@@ -191,3 +191,3 @@ * [`value`] \(*Any*): The value to set. This may be a string, number, boolean or immutable

##### Returns
The updated property.
The updated store as an immutable object.

@@ -279,1 +279,12 @@ #### `getClass(name)`

* [`toggle`] \(*Boolean*): Enable or disable debugger. Default: true.
## Store API
### State
#### `getInitialState()`
Used for unit testing. Gets the initial state of the store.
##### Returns
The initial state of the store as an immutable object.

Sorry, the diff of this file is not supported yet

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