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

ancient-cursor

Package Overview
Dependencies
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ancient-cursor - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

LICENSE.md

2

lib/ApiManager.js

@@ -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);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 ApiManager=function(){function ApiManager(adapterFindApi,adapterSend){_classCallCheck(this,ApiManager);this.adapterFindApi=adapterFindApi;this.adapterSend=adapterSend;this.relations={}}_createClass(ApiManager,[{key:'findApi',value:function findApi(apiQuery){return this.adapterFindApi(apiQuery)}},{key:'receiveQuery',value:function receiveQuery(channelId,apiQuery,query,cursorId){var _this=this;return this.findApi(apiQuery).then(function(api){_lodash2.default.set(_this.relations,[channelId,cursorId],apiQuery);api.receiveQuery(channelId,query,cursorId,function(channelId,bundles){_this.adapterSend(channelId,bundles)});return api})}},{key:'channelDisconnected',value:function channelDisconnected(channelId){var _this2=this;var cursors=_lodash2.default.get(this.relations,[channelId]);var promises=[];var apis={};for(var cursorId in cursors){if(!apis[cursors[cursorId]]){apis[cursors[cursorId]]=true;promises.push(function(channelId,cursorId){return new Promise(function(){return _this2.findApi(cursors[cursorId]).then(function(api){_lodash2.default.set(_this2.relations,[channelId,cursorId],cursors[cursorId]);if(typeof api.channelDisconnected=='function'){api.channelDisconnected(channelId,function(channelId,bundles){_this2.adapterSend(channelId,bundles)})}return api})})}(channelId,cursorId))}promises.push(function(channelId,cursorId){return new Promise(function(){return _this2.cursorDestroyed(channelId,cursorId)})}(channelId,cursorId))}delete this.relations[channelId];return promises}},{key:'cursorDestroyed',value:function cursorDestroyed(channelId,cursorId){var _this3=this;var apiQuery=_lodash2.default.get(this.relations,[channelId,cursorId]);return this.findApi(apiQuery).then(function(api){if(typeof api.cursorDestroyed=='function'){api.cursorDestroyed(channelId,cursorId,function(channelId,bundles){_this3.adapterSend(channelId,bundles)})}})}}]);return ApiManager}();exports.default=ApiManager;
'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);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 ApiManager=function(){function ApiManager(adapterFindApi,adapterSend){_classCallCheck(this,ApiManager);this.adapterFindApi=adapterFindApi;this.adapterSend=adapterSend;this.relations={}}_createClass(ApiManager,[{key:'findApi',value:function findApi(apiQuery){return this.adapterFindApi(apiQuery)}},{key:'receiveQuery',value:function receiveQuery(channelId,apiQuery,query,cursorId){var _this=this;return this.findApi(apiQuery).then(function(api){_lodash2.default.set(_this.relations,[channelId,cursorId],apiQuery);api.receiveQuery(channelId,query,cursorId,function(channelId){for(var _len=arguments.length,bundles=Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){bundles[_key-1]=arguments[_key]}_this.adapterSend(channelId,bundles)});return api})}},{key:'channelDisconnected',value:function channelDisconnected(channelId){var _this2=this;var cursors=_lodash2.default.get(this.relations,[channelId]);var promises=[];var apis={};for(var cursorId in cursors){if(!apis[cursors[cursorId]]){apis[cursors[cursorId]]=true;promises.push(function(channelId,cursorId){return new Promise(function(){return _this2.findApi(cursors[cursorId]).then(function(api){_lodash2.default.set(_this2.relations,[channelId,cursorId],cursors[cursorId]);if(typeof api.channelDisconnected=='function'){api.channelDisconnected(channelId,function(channelId){for(var _len2=arguments.length,bundles=Array(_len2>1?_len2-1:0),_key2=1;_key2<_len2;_key2++){bundles[_key2-1]=arguments[_key2]}_this2.adapterSend(channelId,bundles)})}return api})})}(channelId,cursorId))}promises.push(function(channelId,cursorId){return new Promise(function(){return _this2.cursorDestroyed(channelId,cursorId)})}(channelId,cursorId))}delete this.relations[channelId];return promises}},{key:'cursorDestroyed',value:function cursorDestroyed(channelId,cursorId){var _this3=this;var apiQuery=_lodash2.default.get(this.relations,[channelId,cursorId]);return this.findApi(apiQuery).then(function(api){if(typeof api.cursorDestroyed=='function'){api.cursorDestroyed(channelId,cursorId,function(channelId){for(var _len3=arguments.length,bundles=Array(_len3>1?_len3-1:0),_key3=1;_key3<_len3;_key3++){bundles[_key3-1]=arguments[_key3]}_this3.adapterSend(channelId,bundles)})}})}}]);return ApiManager}();exports.default=ApiManager;
//# sourceMappingURL=ApiManager.js.map
{
"name": "ancient-cursor",
"version": "0.0.8",
"version": "0.0.9",
"description": "Utilities for tracking changes of complex or plain remote data.",

@@ -17,3 +17,2 @@ "keywords": [

],
"author": "Ivan S Glazunov <ivansglazunov@gmail.com>",
"contributors": [

@@ -20,0 +19,0 @@ {

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

'use strict';var _chai=require('chai');var _lib=require('../lib');var _react=require('./react');var _react2=_interopRequireDefault(_react);var _lodash=require('lodash');var _lodash2=_interopRequireDefault(_lodash);var _mingo=require('mingo');var _mingo2=_interopRequireDefault(_mingo);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i]}return arr2}else{return Array.from(arr)}}require('source-map-support').install();describe('AncientSouls/Cursor',function(){describe('Cursor',function(){it('get by path',function(){var document={any:[{custom:{many:'data'}}]};var cursor=new _lib.Cursor(true,document);_chai.assert.equal(cursor.get('any.0.custom.many'),'data')});it('get handle path current set changes',function(done){var document={any:[{custom:{many:'a'}}]};var cursor=new _lib.Cursor(true,document);var changesPattern={old:{many:'a'},path:['any','0','custom'],action:'set',arguments:['any.0.custom',{many:'b'}]};cursor.on('any.0.custom.many',function(old,current,stop,changes,isClone){_chai.assert.equal(old,'a');_chai.assert.equal(current,'b');_chai.assert.deepEqual(changes,changesPattern);_chai.assert.isTrue(isClone)});cursor.on('any.0.custom',function(old,current,stop,changes,isClone){_chai.assert.deepEqual(old,{many:'a'});_chai.assert.deepEqual(current,{many:'b'});_chai.assert.deepEqual(changes,changesPattern);_chai.assert.isTrue(isClone)});cursor.on('any.0',function(old,current,stop,changes,isClone){_chai.assert.deepEqual(old,{custom:{many:'b'}});_chai.assert.deepEqual(current,{custom:{many:'b'}});_chai.assert.deepEqual(changes,changesPattern);_chai.assert.isFalse(isClone);done()});cursor.set('any.0.custom',{many:'b'})});it('set',function(){var cursor=new _lib.Cursor(true,{a:[{b:'x'},{c:'y'},{d:'z'}]});cursor.set('a.0.b','z');_chai.assert.deepEqual(cursor.get('a.0'),{b:'z'});cursor.set('',{x:'y'});_chai.assert.deepEqual(cursor.get(),{x:'y'})});it('splice',function(done){var cursor=new _lib.Cursor(true,{a:[{b:'x'},{c:'y'},{d:'z'}],e:'f'});cursor.on('a.1',function(old,current,stop,changes,isClone){_chai.assert.deepEqual(old,{c:'y'});_chai.assert.deepEqual(current,{e:'q'});_chai.assert.isTrue(isClone);setTimeout(done,100)});cursor.on('a.0',function(old,current,stop,changes,isClone){_chai.assert.deepEqual(old,current);_chai.assert.isTrue(isClone)});cursor.on('e',function(old,current,stop,changes,isClone){throw new Error('It should not be')});cursor.splice('a',1,1,{e:'q'});_chai.assert.equal(cursor.get('a.1.e'),'q')});it('destroy',function(){var cursor=new _lib.Cursor(true,{a:[{b:'x'},{c:'y'},{d:'z'}],e:'f'});cursor.destroy()});it('destroy',function(){var cursor=new _lib.Cursor(true,{a:[{b:'x'},{c:'y'},{d:'z'}],e:'f'});cursor.destroy()});it('once',function(done){var cursor=new _lib.Cursor(true,'a');cursor.on('',function(old,current){if(current=='c')done()});cursor.once('',function(old,current){_chai.assert.equal(current,'b')});cursor.set('','b');cursor.set('','c')})});describe('BundleQueuesManager',function(){it('set',function(done){var cm=new _lib.CursorsManager(_lib.Cursor);var bqm=new(Function.prototype.bind.apply(_lib.BundleQueuesManager,[null].concat(_toConsumableArray((0,_lib.generateAdapterForBundleQueuesManager)(cm).adapters))));var c=cm.new('any',{'some':'thing'});bqm.useBundle({id:5,cursor:c.id,type:'set',path:'some',value:'nothing'},function(){bqm.useBundle({id:1,cursor:c.id,type:'set',path:'some',value:'result'},function(){bqm.useBundle({id:0,cursor:c.id,type:'set',path:'some',value:'other'},function(){_chai.assert.deepEqual(c.get('some'),'result');done()})})})});it('unset',function(done){var cm=new _lib.CursorsManager(_lib.Cursor);var bqm=new(Function.prototype.bind.apply(_lib.BundleQueuesManager,[null].concat(_toConsumableArray((0,_lib.generateAdapterForBundleQueuesManager)(cm).adapters))));var c=cm.new('any',{'some':'thing'});bqm.useBundle({id:5,cursor:c.id,type:'set',path:'some',value:'nothing'},function(){bqm.useBundle({id:1,cursor:c.id,type:'unset',path:'some'},function(){bqm.useBundle({id:0,cursor:c.id,type:'set',path:'some',value:'other'},function(){_chai.assert.deepEqual(c.get('some'),undefined);done()})})})});it('splice',function(done){var cm=new _lib.CursorsManager(_lib.Cursor);var bqm=new(Function.prototype.bind.apply(_lib.BundleQueuesManager,[null].concat(_toConsumableArray((0,_lib.generateAdapterForBundleQueuesManager)(cm).adapters))));var c=cm.new('any',{'some':['things','and','others']});bqm.useBundle({id:1,cursor:c.id,type:'splice',path:'some',start:3,deleteCount:1,items:['nothing']},function(){bqm.useBundle({id:0,cursor:c.id,type:'splice',path:'some',start:2,deleteCount:0,items:['some']},function(){_chai.assert.deepEqual(c.get('some'),['things','and','some','nothing']);done()})})})});describe('ApiManager',function(){it('api instance must receive queries and send bundles',function(done){var counter=1;var interval;var disconnected=false;var manager=new _lib.ApiManager(function adapterFindApi(apiQuery){_chai.assert.equal(apiQuery,'a');function sendBundles(channelId,bundles){manager.adapterSend(channelId,bundles)};return new Promise(function(resolve){return resolve({receiveQuery:function receiveQuery(channelId,query,cursorId,sendBundles){_chai.assert.equal(channelId,2);_chai.assert.equal(query,null);_chai.assert.equal(cursorId,3);interval=setInterval(function(){sendBundles(channelId,++counter)},100)},cursorDestroyed:function cursorDestroyed(channelId,cursorId,sendBundles){_chai.assert.equal(channelId,2);_chai.assert.equal(cursorId,3);clearInterval(interval);_chai.assert.equal(disconnected,true);done()},channelDisconnected:function channelDisconnected(channelId,sendBundles){_chai.assert.equal(disconnected,false);disconnected=true}})})},function adapterSend(channelId,bundles){_chai.assert.equal(channelId,2);_chai.assert.equal(bundles,counter);if(counter>3){manager.channelDisconnected(channelId)}});manager.receiveQuery(2,'a',null,3)})});describe('CursorsManager',function(){it('just should works',function(){var manager=new _lib.CursorsManager(_lib.Cursor);var cursor=manager.new('any','thing');var id0=cursor.id;_chai.assert.equal(manager.cursors[cursor.id],cursor);cursor.destroy();_chai.assert.notProperty(manager.cursors,cursor.id);manager.renew(cursor,'other','something');var id1=cursor.id;_chai.assert.notEqual(id0,id1);_chai.assert.equal(cursor.query,'other');_chai.assert.equal(cursor.data,'something')})});describe('concepts',function(){it('fake primitive server-channel with one api provider',function(){var server=function(){var cursor=new _lib.Cursor(undefined,{a:{b:[{c:'d'},{e:'f'}]}});var channelCursors={};cursor.on(null,function(old,current,stop){var bundles={};for(var c in channelCursors){var currentPerCursor=_lodash2.default.get(current,channelCursors[c].query);if(!_lodash2.default.isEqual(channelCursors[c].old,currentPerCursor)){channelCursors[c].old=currentPerCursor;bundles[c]={id:channelCursors[c].bundlesCounter,type:'set',cursor:c,path:'',value:currentPerCursor};channelCursors[c].bundlesCounter++}}channel.changes(bundles)});var server={api:{cursor:cursor,channelCursors:channelCursors},request:function request(channelCursorId,query){var result=_lodash2.default.cloneDeep(cursor.get(query));if(!channelCursors[channelCursorId]){channelCursors[channelCursorId]={bundlesCounter:0,query:query,old:result}}return _lodash2.default.cloneDeep(result)}};return server}();var channel=function(){var cm=new _lib.CursorsManager(_lib.Cursor);var bqm=new(Function.prototype.bind.apply(_lib.BundleQueuesManager,[null].concat(_toConsumableArray((0,_lib.generateAdapterForBundleQueuesManager)(cm).adapters))));return{api:{cm:cm,needData:function needData(query){var cursor=cm.new(query);var data=server.request(cursor.id,query);cursor.set(null,data);return cursor}},changes:function changes(bundles){for(var b in bundles){if(cm.cursors[bundles[b].cursor]){bqm.useBundle(bundles[b])}}}}}();var cursor1=channel.api.needData('a');var cursor2=channel.api.needData('a.b[0]');_chai.assert.deepEqual(cursor1.get(),server.api.cursor.get('a'));_chai.assert.deepEqual(cursor2.get('c'),server.api.cursor.get('a.b[0].c'));server.api.cursor.set('a.b[0].c','j');_chai.assert.deepEqual(cursor1.get(),server.api.cursor.get('a'));_chai.assert.deepEqual(cursor2.get('c'),server.api.cursor.get('a.b[0].c'));server.api.cursor.splice('a.b',0,1,'abrvalk');_chai.assert.deepEqual(cursor1.get(),server.api.cursor.get('a'));_chai.assert.deepEqual(cursor2.get(),server.api.cursor.get('a.b[0]'))});(0,_react2.default)()})});
'use strict';var _chai=require('chai');var _lib=require('../lib');var _react=require('./react');var _react2=_interopRequireDefault(_react);var _lodash=require('lodash');var _lodash2=_interopRequireDefault(_lodash);var _mingo=require('mingo');var _mingo2=_interopRequireDefault(_mingo);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i]}return arr2}else{return Array.from(arr)}}require('source-map-support').install();describe('AncientSouls/Cursor',function(){describe('Cursor',function(){it('get by path',function(){var document={any:[{custom:{many:'data'}}]};var cursor=new _lib.Cursor(true,document);_chai.assert.equal(cursor.get('any.0.custom.many'),'data')});it('get handle path current set changes',function(done){var document={any:[{custom:{many:'a'}}]};var cursor=new _lib.Cursor(true,document);var changesPattern={old:{many:'a'},path:['any','0','custom'],action:'set',arguments:['any.0.custom',{many:'b'}]};cursor.on('any.0.custom.many',function(old,current,stop,changes,isClone){_chai.assert.equal(old,'a');_chai.assert.equal(current,'b');_chai.assert.deepEqual(changes,changesPattern);_chai.assert.isTrue(isClone)});cursor.on('any.0.custom',function(old,current,stop,changes,isClone){_chai.assert.deepEqual(old,{many:'a'});_chai.assert.deepEqual(current,{many:'b'});_chai.assert.deepEqual(changes,changesPattern);_chai.assert.isTrue(isClone)});cursor.on('any.0',function(old,current,stop,changes,isClone){_chai.assert.deepEqual(old,{custom:{many:'b'}});_chai.assert.deepEqual(current,{custom:{many:'b'}});_chai.assert.deepEqual(changes,changesPattern);_chai.assert.isFalse(isClone);done()});cursor.set('any.0.custom',{many:'b'})});it('set',function(){var cursor=new _lib.Cursor(true,{a:[{b:'x'},{c:'y'},{d:'z'}]});cursor.set('a.0.b','z');_chai.assert.deepEqual(cursor.get('a.0'),{b:'z'});cursor.set('',{x:'y'});_chai.assert.deepEqual(cursor.get(),{x:'y'})});it('splice',function(done){var cursor=new _lib.Cursor(true,{a:[{b:'x'},{c:'y'},{d:'z'}],e:'f'});cursor.on('a.1',function(old,current,stop,changes,isClone){_chai.assert.deepEqual(old,{c:'y'});_chai.assert.deepEqual(current,{e:'q'});_chai.assert.isTrue(isClone);setTimeout(done,100)});cursor.on('a.0',function(old,current,stop,changes,isClone){_chai.assert.deepEqual(old,current);_chai.assert.isTrue(isClone)});cursor.on('e',function(old,current,stop,changes,isClone){throw new Error('It should not be')});cursor.splice('a',1,1,{e:'q'});_chai.assert.equal(cursor.get('a.1.e'),'q')});it('destroy',function(){var cursor=new _lib.Cursor(true,{a:[{b:'x'},{c:'y'},{d:'z'}],e:'f'});cursor.destroy()});it('destroy',function(){var cursor=new _lib.Cursor(true,{a:[{b:'x'},{c:'y'},{d:'z'}],e:'f'});cursor.destroy()});it('once',function(done){var cursor=new _lib.Cursor(true,'a');cursor.on('',function(old,current){if(current=='c')done()});cursor.once('',function(old,current){_chai.assert.equal(current,'b')});cursor.set('','b');cursor.set('','c')})});describe('BundleQueuesManager',function(){it('set',function(done){var cm=new _lib.CursorsManager(_lib.Cursor);var bqm=new(Function.prototype.bind.apply(_lib.BundleQueuesManager,[null].concat(_toConsumableArray((0,_lib.generateAdapterForBundleQueuesManager)(cm).adapters))));var c=cm.new('any',{'some':'thing'});bqm.useBundle({id:5,cursor:c.id,type:'set',path:'some',value:'nothing'},function(){bqm.useBundle({id:1,cursor:c.id,type:'set',path:'some',value:'result'},function(){bqm.useBundle({id:0,cursor:c.id,type:'set',path:'some',value:'other'},function(){_chai.assert.deepEqual(c.get('some'),'result');done()})})})});it('unset',function(done){var cm=new _lib.CursorsManager(_lib.Cursor);var bqm=new(Function.prototype.bind.apply(_lib.BundleQueuesManager,[null].concat(_toConsumableArray((0,_lib.generateAdapterForBundleQueuesManager)(cm).adapters))));var c=cm.new('any',{'some':'thing'});bqm.useBundle({id:5,cursor:c.id,type:'set',path:'some',value:'nothing'},function(){bqm.useBundle({id:1,cursor:c.id,type:'unset',path:'some'},function(){bqm.useBundle({id:0,cursor:c.id,type:'set',path:'some',value:'other'},function(){_chai.assert.deepEqual(c.get('some'),undefined);done()})})})});it('splice',function(done){var cm=new _lib.CursorsManager(_lib.Cursor);var bqm=new(Function.prototype.bind.apply(_lib.BundleQueuesManager,[null].concat(_toConsumableArray((0,_lib.generateAdapterForBundleQueuesManager)(cm).adapters))));var c=cm.new('any',{'some':['things','and','others']});bqm.useBundle({id:1,cursor:c.id,type:'splice',path:'some',start:3,deleteCount:1,items:['nothing']},function(){bqm.useBundle({id:0,cursor:c.id,type:'splice',path:'some',start:2,deleteCount:0,items:['some']},function(){_chai.assert.deepEqual(c.get('some'),['things','and','some','nothing']);done()})})})});describe('ApiManager',function(){it('api instance must receive queries and send bundles',function(done){var counter=1;var interval;var disconnected=false;var manager=new _lib.ApiManager(function adapterFindApi(apiQuery){_chai.assert.equal(apiQuery,'a');function sendBundles(channelId,bundles){manager.adapterSend(channelId,bundles)};return new Promise(function(resolve){return resolve({receiveQuery:function receiveQuery(channelId,query,cursorId,sendBundles){_chai.assert.equal(channelId,2);_chai.assert.equal(query,null);_chai.assert.equal(cursorId,3);interval=setInterval(function(){sendBundles(channelId,++counter,counter)},100)},cursorDestroyed:function cursorDestroyed(channelId,cursorId,sendBundles){_chai.assert.equal(channelId,2);_chai.assert.equal(cursorId,3);clearInterval(interval);_chai.assert.equal(disconnected,true);done()},channelDisconnected:function channelDisconnected(channelId,sendBundles){_chai.assert.equal(disconnected,false);disconnected=true}})})},function adapterSend(channelId,bundles){_chai.assert.equal(channelId,2);_chai.assert.equal(bundles[0],counter);_chai.assert.equal(bundles[1],counter);if(counter>3){manager.channelDisconnected(channelId)}});manager.receiveQuery(2,'a',null,3)})});describe('CursorsManager',function(){it('just should works',function(){var manager=new _lib.CursorsManager(_lib.Cursor);var cursor=manager.new('any','thing');var id0=cursor.id;_chai.assert.equal(manager.cursors[cursor.id],cursor);cursor.destroy();_chai.assert.notProperty(manager.cursors,cursor.id);manager.renew(cursor,'other','something');var id1=cursor.id;_chai.assert.notEqual(id0,id1);_chai.assert.equal(cursor.query,'other');_chai.assert.equal(cursor.data,'something')})});describe('concepts',function(){it('fake primitive server-channel with one api provider',function(){var server=function(){var cursor=new _lib.Cursor(undefined,{a:{b:[{c:'d'},{e:'f'}]}});var channelCursors={};cursor.on(null,function(old,current,stop){var bundles={};for(var c in channelCursors){var currentPerCursor=_lodash2.default.get(current,channelCursors[c].query);if(!_lodash2.default.isEqual(channelCursors[c].old,currentPerCursor)){channelCursors[c].old=currentPerCursor;bundles[c]={id:channelCursors[c].bundlesCounter,type:'set',cursor:c,path:'',value:currentPerCursor};channelCursors[c].bundlesCounter++}}channel.changes(bundles)});var server={api:{cursor:cursor,channelCursors:channelCursors},request:function request(channelCursorId,query){var result=_lodash2.default.cloneDeep(cursor.get(query));if(!channelCursors[channelCursorId]){channelCursors[channelCursorId]={bundlesCounter:0,query:query,old:result}}return _lodash2.default.cloneDeep(result)}};return server}();var channel=function(){var cm=new _lib.CursorsManager(_lib.Cursor);var bqm=new(Function.prototype.bind.apply(_lib.BundleQueuesManager,[null].concat(_toConsumableArray((0,_lib.generateAdapterForBundleQueuesManager)(cm).adapters))));return{api:{cm:cm,needData:function needData(query){var cursor=cm.new(query);var data=server.request(cursor.id,query);cursor.set(null,data);return cursor}},changes:function changes(bundles){for(var b in bundles){if(cm.cursors[bundles[b].cursor]){bqm.useBundle(bundles[b])}}}}}();var cursor1=channel.api.needData('a');var cursor2=channel.api.needData('a.b[0]');_chai.assert.deepEqual(cursor1.get(),server.api.cursor.get('a'));_chai.assert.deepEqual(cursor2.get('c'),server.api.cursor.get('a.b[0].c'));server.api.cursor.set('a.b[0].c','j');_chai.assert.deepEqual(cursor1.get(),server.api.cursor.get('a'));_chai.assert.deepEqual(cursor2.get('c'),server.api.cursor.get('a.b[0].c'));server.api.cursor.splice('a.b',0,1,'abrvalk');_chai.assert.deepEqual(cursor1.get(),server.api.cursor.get('a'));_chai.assert.deepEqual(cursor2.get(),server.api.cursor.get('a.b[0]'))});(0,_react2.default)()})});
//# sourceMappingURL=index.js.map

Sorry, the diff of this file is not supported yet

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