New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

delta-listener

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

delta-listener - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0-alpha.0

36

lib/compare.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function compare(tree1, tree2) {

@@ -8,19 +9,14 @@ var patches = [];

exports.compare = compare;
function deepClone(obj) {
switch (typeof obj) {
case "object":
return JSON.parse(JSON.stringify(obj)); //Faster than ES5 clone - http://jsperf.com/deep-cloning-of-objects/5
case "undefined":
return null; //this is how JSON.stringify behaves for array items
default:
return obj; //no need to clone primitives
}
function concat(arr, value) {
var newArr = arr.slice();
newArr.push(value);
return newArr;
}
function objectKeys(obj) {
if (Array.isArray(obj)) {
var keys = new Array(obj.length);
for (var k = 0; k < keys.length; k++) {
keys[k] = "" + k;
var keys_1 = new Array(obj.length);
for (var k = 0; k < keys_1.length; k++) {
keys_1[k] = "" + k;
}
return keys;
return keys_1;
}

@@ -51,3 +47,3 @@ if (Object.keys) {

if (typeof oldVal == "object" && oldVal != null && typeof newVal == "object" && newVal != null) {
generate(oldVal, newVal, patches, path.concat(key));
generate(oldVal, newVal, patches, concat(path, key));
}

@@ -57,3 +53,3 @@ else {

changed = true;
patches.push({ operation: "replace", path: path.concat(key), value: deepClone(newVal) });
patches.push({ operation: "replace", path: concat(path, key), value: newVal });
}

@@ -63,3 +59,3 @@ }

else {
patches.push({ operation: "remove", path: path.concat(key) });
patches.push({ operation: "remove", path: concat(path, key) });
deleted = true; // property has been deleted

@@ -74,5 +70,11 @@ }

if (!mirror.hasOwnProperty(key) && obj[key] !== undefined) {
patches.push({ operation: "add", path: path.concat(key), value: deepClone(obj[key]) });
var newVal = obj[key];
var addPath = concat(path, key);
// compare deeper additions
if (typeof newVal == "object" && newVal != null) {
generate({}, newVal, patches, addPath);
}
patches.push({ operation: "add", path: addPath, value: newVal });
}
}
}

@@ -10,3 +10,3 @@ import { PatchObject } from "./compare";

}
export declare class DeltaContainer<T> {
export declare class DeltaContainer<T = any> {
data: T;

@@ -13,0 +13,0 @@ private listeners;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var compare_1 = require("./compare");
var DeltaContainer = (function () {
var DeltaContainer = /** @class */ (function () {
function DeltaContainer(data) {

@@ -5,0 +6,0 @@ this.listeners = [];

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var DeltaContainer_1 = require("./DeltaContainer");
exports.DeltaContainer = DeltaContainer_1.DeltaContainer;
{
"name": "delta-listener",
"version": "2.0.0",
"version": "2.1.0-alpha.0",
"description": "Deeply compare JavaScript objects and listen to changes.",

@@ -28,9 +28,9 @@ "main": "lib/index.js",

"chai": "^3.5.0",
"fast-json-patch": "^1.1.2",
"fast-json-patch": "^2.0.5",
"mocha": "^3.2.0",
"rimraf": "^2.5.4",
"ts-node": "^3.1.0",
"typescript": "^2.1.4",
"typescript": "^2.5.3",
"zuul": "^3.11.1"
}
}

@@ -87,2 +87,3 @@ # delta-listener [![Build status](https://travis-ci.org/endel/delta-listener.svg?branch=master)](https://travis-ci.org/endel/delta-listener)

- `:string`: `/(\w+)/`
- `:axis`: `/^([xyz])$/`
- `:*`: `/(.*)/`

@@ -89,0 +90,0 @@

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