@thi.ng/dcons
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -1,2 +0,2 @@ | ||
import * as api from "@thi.ng/api"; | ||
import * as api from "@thi.ng/api/api"; | ||
export interface ConsCell<T> { | ||
@@ -25,3 +25,3 @@ value: T; | ||
insertAfterNth(n: number, x: T): DCons<T>; | ||
insertSorted(value: T, compare?: (a: T, b: T) => number): DCons<T>; | ||
insertSorted(value: T, cmp?: api.Comparator<T>): DCons<T>; | ||
find(value: T): ConsCell<T>; | ||
@@ -28,0 +28,0 @@ findWith(fn: (value: T) => boolean): ConsCell<T>; |
17
index.js
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const api = require("@thi.ng/api"); | ||
const checks_1 = require("@thi.ng/checks"); | ||
const compare_1 = require("@thi.ng/api/compare"); | ||
const equiv_1 = require("@thi.ng/api/equiv"); | ||
const is_arraylike_1 = require("@thi.ng/checks/is-arraylike"); | ||
class DCons { | ||
@@ -42,3 +43,3 @@ constructor(src) { | ||
while (ca && res == 0) { | ||
res = api.compare(ca.value, cb.value); | ||
res = compare_1.compare(ca.value, cb.value); | ||
ca = ca.next; | ||
@@ -51,6 +52,6 @@ cb = cb.next; | ||
equiv(o) { | ||
if ((o instanceof DCons || checks_1.isArrayLike(o)) && this._length === o.length) { | ||
if ((o instanceof DCons || is_arraylike_1.isArrayLike(o)) && this._length === o.length) { | ||
let cell = this.head; | ||
for (let x of o) { | ||
if (!api.equiv(cell.value, x)) { | ||
if (!equiv_1.equiv(cell.value, x)) { | ||
return false; | ||
@@ -154,7 +155,7 @@ } | ||
} | ||
insertSorted(value, compare) { | ||
compare = compare || api.compare; | ||
insertSorted(value, cmp) { | ||
cmp = cmp || compare_1.compare; | ||
let cell = this.head; | ||
while (cell) { | ||
if (compare(value, cell.value) <= 0) { | ||
if (cmp(value, cell.value) <= 0) { | ||
return this.insertBefore(cell, value); | ||
@@ -161,0 +162,0 @@ } |
{ | ||
"name": "@thi.ng/dcons", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Comprehensive doubly linked list structure w/ iterator support", | ||
@@ -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
15472
488