@casret/dedupe
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -47,3 +47,3 @@ const SortedItems = Symbol("SortedItems") | ||
const index = current_keys.findIndex(key => key == key_cache[0]) | ||
if (index) items = items.slice(0, index) | ||
if (index > -1) items = items.slice(0, index) | ||
key_cache = current_keys | ||
@@ -50,0 +50,0 @@ } else { |
const {SortedItems, SortedKeys, Unsorted, dedupe} = require("./index") | ||
describe("SortedItems strategy", () => { | ||
test("should drop any key to the right of the pivot", () => { | ||
test("should drop any key to the right of the pivot and update key_cache", () => { | ||
const { items, key_cache } = dedupe(SortedItems, [{id: "a"}, {id: "b"}, {id:"c"}], ["b"]) | ||
@@ -9,2 +9,13 @@ expect(items).toEqual([{id: "a"}]) | ||
}) | ||
test("should drop all keys if pivot is the key_cache", () => { | ||
const { items, key_cache } = dedupe(SortedItems, [{id: "a"}, {id: "b"}, {id:"c"}], ["a"]) | ||
expect(items).toEqual([]) | ||
expect(key_cache).toEqual(["a"]) | ||
}) | ||
test("should keep all keys and update key_cache if pivot doesn't match", () => { | ||
const { items, key_cache } = dedupe(SortedItems, [{id: "a"}, {id: "b"}, {id:"c"}], ["d"]) | ||
expect(items).toEqual([{id: "a"}, {id: "b"}, {id: "c"}]) | ||
expect(key_cache).toEqual(["a"]) | ||
}) | ||
}) | ||
@@ -11,0 +22,0 @@ |
{ | ||
"name": "@casret/dedupe", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Dedupe utilities for pipedream", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
5703
121