@thi.ng/associative
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -6,2 +6,10 @@ # Change Log | ||
## [1.0.7](https://github.com/thi-ng/umbrella/compare/@thi.ng/associative@1.0.6...@thi.ng/associative@1.0.7) (2019-03-01) | ||
**Note:** Version bump only for package @thi.ng/associative | ||
## [1.0.6](https://github.com/thi-ng/umbrella/compare/@thi.ng/associative@1.0.5...@thi.ng/associative@1.0.6) (2019-02-26) | ||
@@ -8,0 +16,0 @@ |
@@ -19,3 +19,3 @@ import { SEMAPHORE } from "@thi.ng/api"; | ||
__private.set(this, { | ||
keys: new (_opts.keys)(null, { equiv: _opts.equiv }), | ||
keys: new _opts.keys(null, { equiv: _opts.equiv }), | ||
map: new Map(), | ||
@@ -66,3 +66,3 @@ opts: _opts | ||
map: new Map($this.map), | ||
opts: $this.opts, | ||
opts: $this.opts | ||
}); | ||
@@ -69,0 +69,0 @@ return m; |
@@ -28,3 +28,3 @@ import { EquivMap } from "./equiv-map"; | ||
rv = res.get(ik); | ||
!rv && res.set(ik, rv = empty(records, Set)); | ||
!rv && res.set(ik, (rv = empty(records, Set))); | ||
rv.add(x); | ||
@@ -31,0 +31,0 @@ } |
@@ -147,4 +147,8 @@ 'use strict'; | ||
const empty = (x, ctor) => checks.implementsFunction(x, "empty") ? x.empty() : new (x[Symbol.species] || ctor)(); | ||
const copy = (x, ctor) => checks.implementsFunction(x, "copy") ? x.copy() : new (x[Symbol.species] || ctor)(x); | ||
const empty = (x, ctor) => checks.implementsFunction(x, "empty") | ||
? x.empty() | ||
: new (x[Symbol.species] || ctor)(); | ||
const copy = (x, ctor) => checks.implementsFunction(x, "copy") | ||
? x.copy() | ||
: new (x[Symbol.species] || ctor)(x); | ||
const first = (x) => x[Symbol.iterator]().next().value; | ||
@@ -176,3 +180,3 @@ const objValues = (src) => { | ||
__private$1.set(this, { | ||
keys: new (_opts.keys)(null, { equiv: _opts.equiv }), | ||
keys: new _opts.keys(null, { equiv: _opts.equiv }), | ||
map: new Map(), | ||
@@ -217,3 +221,3 @@ opts: _opts | ||
map: new Map($this.map), | ||
opts: $this.opts, | ||
opts: $this.opts | ||
}); | ||
@@ -328,3 +332,3 @@ return m; | ||
rv = res.get(ik); | ||
!rv && res.set(ik, rv = empty(records, Set)); | ||
!rv && res.set(ik, (rv = empty(records, Set))); | ||
rv.add(x); | ||
@@ -451,3 +455,6 @@ } | ||
super(); | ||
__private$2.set(this, { equiv: opts.equiv || equiv.equiv, vals: new dcons.DCons() }); | ||
__private$2.set(this, { | ||
equiv: opts.equiv || equiv.equiv, | ||
vals: new dcons.DCons() | ||
}); | ||
vals && this.into(vals); | ||
@@ -616,5 +623,3 @@ } | ||
const mergeDeepObj = (dest, ...xs) => mergeObjWith((a, b) => checks.isPlainObject(a) && checks.isPlainObject(b) ? | ||
mergeDeepObj(a, b) : | ||
b, dest, ...xs); | ||
const mergeDeepObj = (dest, ...xs) => mergeObjWith((a, b) => checks.isPlainObject(a) && checks.isPlainObject(b) ? mergeDeepObj(a, b) : b, dest, ...xs); | ||
@@ -641,3 +646,5 @@ const __private$3 = new WeakMap(); | ||
static fromObject(obj) { | ||
const m = new SortedMap(null, { capacity: Object.keys(obj).length }); | ||
const m = new SortedMap(null, { | ||
capacity: Object.keys(obj).length | ||
}); | ||
for (let k in obj) { | ||
@@ -676,3 +683,3 @@ m.set(k, obj[k]); | ||
let c; | ||
while ((x = i.next(), y = j.next(), !x.done && !y.done)) { | ||
while (((x = i.next()), (y = j.next()), !x.done && !y.done)) { | ||
if ((c = compare.compare(x.value[0], y.value[0])) !== 0) { | ||
@@ -761,3 +768,4 @@ return c; | ||
} | ||
while ($this.level > 0 && $this.head[$this.level + NEXT][KEY] === undefined) { | ||
while ($this.level > 0 && | ||
$this.head[$this.level + NEXT][KEY] === undefined) { | ||
$this.level--; | ||
@@ -785,5 +793,3 @@ } | ||
const node = this.findLess(key)[NEXT]; | ||
return $this.equiv(node[KEY], key) ? | ||
node[VAL] : | ||
notFound; | ||
return $this.equiv(node[KEY], key) ? node[VAL] : notFound; | ||
} | ||
@@ -811,5 +817,7 @@ into(pairs) { | ||
const found = this.findLess(key); | ||
node = !reverse || (found[NEXT] != $this.nil && $this.equiv(found[NEXT][KEY], key)) ? | ||
found[NEXT] : | ||
found; | ||
node = | ||
!reverse || | ||
(found[NEXT] != $this.nil && $this.equiv(found[NEXT][KEY], key)) | ||
? found[NEXT] | ||
: found; | ||
} | ||
@@ -862,3 +870,3 @@ while (node[KEY] !== undefined) { | ||
compare: $this.cmp, | ||
probability: $this.p, | ||
probability: $this.p | ||
}; | ||
@@ -945,3 +953,3 @@ } | ||
let c; | ||
while ((x = i.next(), y = j.next(), !x.done && !y.done)) { | ||
while (((x = i.next()), (y = j.next()), !x.done && !y.done)) { | ||
if ((c = compare.compare(x.value[0], y.value[0])) !== 0) { | ||
@@ -948,0 +956,0 @@ return c; |
@@ -141,4 +141,8 @@ (function (global, factory) { | ||
const empty = (x, ctor) => checks.implementsFunction(x, "empty") ? x.empty() : new (x[Symbol.species] || ctor)(); | ||
const copy = (x, ctor) => checks.implementsFunction(x, "copy") ? x.copy() : new (x[Symbol.species] || ctor)(x); | ||
const empty = (x, ctor) => checks.implementsFunction(x, "empty") | ||
? x.empty() | ||
: new (x[Symbol.species] || ctor)(); | ||
const copy = (x, ctor) => checks.implementsFunction(x, "copy") | ||
? x.copy() | ||
: new (x[Symbol.species] || ctor)(x); | ||
const first = (x) => x[Symbol.iterator]().next().value; | ||
@@ -170,3 +174,3 @@ const objValues = (src) => { | ||
__private$1.set(this, { | ||
keys: new (_opts.keys)(null, { equiv: _opts.equiv }), | ||
keys: new _opts.keys(null, { equiv: _opts.equiv }), | ||
map: new Map(), | ||
@@ -211,3 +215,3 @@ opts: _opts | ||
map: new Map($this.map), | ||
opts: $this.opts, | ||
opts: $this.opts | ||
}); | ||
@@ -322,3 +326,3 @@ return m; | ||
rv = res.get(ik); | ||
!rv && res.set(ik, rv = empty(records, Set)); | ||
!rv && res.set(ik, (rv = empty(records, Set))); | ||
rv.add(x); | ||
@@ -445,3 +449,6 @@ } | ||
super(); | ||
__private$2.set(this, { equiv: opts.equiv || equiv.equiv, vals: new dcons.DCons() }); | ||
__private$2.set(this, { | ||
equiv: opts.equiv || equiv.equiv, | ||
vals: new dcons.DCons() | ||
}); | ||
vals && this.into(vals); | ||
@@ -610,5 +617,3 @@ } | ||
const mergeDeepObj = (dest, ...xs) => mergeObjWith((a, b) => checks.isPlainObject(a) && checks.isPlainObject(b) ? | ||
mergeDeepObj(a, b) : | ||
b, dest, ...xs); | ||
const mergeDeepObj = (dest, ...xs) => mergeObjWith((a, b) => checks.isPlainObject(a) && checks.isPlainObject(b) ? mergeDeepObj(a, b) : b, dest, ...xs); | ||
@@ -635,3 +640,5 @@ const __private$3 = new WeakMap(); | ||
static fromObject(obj) { | ||
const m = new SortedMap(null, { capacity: Object.keys(obj).length }); | ||
const m = new SortedMap(null, { | ||
capacity: Object.keys(obj).length | ||
}); | ||
for (let k in obj) { | ||
@@ -670,3 +677,3 @@ m.set(k, obj[k]); | ||
let c; | ||
while ((x = i.next(), y = j.next(), !x.done && !y.done)) { | ||
while (((x = i.next()), (y = j.next()), !x.done && !y.done)) { | ||
if ((c = compare.compare(x.value[0], y.value[0])) !== 0) { | ||
@@ -755,3 +762,4 @@ return c; | ||
} | ||
while ($this.level > 0 && $this.head[$this.level + NEXT][KEY] === undefined) { | ||
while ($this.level > 0 && | ||
$this.head[$this.level + NEXT][KEY] === undefined) { | ||
$this.level--; | ||
@@ -779,5 +787,3 @@ } | ||
const node = this.findLess(key)[NEXT]; | ||
return $this.equiv(node[KEY], key) ? | ||
node[VAL] : | ||
notFound; | ||
return $this.equiv(node[KEY], key) ? node[VAL] : notFound; | ||
} | ||
@@ -805,5 +811,7 @@ into(pairs) { | ||
const found = this.findLess(key); | ||
node = !reverse || (found[NEXT] != $this.nil && $this.equiv(found[NEXT][KEY], key)) ? | ||
found[NEXT] : | ||
found; | ||
node = | ||
!reverse || | ||
(found[NEXT] != $this.nil && $this.equiv(found[NEXT][KEY], key)) | ||
? found[NEXT] | ||
: found; | ||
} | ||
@@ -856,3 +864,3 @@ while (node[KEY] !== undefined) { | ||
compare: $this.cmp, | ||
probability: $this.p, | ||
probability: $this.p | ||
}; | ||
@@ -939,3 +947,3 @@ } | ||
let c; | ||
while ((x = i.next(), y = j.next(), !x.done && !y.done)) { | ||
while (((x = i.next()), (y = j.next()), !x.done && !y.done)) { | ||
if ((c = compare.compare(x.value[0], y.value[0])) !== 0) { | ||
@@ -942,0 +950,0 @@ return c; |
@@ -17,3 +17,6 @@ import { SEMAPHORE } from "@thi.ng/api"; | ||
super(); | ||
__private.set(this, { equiv: opts.equiv || equiv, vals: new DCons() }); | ||
__private.set(this, { | ||
equiv: opts.equiv || equiv, | ||
vals: new DCons() | ||
}); | ||
vals && this.into(vals); | ||
@@ -20,0 +23,0 @@ } |
import { isPlainObject } from "@thi.ng/checks"; | ||
import { mergeObjWith } from "./merge-with"; | ||
export const mergeDeepObj = (dest, ...xs) => mergeObjWith((a, b) => isPlainObject(a) && isPlainObject(b) ? | ||
mergeDeepObj(a, b) : | ||
b, dest, ...xs); | ||
export const mergeDeepObj = (dest, ...xs) => mergeObjWith((a, b) => isPlainObject(a) && isPlainObject(b) ? mergeDeepObj(a, b) : b, dest, ...xs); |
{ | ||
"name": "@thi.ng/associative", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "Alternative Set & Map data type implementations with customizable equality semantics & supporting operations", | ||
@@ -35,9 +35,9 @@ "module": "./index.js", | ||
"dependencies": { | ||
"@thi.ng/api": "^5.0.2", | ||
"@thi.ng/checks": "^2.1.0", | ||
"@thi.ng/compare": "^1.0.2", | ||
"@thi.ng/dcons": "^2.0.6", | ||
"@thi.ng/equiv": "^1.0.2", | ||
"@thi.ng/errors": "^1.0.2", | ||
"@thi.ng/transducers": "^5.1.0" | ||
"@thi.ng/api": "^5.0.3", | ||
"@thi.ng/checks": "^2.1.1", | ||
"@thi.ng/compare": "^1.0.3", | ||
"@thi.ng/dcons": "^2.0.7", | ||
"@thi.ng/equiv": "^1.0.3", | ||
"@thi.ng/errors": "^1.0.3", | ||
"@thi.ng/transducers": "^5.1.1" | ||
}, | ||
@@ -63,3 +63,3 @@ "keywords": [ | ||
"sideEffects": false, | ||
"gitHead": "647e13737436e44d28e151c0be8594835cf25ed0" | ||
"gitHead": "e43f57c7554fd78380bba58d37ae62ca01221eeb" | ||
} |
@@ -54,3 +54,5 @@ import { SEMAPHORE } from "@thi.ng/api"; | ||
static fromObject(obj) { | ||
const m = new SortedMap(null, { capacity: Object.keys(obj).length }); | ||
const m = new SortedMap(null, { | ||
capacity: Object.keys(obj).length | ||
}); | ||
for (let k in obj) { | ||
@@ -89,3 +91,3 @@ m.set(k, obj[k]); | ||
let c; | ||
while ((x = i.next(), y = j.next(), !x.done && !y.done)) { | ||
while (((x = i.next()), (y = j.next()), !x.done && !y.done)) { | ||
if ((c = compare(x.value[0], y.value[0])) !== 0) { | ||
@@ -174,3 +176,4 @@ return c; | ||
} | ||
while ($this.level > 0 && $this.head[$this.level + NEXT][KEY] === undefined) { | ||
while ($this.level > 0 && | ||
$this.head[$this.level + NEXT][KEY] === undefined) { | ||
$this.level--; | ||
@@ -198,5 +201,3 @@ } | ||
const node = this.findLess(key)[NEXT]; | ||
return $this.equiv(node[KEY], key) ? | ||
node[VAL] : | ||
notFound; | ||
return $this.equiv(node[KEY], key) ? node[VAL] : notFound; | ||
} | ||
@@ -225,5 +226,7 @@ into(pairs) { | ||
// the original python impl doesn't handle unknown and out-of-range keys properly | ||
node = !reverse || (found[NEXT] != $this.nil && $this.equiv(found[NEXT][KEY], key)) ? | ||
found[NEXT] : | ||
found; | ||
node = | ||
!reverse || | ||
(found[NEXT] != $this.nil && $this.equiv(found[NEXT][KEY], key)) | ||
? found[NEXT] | ||
: found; | ||
} | ||
@@ -276,3 +279,3 @@ while (node[KEY] !== undefined) { | ||
compare: $this.cmp, | ||
probability: $this.p, | ||
probability: $this.p | ||
}; | ||
@@ -279,0 +282,0 @@ } |
@@ -0,4 +1,4 @@ | ||
import { ICompare, Pair } from "@thi.ng/api"; | ||
import { IReducible, ReductionFn } from "@thi.ng/transducers"; | ||
import { IEquivSet, SortedSetOpts } from "./api"; | ||
import { ICompare, Pair } from "@thi.ng/api"; | ||
/** | ||
@@ -5,0 +5,0 @@ * Sorted set implementation with standard ES6 Set API, customizable |
@@ -58,3 +58,3 @@ import { compare } from "@thi.ng/compare"; | ||
let c; | ||
while ((x = i.next(), y = j.next(), !x.done && !y.done)) { | ||
while (((x = i.next()), (y = j.next()), !x.done && !y.done)) { | ||
if ((c = compare(x.value[0], y.value[0])) !== 0) { | ||
@@ -61,0 +61,0 @@ return c; |
import { implementsFunction } from "@thi.ng/checks"; | ||
export const empty = (x, ctor) => implementsFunction(x, "empty") ? x.empty() : new (x[Symbol.species] || ctor)(); | ||
export const copy = (x, ctor) => implementsFunction(x, "copy") ? x.copy() : new (x[Symbol.species] || ctor)(x); | ||
export const empty = (x, ctor) => implementsFunction(x, "empty") | ||
? x.empty() | ||
: new (x[Symbol.species] || ctor)(); | ||
export const copy = (x, ctor) => implementsFunction(x, "copy") | ||
? x.copy() | ||
: new (x[Symbol.species] || ctor)(x); | ||
export const first = (x) => x[Symbol.iterator]().next().value; | ||
@@ -5,0 +9,0 @@ export const objValues = (src) => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
211721
3943
Updated@thi.ng/api@^5.0.3
Updated@thi.ng/checks@^2.1.1
Updated@thi.ng/compare@^1.0.3
Updated@thi.ng/dcons@^2.0.7
Updated@thi.ng/equiv@^1.0.3
Updated@thi.ng/errors@^1.0.3
Updated@thi.ng/transducers@^5.1.1