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

@startup-booster/move

Package Overview
Dependencies
Maintainers
4
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@startup-booster/move - npm Package Compare versions

Comparing version 0.1.28 to 0.1.29

52

move.js
const { EventEmitter } = require('events');
const { io } = require('socket.io-client');
const shortid = require('shortid');
const cloneDeep = require('lodash/cloneDeep');
const set = require('lodash/set');
const isEqual = require('lodash/isEqual');

@@ -38,3 +41,3 @@ /** @type {function(string, MoveOptions): MoveClient} */

socket.on('value', (path, value, index) => {
socket.on('value', (path, value, index, initEmit) => {
console.log(`value ${path}`, value);

@@ -47,6 +50,14 @@ if (!listeners[path]) {

}
if (listeners[path].index > index) {
if (move.data.index >= index) {
return;
}
listeners[path].index = index;
if (initEmit) {
return;
}
delete value['@metadata'];
if (isEqual(listeners[path].snapshot, value)) {
return;
}
move.data.index = index;
for (const listener of listeners[path].handlers || []) {

@@ -109,2 +120,5 @@ // Use setTimeout to escape the current call stack and avoid error handling

console.log(`Got ${path}`, value);
const clone = cloneDeep(value);
delete clone['@metadata'];
listeners[path].snapshot = clone;
callback(value);

@@ -114,2 +128,9 @@ });

}
rpc('get', path).then(value => {
console.log(`Got ${path}`, value);
const clone = cloneDeep(value);
delete clone['@metadata'];
listeners[path].snapshot = clone;
callback(value);
});
console.log(`Listen: first handler for ${path}`);

@@ -141,3 +162,2 @@ listeners[path] = {

handlers: new Set([callback]),
index: 0,
};

@@ -163,6 +183,20 @@ await rpc('collectionListen', collection);

async set(path, value) {
const emitIndex = await rpc('set', path, value);
if (listeners[path]) {
listeners[path].index = emitIndex;
const { generation: emitIndex } = await rpc('set', path, value);
for (const listenerPath in listeners) {
if (!path.startsWith(listenerPath)) {
continue;
}
let subpath = path.replace(listenerPath, '');
if (subpath.startsWith('.')) {
subpath = subpath.slice(1);
}
if (!value) {
return;
}
const valueClone = JSON.parse(JSON.stringify(value));
delete valueClone['@metadata'];
set(listeners[listenerPath].snapshot, subpath, valueClone);
}
move.data.index = emitIndex;
},

@@ -216,3 +250,5 @@

data: {},
data: {
index: 0,
},
};

@@ -219,0 +255,0 @@

2

package.json
{
"name": "@startup-booster/move",
"version": "0.1.28",
"version": "0.1.29",
"main": "move.js",

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

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