ancient-cursor
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -0,1 +1,7 @@ | ||
#### 0.0.6 (2017-9-9) | ||
##### New Features | ||
* **cursor** Cursor now can be used fully alone without manager. | ||
#### 0.0.5 (2017-9-8) | ||
@@ -17,3 +23,3 @@ | ||
##### New Featurs | ||
##### New Features | ||
@@ -20,0 +26,0 @@ * **clientId** Removed excess concept of clientId. Only the channel if left, which provides connection with some client, but without information about client. Application can describe it manually. |
@@ -1,2 +0,2 @@ | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if('value'in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();var _lodash=require('lodash');var _lodash2=_interopRequireDefault(_lodash);var _events=require('events');var _events2=_interopRequireDefault(_events);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 Cursor=function(){function Cursor(query,data,manager,id){_classCallCheck(this,Cursor);this.query=query;this.data=data;this.manager=manager;this.id=id;this.emitter=new _events2.default}_createClass(Cursor,[{key:'set',value:function set(path,current){var _path=_lodash2.default.toPath(path);var oldByPath=_lodash2.default.get(this.data,_path);if(!_path.length)this.data=current;else this.data=_lodash2.default.set(this.data||{},_path,current);this.emitter.emit('changed',{old:oldByPath,path:_path,action:'set','arguments':_lodash2.default.toArray(arguments)})}},{key:'splice',value:function splice(path,start,deleteCount){for(var _len=arguments.length,items=Array(_len>3?_len-3:0),_key=3;_key<_len;_key++){items[_key-3]=arguments[_key]}var _path=_lodash2.default.toPath(path);var oldByPath=_lodash2.default.clone(_lodash2.default.get(this.data,_path));var data=this.get(_path);if(!_lodash2.default.isArray(data))throw new Error('Data by path is not an array.');data.splice.apply(data,[start,deleteCount].concat(items));this.emitter.emit('changed',{old:oldByPath,path:_path,action:'splice','arguments':_lodash2.default.toArray(arguments)})}},{key:'get',value:function get(){var path=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var handler=arguments[1];this.on(path,handler);return _lodash2.default.isNull(path)?this.data:_lodash2.default.get(this.data,path)}},{key:'on',value:function on(){var _this=this;var path=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var handler=arguments[1];var eventPath=_lodash2.default.toPath(path);if(typeof handler=='function'){var listener=function listener(changes){var isClone,oldValue,currentValue;var eventPathLocal=eventPath.slice(changes.path.length);if(changes.path.length<=eventPath.length){if(_lodash2.default.isEqual(changes.path,eventPath.slice(0,changes.path.length))){isClone=true;oldValue=eventPathLocal.length?_lodash2.default.get(changes.old,eventPathLocal):changes.old;currentValue=eventPath.length?_lodash2.default.get(_this.data,eventPath):_this.data}else return}else{if(_lodash2.default.isEqual(eventPath,changes.path.slice(0,eventPath.length))){isClone=false;oldValue=currentValue=eventPath.length?_lodash2.default.get(_this.data,eventPath):_this.data}else return}handler(oldValue,currentValue,stop,changes,isClone,_this)};var stop=function stop(){return _this.emitter.removeListener('changed',listener)};this.emitter.on('changed',listener);return stop}}},{key:'destroy',value:function destroy(){if(this.manager){this.manager.cursorDestroyed(this)}}}]);return Cursor}();exports.default=Cursor; | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if('value'in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();var _lodash=require('lodash');var _lodash2=_interopRequireDefault(_lodash);var _events=require('events');var _events2=_interopRequireDefault(_events);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 Cursor=function(){function Cursor(query,data,adapterDestroyed,id){_classCallCheck(this,Cursor);this.query=query;this.data=data;this.adapterDestroyed=adapterDestroyed;this.id=id;this.emitter=new _events2.default}_createClass(Cursor,[{key:'set',value:function set(path,current){var _path=_lodash2.default.toPath(path);var oldByPath=_lodash2.default.get(this.data,_path);if(!_path.length)this.data=current;else this.data=_lodash2.default.set(this.data||{},_path,current);this.emitter.emit('changed',{old:oldByPath,path:_path,action:'set','arguments':_lodash2.default.toArray(arguments)})}},{key:'splice',value:function splice(path,start,deleteCount){for(var _len=arguments.length,items=Array(_len>3?_len-3:0),_key=3;_key<_len;_key++){items[_key-3]=arguments[_key]}var _path=_lodash2.default.toPath(path);var oldByPath=_lodash2.default.clone(_lodash2.default.get(this.data,_path));var data=this.get(_path);if(!_lodash2.default.isArray(data))throw new Error('Data by path is not an array.');data.splice.apply(data,[start,deleteCount].concat(items));this.emitter.emit('changed',{old:oldByPath,path:_path,action:'splice','arguments':_lodash2.default.toArray(arguments)})}},{key:'get',value:function get(){var path=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var handler=arguments[1];this.on(path,handler);return _lodash2.default.isNull(path)?this.data:_lodash2.default.get(this.data,path)}},{key:'on',value:function on(){var _this=this;var path=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var handler=arguments[1];var eventPath=_lodash2.default.toPath(path);if(typeof handler=='function'){var listener=function listener(changes){var isClone,oldValue,currentValue;var eventPathLocal=eventPath.slice(changes.path.length);if(changes.path.length<=eventPath.length){if(_lodash2.default.isEqual(changes.path,eventPath.slice(0,changes.path.length))){isClone=true;oldValue=eventPathLocal.length?_lodash2.default.get(changes.old,eventPathLocal):changes.old;currentValue=eventPath.length?_lodash2.default.get(_this.data,eventPath):_this.data}else return}else{if(_lodash2.default.isEqual(eventPath,changes.path.slice(0,eventPath.length))){isClone=false;oldValue=currentValue=eventPath.length?_lodash2.default.get(_this.data,eventPath):_this.data}else return}handler(oldValue,currentValue,stop,changes,isClone,_this)};var stop=function stop(){return _this.emitter.removeListener('changed',listener)};this.emitter.on('changed',listener);return stop}}},{key:'destroy',value:function destroy(){if(typeof this.adapterDestroyed=='function'){this.adapterDestroyed(this)}}}]);return Cursor}();exports.default=Cursor; | ||
//# sourceMappingURL=Cursor.js.map |
@@ -1,2 +0,2 @@ | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if('value'in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError('Cannot call a class as a function')}}var CursorsManager=function(){function CursorsManager(){var Cursor=arguments.length>0&&arguments[0]!==undefined?arguments[0]:Cursor;var adapterCursorDestroyed=arguments[1];var adapterCustorConstructed=arguments[2];_classCallCheck(this,CursorsManager);this.Cursor=Cursor;this.cursors={};this.nextId=0;this.adapterCursorDestroyed=adapterCursorDestroyed;this.adapterCustorConstructed=adapterCustorConstructed}_createClass(CursorsManager,[{key:'new',value:function _new(query,data){var cursor=new this.Cursor(query,data,this,this.nextId);this.cursors[this.nextId]=cursor;this.nextId++;if(typeof this.adapterCustorConstructed=='function'){this.adapterCustorConstructed(cursor)}return cursor}},{key:'renew',value:function renew(cursor,query,data){if(!cursor.hasOwnProperty('id')){cursor.id=this.nextId++;this.cursors[cursor.id]=cursor;if(query)cursor.query=query;if(arguments.length==3)cursor.set('',data);if(typeof this.adapterCustorConstructed=='function'){this.adapterCustorConstructed(cursor)}return cursor}else{throw new Error('Cursor must be destroyed.')}}},{key:'cursorDestroyed',value:function cursorDestroyed(cursor){delete this.cursors[cursor.id];delete cursor.id;if(typeof this.adapterCursorDestroyed=='function'){this.adapterCursorDestroyed(cursor)}}}]);return CursorsManager}();exports.default=CursorsManager; | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if('value'in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError('Cannot call a class as a function')}}var CursorsManager=function(){function CursorsManager(){var Cursor=arguments.length>0&&arguments[0]!==undefined?arguments[0]:Cursor;var adapterCursorDestroyed=arguments[1];var adapterCustorConstructed=arguments[2];_classCallCheck(this,CursorsManager);this.Cursor=Cursor;this.cursors={};this.nextId=0;this.adapterCursorDestroyed=adapterCursorDestroyed;this.adapterCustorConstructed=adapterCustorConstructed}_createClass(CursorsManager,[{key:'new',value:function _new(query,data){var _this=this;var cursor=new this.Cursor(query,data,function(){return _this.cursorDestroyed(cursor)},this.nextId);this.cursors[this.nextId]=cursor;this.nextId++;if(typeof this.adapterCustorConstructed=='function'){this.adapterCustorConstructed(cursor)}return cursor}},{key:'renew',value:function renew(cursor,query,data){if(!cursor.hasOwnProperty('id')){cursor.id=this.nextId++;this.cursors[cursor.id]=cursor;if(query)cursor.query=query;if(arguments.length==3)cursor.set('',data);if(typeof this.adapterCustorConstructed=='function'){this.adapterCustorConstructed(cursor)}return cursor}else{throw new Error('Cursor must be destroyed.')}}},{key:'cursorDestroyed',value:function cursorDestroyed(cursor){delete this.cursors[cursor.id];delete cursor.id;if(typeof this.adapterCursorDestroyed=='function'){this.adapterCursorDestroyed(cursor)}}}]);return CursorsManager}();exports.default=CursorsManager; | ||
//# sourceMappingURL=CursorsManager.js.map |
{ | ||
"name": "ancient-cursor", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Utilities for tracking changes of complex or plain remote data.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
1674074
974
14