iridium
Advanced tools
Comparing version 7.2.4 to 7.2.5
@@ -89,4 +89,9 @@ "use strict"; | ||
for (; i < original.length && j < modified.length; i++) { | ||
if (this.almostEqual(original[i], modified[j])) | ||
const equalityDistance = this.almostEqual(original[i], modified[j]); | ||
if (equalityDistance == 1) | ||
j++; | ||
else if (equalityDistance > 0) | ||
// If we would need to both pull and $set on this array, we have to | ||
// just use the $set operator. | ||
return this.set(changePath, modified); | ||
else | ||
@@ -103,4 +108,5 @@ pulls.push(original[i]); | ||
} | ||
else | ||
return this.set(changePath, modified); | ||
// If we have a smaller target array than our source, we will need to re-create it | ||
// regardless (if we want to do so in a single operation anyway) | ||
return this.set(changePath, modified); | ||
} | ||
@@ -107,0 +113,0 @@ onLargerArray(original, modified, changePath) { |
@@ -262,4 +262,27 @@ "use strict"; | ||
}); | ||
it("should handle complex array objects which should be replaced in a smaller array", () => { | ||
let oldObject = { a: [{ x: 1, y: "a" }, { x: 2, y: "b" }, { x: 3, y: "c" }, { x: 4, y: "d" }] }; | ||
let newObject = { a: [{ x: 1, y: "z" }, { x: 2, y: "y" }] }; | ||
let expectedDiff = { | ||
$set: { | ||
"a": [{ x: 1, y: "z" }, { x: 2, y: "y" }] | ||
} | ||
}; | ||
chai.expect(Omnom_1.Omnom.diff(oldObject, newObject)).to.exist.and.be.eql(expectedDiff); | ||
}); | ||
it("should handle complex array objects which should be replaced in a larger array", () => { | ||
let oldObject = { a: [{ x: 1, y: "a" }, { x: 2, y: "b" }] }; | ||
let newObject = { a: [{ x: 1, y: "z" }, { x: 2, y: "y" }, { x: 3, y: "x" }, { x: 4, y: "w" }] }; | ||
let expectedDiff = { | ||
$set: { | ||
"a.0.y": "z", | ||
"a.1.y": "y", | ||
"a.2": { x: 3, y: "x" }, | ||
"a.3": { x: 4, y: "w" } | ||
} | ||
}; | ||
chai.expect(Omnom_1.Omnom.diff(oldObject, newObject)).to.exist.and.be.eql(expectedDiff); | ||
}); | ||
}); | ||
}); | ||
//# sourceMappingURL=Omnom.js.map |
{ | ||
"name": "iridium", | ||
"version": "7.2.4", | ||
"version": "7.2.5", | ||
"author": "Benjamin Pannell <admin@sierrasoftworks.com>", | ||
@@ -5,0 +5,0 @@ "description": "A custom lightweight ORM for MongoDB designed for power-users", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
764460
192
8120
0