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

@qiwi/cyclone

Package Overview
Dependencies
Maintainers
5
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@qiwi/cyclone - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

7

CHANGELOG.md

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

# [1.1.0](https://github.com/qiwi/cyclone/compare/v1.0.0...v1.1.0) (2018-10-04)
### Features
* add `historySize` limit ([b4565e7](https://github.com/qiwi/cyclone/commit/b4565e7))
# 1.0.0 (2018-10-04)

@@ -2,0 +9,0 @@

2

dist/index.js

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

'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _machine=require('./machine');Object.keys(_machine).forEach(function(a){'default'===a||'__esModule'===a||Object.defineProperty(exports,a,{enumerable:!0,get:function b(){return _machine[a]}})});var _error=require('./error');Object.keys(_error).forEach(function(a){'default'===a||'__esModule'===a||Object.defineProperty(exports,a,{enumerable:!0,get:function b(){return _error[a]}})});
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _machine=require('./machine');Object.keys(_machine).forEach(function(a){'default'===a||'__esModule'===a||Object.defineProperty(exports,a,{enumerable:!0,get:function b(){return _machine[a]}})});var _error=require('./error');Object.keys(_error).forEach(function(a){'default'===a||'__esModule'===a||Object.defineProperty(exports,a,{enumerable:!0,get:function b(){return _error[a]}})});var _machine2=_interopRequireDefault(_machine);function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}exports.default=_machine2.default;

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

'use strict';Object.defineProperty(exports,'__esModule',{value:!0}),exports.DEFAULT_OPTS=exports.DEFAULT_HANDLER=exports.DELIMITER=void 0;var _extends=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_createClass=function(){function a(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,'value'in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),_error=require('./error');function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')}var DELIMITER=exports.DELIMITER='>',DEFAULT_HANDLER=exports.DEFAULT_HANDLER=function(a){return a},DEFAULT_OPTS=exports.DEFAULT_OPTS={transitions:{}},Machine=function(){function a(b){return _classCallCheck(this,a),this.opts=_extends({},DEFAULT_OPTS,b),this.history=[],this.key=null,this.transitions=b.transitions,'string'==typeof b.initialState&&this.history.push({state:b.initialState,data:b.initialData}),this}return _createClass(a,[{key:'next',value:function h(a){if(this.key)throw new _error.MachineError(_error.LOCK_VIOLATION);for(var b=this.constructor.getHandler(a,this.history,this.transitions),c=this.current(),d=arguments.length,e=Array(1<d?d-1:0),f=1;f<d;f++)e[f-1]=arguments[f];var g=b.apply(void 0,[c.data].concat(e));return this.history.push({state:a,data:g}),this}},{key:'current',value:function a(){return _extends({},this.history[this.history.length-1])}},{key:'prev',value:function a(){if(this.key)throw new _error.MachineError(_error.LOCK_VIOLATION);if(2>this.history.length)throw new _error.MachineError(_error.TRANSITION_VIOLATION);return this.history.pop(),this}},{key:'lock',value:function b(a){return this.key=a?a:'lock'+Math.random(),this}},{key:'unlock',value:function b(a){if(this.key!==a)throw new _error.MachineError(_error.INVALID_UNLOCK_KEY);return this.key=null,this}}],[{key:'getHandler',value:function g(a,b,c){var d=this.getTargetTransition(a,b),e=this.getTransition(d,c);if(!e)throw new _error.MachineError(_error.TRANSITION_VIOLATION);var f=c[e];return'function'==typeof f?f:DEFAULT_HANDLER}},{key:'getTransition',value:function c(a,b){return Object.keys(b).filter(function(b){return a.length>b.length?new RegExp('.*'+b+'$').test(a):a===b}).sort(function(c,a){return a.length-c.length})[0]}},{key:'getTargetTransition',value:function c(a,b){return b.map(function(a){var b=a.state;return b}).concat(a).join(DELIMITER)}}]),a}();exports.default=Machine;
'use strict';Object.defineProperty(exports,'__esModule',{value:!0}),exports.DEFAULT_OPTS=exports.DEFAULT_HANDLER=exports.DELIMITER=void 0;var _extends=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_createClass=function(){function a(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,'value'in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),_error=require('./error'),_log=require('./log'),_log2=_interopRequireDefault(_log);function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')}var DELIMITER=exports.DELIMITER='>',DEFAULT_HANDLER=exports.DEFAULT_HANDLER=function(a){return a},DEFAULT_OPTS=exports.DEFAULT_OPTS={transitions:{},historySize:10},Machine=function(){function a(b){return _classCallCheck(this,a),this.opts=_extends({},DEFAULT_OPTS,b),this.history=[],this.key=null,this.transitions=b.transitions,'string'==typeof b.initialState&&this.history.push({state:b.initialState,data:b.initialData}),this}return _createClass(a,[{key:'next',value:function h(a){if(this.key)throw new _error.MachineError(_error.LOCK_VIOLATION);for(var b=this.constructor.getHandler(a,this.history,this.transitions),c=this.current(),d=arguments.length,e=Array(1<d?d-1:0),f=1;f<d;f++)e[f-1]=arguments[f];var g=b.apply(void 0,[c.data].concat(e));return this.history.push({state:a,data:g}),this.history.length>+this.opts.historySize&&(_log2.default.debug('history limit reached'),this.history.shift()),this}},{key:'current',value:function a(){return _extends({},this.history[this.history.length-1])}},{key:'prev',value:function a(){if(this.key)throw new _error.MachineError(_error.LOCK_VIOLATION);if(2>this.history.length)throw new _error.MachineError(_error.TRANSITION_VIOLATION);return this.history.pop(),this}},{key:'lock',value:function b(a){return this.key=a?a:'lock'+Math.random(),this}},{key:'unlock',value:function b(a){if(this.key!==a)throw new _error.MachineError(_error.INVALID_UNLOCK_KEY);return this.key=null,this}}],[{key:'getHandler',value:function g(a,b,c){var d=this.getTargetTransition(a,b),e=this.getTransition(d,c);if(!e)throw new _error.MachineError(_error.TRANSITION_VIOLATION);var f=c[e];return'function'==typeof f?f:DEFAULT_HANDLER}},{key:'getTransition',value:function c(a,b){return Object.keys(b).filter(function(b){return a.length>b.length?new RegExp('.*'+b+'$').test(a):a===b}).sort(function(c,a){return a.length-c.length})[0]}},{key:'getTargetTransition',value:function c(a,b){return b.map(function(a){var b=a.state;return b}).concat(a).join(DELIMITER)}}]),a}();exports.default=Machine;
{
"name": "@qiwi/cyclone",
"version": "1.0.0",
"version": "1.1.0",
"description": "\"State machine\" for basic data flows",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -32,3 +32,4 @@ # @qiwi/cyclone

'foo>bar>baz>foo': handler1
}
},
historySize: 5, // default = 10
}

@@ -35,0 +36,0 @@ const machine = new Machine(opts)

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