diff --git a/README.md b/README.md
index 15a50cc8f6..4fb95a3711 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
# @thi.ng/umbrella
[![Travis status](https://api.travis-ci.org/thi-ng/umbrella.svg?branch=master)](https://travis-ci.org/thi-ng/umbrella)
+[![Code Climate](https://api.codeclimate.com/v1/badges/592940419adb5bf8abaf/maintainability)](https://codeclimate.com/github/thi-ng/umbrella/maintainability)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org/)
[![Discord chat](https://img.shields.io/discord/445761008837984256.svg)](https://discord.gg/JhYcmBw)
[![Twitter Follow](https://img.shields.io/twitter/follow/thing_umbrella.svg?label=%40thing_umbrella&style=social)](https://twitter.com/thing_umbrella)
diff --git a/examples/geom-convex-hull/src/webpack.d.ts b/examples/geom-convex-hull/src/webpack.d.ts
new file mode 100644
index 0000000000..6e39ca7616
--- /dev/null
+++ b/examples/geom-convex-hull/src/webpack.d.ts
@@ -0,0 +1,3 @@
+declare module "*.jpg";
+declare module "*.png";
+declare module "*.svg";
diff --git a/examples/imgui/README.md b/examples/imgui/README.md
index 149ce48398..9a287dd366 100644
--- a/examples/imgui/README.md
+++ b/examples/imgui/README.md
@@ -1,6 +1,6 @@
# imgui
-![screenshot](https://raw.githubusercontent.com/thi-ng/umbrella/feature/imgui/assets/screenshots/imgui-demo.png)
+![screenshot](https://raw.githubusercontent.com/thi-ng/umbrella/master/assets/screenshots/imgui-demo.png)
[Live demo](http://demo.thi.ng/umbrella/imgui/)
diff --git a/examples/imgui/index.html b/examples/imgui/index.html
index 4a1c63715d..7087dbe5f0 100644
--- a/examples/imgui/index.html
+++ b/examples/imgui/index.html
@@ -39,7 +39,7 @@
Source code / Info
diff --git a/examples/imgui/src/webpack.d.ts b/examples/imgui/src/webpack.d.ts
new file mode 100644
index 0000000000..6e39ca7616
--- /dev/null
+++ b/examples/imgui/src/webpack.d.ts
@@ -0,0 +1,3 @@
+declare module "*.jpg";
+declare module "*.png";
+declare module "*.svg";
diff --git a/examples/pixel-basics/src/webpack.d.ts b/examples/pixel-basics/src/webpack.d.ts
new file mode 100644
index 0000000000..891c762327
--- /dev/null
+++ b/examples/pixel-basics/src/webpack.d.ts
@@ -0,0 +1,2 @@
+declare module "*.jpg";
+declare module "*.png";
diff --git a/examples/porter-duff/src/webpack.d.ts b/examples/porter-duff/src/webpack.d.ts
new file mode 100644
index 0000000000..6e39ca7616
--- /dev/null
+++ b/examples/porter-duff/src/webpack.d.ts
@@ -0,0 +1,3 @@
+declare module "*.jpg";
+declare module "*.png";
+declare module "*.svg";
diff --git a/examples/scenegraph-image/src/webpack.d.ts b/examples/scenegraph-image/src/webpack.d.ts
new file mode 100644
index 0000000000..65e20c0a38
--- /dev/null
+++ b/examples/scenegraph-image/src/webpack.d.ts
@@ -0,0 +1,2 @@
+declare module "*.png";
+declare module "*.jpg";
diff --git a/examples/shader-ast-noise/index.html b/examples/shader-ast-noise/index.html
index 7a1fc0bfb0..c95735abab 100644
--- a/examples/shader-ast-noise/index.html
+++ b/examples/shader-ast-noise/index.html
@@ -27,7 +27,7 @@
Source code
diff --git a/examples/shader-ast-raymarch/index.html b/examples/shader-ast-raymarch/index.html
index 4df683ba16..c030e2f6b8 100644
--- a/examples/shader-ast-raymarch/index.html
+++ b/examples/shader-ast-raymarch/index.html
@@ -27,7 +27,7 @@
Source code
diff --git a/examples/shader-ast-sdf2d/index.html b/examples/shader-ast-sdf2d/index.html
index bf6558aac0..b1bb4735af 100644
--- a/examples/shader-ast-sdf2d/index.html
+++ b/examples/shader-ast-sdf2d/index.html
@@ -27,7 +27,7 @@
Source code
diff --git a/examples/shader-ast-sdf2d/package.json b/examples/shader-ast-sdf2d/package.json
index ee609cee03..56f8728490 100644
--- a/examples/shader-ast-sdf2d/package.json
+++ b/examples/shader-ast-sdf2d/package.json
@@ -7,6 +7,7 @@
"scripts": {
"clean": "rm -rf .cache build out",
"build": "yarn clean && parcel build index.html -d out --public-url ./ --no-source-maps --no-cache --detailed-report",
+ "build:webpack": "../../node_modules/.bin/webpack --mode production",
"start": "parcel index.html -p 8080 --open"
},
"devDependencies": {
diff --git a/examples/shader-ast-sdf2d/webpack.config.js b/examples/shader-ast-sdf2d/webpack.config.js
new file mode 100644
index 0000000000..bf16021356
--- /dev/null
+++ b/examples/shader-ast-sdf2d/webpack.config.js
@@ -0,0 +1,23 @@
+module.exports = {
+ entry: "./src/index.ts",
+ output: {
+ filename: "bundle.[hash].js",
+ path: __dirname + "/out"
+ },
+ resolve: {
+ extensions: [".ts", ".js"]
+ },
+ module: {
+ rules: [
+ {
+ test: /\.(png|jpg|gif)$/,
+ loader: "file-loader",
+ options: { name: "[path][hash].[ext]" }
+ },
+ { test: /\.ts$/, use: "ts-loader" }
+ ]
+ },
+ node: {
+ process: false
+ }
+};
diff --git a/examples/shader-ast-tunnel/index.html b/examples/shader-ast-tunnel/index.html
index c0b8c1f0e7..74e1fac015 100644
--- a/examples/shader-ast-tunnel/index.html
+++ b/examples/shader-ast-tunnel/index.html
@@ -27,7 +27,7 @@
Source code
diff --git a/examples/shader-ast-tunnel/package.json b/examples/shader-ast-tunnel/package.json
index bb0d0ea3c0..375e237d53 100644
--- a/examples/shader-ast-tunnel/package.json
+++ b/examples/shader-ast-tunnel/package.json
@@ -7,6 +7,7 @@
"scripts": {
"clean": "rm -rf .cache build out",
"build": "yarn clean && parcel build index.html -d out --public-url ./ --no-source-maps --no-cache --detailed-report",
+ "build:webpack": "../../node_modules/.bin/webpack --mode production",
"start": "parcel index.html -p 8080 --open"
},
"devDependencies": {
diff --git a/examples/shader-ast-tunnel/src/webpack.d.ts b/examples/shader-ast-tunnel/src/webpack.d.ts
new file mode 100644
index 0000000000..6e39ca7616
--- /dev/null
+++ b/examples/shader-ast-tunnel/src/webpack.d.ts
@@ -0,0 +1,3 @@
+declare module "*.jpg";
+declare module "*.png";
+declare module "*.svg";
diff --git a/examples/shader-ast-tunnel/webpack.config.js b/examples/shader-ast-tunnel/webpack.config.js
new file mode 100644
index 0000000000..bf16021356
--- /dev/null
+++ b/examples/shader-ast-tunnel/webpack.config.js
@@ -0,0 +1,23 @@
+module.exports = {
+ entry: "./src/index.ts",
+ output: {
+ filename: "bundle.[hash].js",
+ path: __dirname + "/out"
+ },
+ resolve: {
+ extensions: [".ts", ".js"]
+ },
+ module: {
+ rules: [
+ {
+ test: /\.(png|jpg|gif)$/,
+ loader: "file-loader",
+ options: { name: "[path][hash].[ext]" }
+ },
+ { test: /\.ts$/, use: "ts-loader" }
+ ]
+ },
+ node: {
+ process: false
+ }
+};
diff --git a/examples/texgen/src/webpack.d.ts b/examples/texgen/src/webpack.d.ts
new file mode 100644
index 0000000000..6e39ca7616
--- /dev/null
+++ b/examples/texgen/src/webpack.d.ts
@@ -0,0 +1,3 @@
+declare module "*.jpg";
+declare module "*.png";
+declare module "*.svg";
diff --git a/packages/adjacency/CHANGELOG.md b/packages/adjacency/CHANGELOG.md
index 45f8ab9d53..47b979685e 100644
--- a/packages/adjacency/CHANGELOG.md
+++ b/packages/adjacency/CHANGELOG.md
@@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+## [0.1.23](https://github.com/thi-ng/umbrella/compare/@thi.ng/adjacency@0.1.22...@thi.ng/adjacency@0.1.23) (2019-08-21)
+
+**Note:** Version bump only for package @thi.ng/adjacency
+
+
+
+
+
+## [0.1.22](https://github.com/thi-ng/umbrella/compare/@thi.ng/adjacency@0.1.21...@thi.ng/adjacency@0.1.22) (2019-08-17)
+
+**Note:** Version bump only for package @thi.ng/adjacency
+
+
+
+
+
## [0.1.21](https://github.com/thi-ng/umbrella/compare/@thi.ng/adjacency@0.1.20...@thi.ng/adjacency@0.1.21) (2019-08-16)
**Note:** Version bump only for package @thi.ng/adjacency
diff --git a/packages/adjacency/package.json b/packages/adjacency/package.json
index 07890c9926..8cb5f2c8ae 100644
--- a/packages/adjacency/package.json
+++ b/packages/adjacency/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/adjacency",
- "version": "0.1.21",
+ "version": "0.1.23",
"description": "Sparse & bitwise adjacency matrices for directed / undirected graphs",
"module": "./index.js",
"main": "./lib/index.js",
@@ -25,7 +25,7 @@
"pub": "yarn build:release && yarn publish --access public"
},
"devDependencies": {
- "@thi.ng/vectors": "^3.1.1",
+ "@thi.ng/vectors": "^3.3.0",
"@types/mocha": "^5.2.6",
"@types/node": "^12.6.3",
"mocha": "^6.1.4",
@@ -34,12 +34,12 @@
"typescript": "^3.5.3"
},
"dependencies": {
- "@thi.ng/api": "^6.3.2",
+ "@thi.ng/api": "^6.3.3",
"@thi.ng/binary": "^1.1.0",
- "@thi.ng/bitfield": "^0.1.11",
+ "@thi.ng/bitfield": "^0.1.12",
"@thi.ng/checks": "^2.3.0",
- "@thi.ng/dcons": "^2.1.3",
- "@thi.ng/sparse": "^0.1.19"
+ "@thi.ng/dcons": "^2.1.4",
+ "@thi.ng/sparse": "^0.1.20"
},
"keywords": [
"adjacency",
diff --git a/packages/api/CHANGELOG.md b/packages/api/CHANGELOG.md
index b33dc124e8..e11c49192c 100644
--- a/packages/api/CHANGELOG.md
+++ b/packages/api/CHANGELOG.md
@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+## [6.3.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@6.3.2...@thi.ng/api@6.3.3) (2019-08-21)
+
+**Note:** Version bump only for package @thi.ng/api
+
+
+
+
+
## [6.3.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@6.3.1...@thi.ng/api@6.3.2) (2019-07-31)
**Note:** Version bump only for package @thi.ng/api
diff --git a/packages/api/package.json b/packages/api/package.json
index 9c226a18bc..e589b0a116 100644
--- a/packages/api/package.json
+++ b/packages/api/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/api",
- "version": "6.3.2",
+ "version": "6.3.3",
"description": "Common, generic types & interfaces for thi.ng projects",
"module": "./index.js",
"main": "./lib/index.js",
@@ -33,7 +33,7 @@
"typescript": "^3.5.3"
},
"dependencies": {
- "@thi.ng/errors": "^1.1.2"
+ "@thi.ng/errors": "^1.2.0"
},
"keywords": [
"compare",
diff --git a/packages/arrays/CHANGELOG.md b/packages/arrays/CHANGELOG.md
index 14232cee7a..68115096f6 100644
--- a/packages/arrays/CHANGELOG.md
+++ b/packages/arrays/CHANGELOG.md
@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+## [0.2.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/arrays@0.2.3...@thi.ng/arrays@0.2.4) (2019-08-21)
+
+**Note:** Version bump only for package @thi.ng/arrays
+
+
+
+
+
## [0.2.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/arrays@0.2.2...@thi.ng/arrays@0.2.3) (2019-08-16)
**Note:** Version bump only for package @thi.ng/arrays
diff --git a/packages/arrays/package.json b/packages/arrays/package.json
index bc3c6060a0..b62160d6d2 100644
--- a/packages/arrays/package.json
+++ b/packages/arrays/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/arrays",
- "version": "0.2.3",
+ "version": "0.2.4",
"description": "Array / Arraylike utilities",
"module": "./index.js",
"main": "./lib/index.js",
@@ -33,12 +33,12 @@
"typescript": "^3.5.3"
},
"dependencies": {
- "@thi.ng/api": "^6.3.2",
+ "@thi.ng/api": "^6.3.3",
"@thi.ng/checks": "^2.3.0",
"@thi.ng/compare": "^1.0.9",
"@thi.ng/equiv": "^1.0.9",
- "@thi.ng/errors": "^1.1.2",
- "@thi.ng/random": "^1.1.10"
+ "@thi.ng/errors": "^1.2.0",
+ "@thi.ng/random": "^1.1.11"
},
"keywords": [
"arrays",
diff --git a/packages/associative/CHANGELOG.md b/packages/associative/CHANGELOG.md
index 8aedeaa30c..c4abc6a04c 100644
--- a/packages/associative/CHANGELOG.md
+++ b/packages/associative/CHANGELOG.md
@@ -3,6 +3,30 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+# [3.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/associative@2.4.3...@thi.ng/associative@3.0.0) (2019-08-21)
+
+
+### Code Refactoring
+
+* **associative:** update XXXMap.dissoc() signature to unify API ([632c57a](https://github.com/thi-ng/umbrella/commit/632c57a))
+
+
+### BREAKING CHANGES
+
+* **associative:** dissoc() method signature changed from varargs to `Iterable`
+
+Example:
+
+- previously: `HashMap.dissoc(1, 2, 3)`
+- now: `HashMap.dissoc([1, 2, 3])`
+
+This new signature is the same as used by `dissoc()` standalone fn and
+the `disj()` methods of the various Sets in this package.
+
+
+
+
+
## [2.4.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/associative@2.4.2...@thi.ng/associative@2.4.3) (2019-08-16)
**Note:** Version bump only for package @thi.ng/associative
diff --git a/packages/associative/package.json b/packages/associative/package.json
index 1c8dd1866d..d650cdc92b 100644
--- a/packages/associative/package.json
+++ b/packages/associative/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/associative",
- "version": "2.4.3",
+ "version": "3.0.0",
"description": "Alternative Set & Map data type implementations with customizable equality semantics & supporting operations",
"module": "./index.js",
"main": "./lib/index.js",
@@ -33,14 +33,14 @@
"typescript": "^3.5.3"
},
"dependencies": {
- "@thi.ng/api": "^6.3.2",
+ "@thi.ng/api": "^6.3.3",
"@thi.ng/binary": "^1.1.0",
"@thi.ng/checks": "^2.3.0",
"@thi.ng/compare": "^1.0.9",
- "@thi.ng/dcons": "^2.1.3",
+ "@thi.ng/dcons": "^2.1.4",
"@thi.ng/equiv": "^1.0.9",
- "@thi.ng/errors": "^1.1.2",
- "@thi.ng/transducers": "^5.4.3"
+ "@thi.ng/errors": "^1.2.0",
+ "@thi.ng/transducers": "^5.4.4"
},
"keywords": [
"data structures",
diff --git a/packages/associative/src/api.ts b/packages/associative/src/api.ts
index 1d2b9d2996..54ff5ea2fb 100644
--- a/packages/associative/src/api.ts
+++ b/packages/associative/src/api.ts
@@ -40,14 +40,20 @@ export interface EquivMapOpts extends EquivSetOpts {
keys: EquivSetConstructor;
}
+/**
+ * Hash function for key values of type K
+ */
+export type HashFn = Fn;
+
/**
* Creation options for HashMap class.
*/
export interface HashMapOpts {
/**
- * Function for computing key hash codes. MUST be supplied.
+ * Function for computing key hash codes. MUST be supplied. Only
+ * numeric hashes are supported.
*/
- hash: Fn;
+ hash: HashFn;
/**
* Optional key equality predicate. Default: thi.ng/equiv
*/
diff --git a/packages/associative/src/array-set.ts b/packages/associative/src/array-set.ts
index a908aec9be..f3ccb5e9d7 100644
--- a/packages/associative/src/array-set.ts
+++ b/packages/associative/src/array-set.ts
@@ -6,6 +6,9 @@ import {
} from "@thi.ng/api";
import { equiv } from "@thi.ng/equiv";
import { EquivSetOpts, IEquivSet } from "./api";
+import { dissoc } from "./dissoc";
+import { equivSet } from "./internal/equiv";
+import { into } from "./into";
interface ArraySetProps {
vals: T[];
@@ -14,6 +17,8 @@ interface ArraySetProps {
const __private = new WeakMap, ArraySetProps>();
+const __vals = (inst: ArraySet) => __private.get(inst)!.vals;
+
/**
* An alternative set implementation to the native ES6 Set type. Uses
* customizable equality/equivalence predicate and so is more useful
@@ -34,7 +39,7 @@ export class ArraySet extends Set implements IEquivSet {
}
*[Symbol.iterator](): IterableIterator {
- yield* __private.get(this)!.vals;
+ yield* __vals(this);
}
get [Symbol.species]() {
@@ -46,7 +51,7 @@ export class ArraySet extends Set implements IEquivSet {
}
get size(): number {
- return __private.get(this)!.vals.length;
+ return __vals(this).length;
}
copy(): ArraySet {
@@ -61,56 +66,53 @@ export class ArraySet extends Set implements IEquivSet {
}
clear() {
- __private.get(this)!.vals.length = 0;
+ __vals(this).length = 0;
}
first(): T | undefined {
if (this.size) {
- return __private.get(this)!.vals[0];
+ return __vals(this)[0];
}
}
- add(x: T) {
- !this.has(x) && __private.get(this)!.vals.push(x);
+ add(key: T) {
+ !this.has(key) && __vals(this).push(key);
return this;
}
- into(xs: Iterable) {
- for (let x of xs) {
- this.add(x);
- }
- return this;
+ into(keys: Iterable) {
+ return into(this, keys);
}
- has(x: T) {
- return this.get(x, SEMAPHORE) !== SEMAPHORE;
+ has(key: T) {
+ return this.get(key, SEMAPHORE) !== SEMAPHORE;
}
/**
* Returns the canonical value for `x`, if present. If the set
* contains no equivalent for `x`, returns `notFound`.
*
- * @param x
+ * @param key
* @param notFound
*/
- get(x: T, notFound?: T): T | undefined {
+ get(key: T, notFound?: T): T | undefined {
const $this = __private.get(this)!;
const eq = $this.equiv;
const vals = $this.vals;
- for (let i = vals.length - 1; i >= 0; i--) {
- if (eq(vals[i], x)) {
+ for (let i = vals.length; --i >= 0; ) {
+ if (eq(vals[i], key)) {
return vals[i];
}
}
return notFound;
}
- delete(x: T) {
+ delete(key: T) {
const $this = __private.get(this)!;
const eq = $this.equiv;
const vals = $this.vals;
- for (let i = vals.length - 1; i >= 0; i--) {
- if (eq(vals[i], x)) {
+ for (let i = vals.length; --i >= 0; ) {
+ if (eq(vals[i], key)) {
vals.splice(i, 1);
return true;
}
@@ -118,34 +120,16 @@ export class ArraySet extends Set implements IEquivSet {
return false;
}
- disj(xs: Iterable) {
- for (let x of xs) {
- this.delete(x);
- }
- return this;
+ disj(keys: Iterable) {
+ return dissoc(this, keys);
}
equiv(o: any) {
- if (this === o) {
- return true;
- }
- if (!(o instanceof Set)) {
- return false;
- }
- if (this.size !== o.size) {
- return false;
- }
- const vals = __private.get(this)!.vals;
- for (let i = vals.length; --i >= 0; ) {
- if (!o.has(vals[i])) {
- return false;
- }
- }
- return true;
+ return equivSet(this, o);
}
forEach(fn: Fn3, Readonly, Set, void>, thisArg?: any) {
- const vals = __private.get(this)!.vals;
+ const vals = __vals(this);
for (let i = vals.length; --i >= 0; ) {
const v = vals[i];
fn.call(thisArg, v, v, this);
@@ -153,17 +137,17 @@ export class ArraySet extends Set implements IEquivSet {
}
*entries(): IterableIterator> {
- for (let v of __private.get(this)!.vals) {
+ for (let v of __vals(this)) {
yield [v, v];
}
}
*keys(): IterableIterator {
- yield* __private.get(this)!.vals;
+ yield* __vals(this);
}
*values(): IterableIterator {
- yield* this.keys();
+ yield* __vals(this);
}
opts(): EquivSetOpts {
diff --git a/packages/associative/src/dissoc.ts b/packages/associative/src/dissoc.ts
new file mode 100644
index 0000000000..c55abf645c
--- /dev/null
+++ b/packages/associative/src/dissoc.ts
@@ -0,0 +1,20 @@
+import { IObjectOf } from "@thi.ng/api";
+
+export function dissoc(map: Map, keys: Iterable): Map;
+export function dissoc(set: Set, keys: Iterable): Set;
+export function dissoc(coll: Map | Set, keys: Iterable) {
+ for (let k of keys) {
+ coll.delete(k);
+ }
+ return coll;
+}
+
+export const dissocObj = (
+ obj: IObjectOf,
+ keys: Iterable
+) => {
+ for (let k of keys) {
+ delete obj[k];
+ }
+ return obj;
+};
diff --git a/packages/associative/src/equiv-map.ts b/packages/associative/src/equiv-map.ts
index 82bfdf6841..753027e765 100644
--- a/packages/associative/src/equiv-map.ts
+++ b/packages/associative/src/equiv-map.ts
@@ -10,6 +10,9 @@ import {
import { equiv } from "@thi.ng/equiv";
import { EquivMapOpts, IEquivSet } from "./api";
import { ArraySet } from "./array-set";
+import { dissoc } from "./dissoc";
+import { equivMap } from "./internal/equiv";
+import { into } from "./into";
interface MapProps {
keys: IEquivSet;
@@ -19,6 +22,8 @@ interface MapProps {
const __private = new WeakMap, MapProps>();
+const __map = (map: EquivMap) => __private.get(map)!.map;
+
export class EquivMap extends Map
implements
Iterable>,
@@ -110,21 +115,7 @@ export class EquivMap extends Map
}
equiv(o: any) {
- if (this === o) {
- return true;
- }
- if (!(o instanceof Map)) {
- return false;
- }
- if (this.size !== o.size) {
- return false;
- }
- for (let p of __private.get(this)!.map.entries()) {
- if (!equiv(o.get(p[0]), p[1])) {
- return false;
- }
- }
- return true;
+ return equivMap(this, o);
}
delete(key: K) {
@@ -138,15 +129,12 @@ export class EquivMap extends Map
return false;
}
- dissoc(...keys: K[]) {
- for (let k of keys) {
- this.delete(k);
- }
- return this;
+ dissoc(keys: Iterable) {
+ return dissoc(this, keys);
}
forEach(fn: Fn3, Map, void>, thisArg?: any) {
- for (let pair of __private.get(this)!.map) {
+ for (let pair of __map(this)) {
fn.call(thisArg, pair[1], pair[0], this);
}
}
@@ -177,22 +165,19 @@ export class EquivMap extends Map
}
into(pairs: Iterable>) {
- for (let p of pairs) {
- this.set(p[0], p[1]);
- }
- return this;
+ return into(this, pairs);
}
entries(): IterableIterator> {
- return __private.get(this)!.map.entries();
+ return __map(this).entries();
}
keys(): IterableIterator {
- return __private.get(this)!.map.keys();
+ return __map(this).keys();
}
values(): IterableIterator {
- return __private.get(this)!.map.values();
+ return __map(this).values();
}
opts(): EquivMapOpts {
diff --git a/packages/associative/src/hash-map.ts b/packages/associative/src/hash-map.ts
index 14bffc14a8..21a76a4b0e 100644
--- a/packages/associative/src/hash-map.ts
+++ b/packages/associative/src/hash-map.ts
@@ -10,6 +10,9 @@ import {
import { ceilPow2 } from "@thi.ng/binary";
import { equiv } from "@thi.ng/equiv";
import { HashMapOpts } from "./api";
+import { dissoc } from "./dissoc";
+import { equivMap } from "./internal/equiv";
+import { into } from "./into";
interface HashMapState {
hash: Fn;
@@ -22,12 +25,19 @@ interface HashMapState {
const __private = new WeakMap, HashMapState>();
+const __iterator = (map: HashMap, id: 0 | 1) =>
+ function*() {
+ for (let p of __private.get(map)!.bins) {
+ if (p) yield p[id];
+ }
+ };
+
const DEFAULT_CAP = 16;
/**
- * Configurable hash map implementation w/ ES6 Map API and using open
+ * Configurable hash map implementation w/ ES6 Map API. Uses open
* addressing / linear probing to resolve key collisions. Supports any
- * key types, via user supplied hash function.
+ * key types via mandatory user supplied hash function.
*
* See `HashMapOpts` for further configuration & behavior details.
*
@@ -87,16 +97,12 @@ export class HashMap extends Map
}
}
- *keys(): IterableIterator {
- for (let p of __private.get(this)!.bins) {
- if (p) yield p[0];
- }
+ keys(): IterableIterator {
+ return __iterator(this, 0)();
}
- *values(): IterableIterator {
- for (let p of __private.get(this)!.bins) {
- if (p) yield p[1];
- }
+ values(): IterableIterator {
+ return __iterator(this, 1)();
}
forEach(fn: Fn3, Map, void>, thisArg?: any) {
@@ -128,21 +134,7 @@ export class HashMap extends Map
}
equiv(o: any) {
- if (this === o) {
- return true;
- }
- if (!(o instanceof Map)) {
- return false;
- }
- if (this.size !== o.size) {
- return false;
- }
- for (let p of __private.get(this)!.bins) {
- if (p && !equiv(o.get(p[0]), p[1])) {
- return false;
- }
- }
- return true;
+ return equivMap(this, o);
}
has(key: K): boolean {
@@ -197,17 +189,11 @@ export class HashMap extends Map
}
into(pairs: Iterable>) {
- for (let p of pairs) {
- this.set(p[0], p[1]);
- }
- return this;
+ return into(this, pairs);
}
- dissoc(...keys: K[]) {
- for (let k of keys) {
- this.delete(k);
- }
- return this;
+ dissoc(keys: Iterable) {
+ return dissoc(this, keys);
}
opts(overrides?: Partial>): HashMapOpts {
diff --git a/packages/associative/src/index.ts b/packages/associative/src/index.ts
index 85c818f47c..bb46785349 100644
--- a/packages/associative/src/index.ts
+++ b/packages/associative/src/index.ts
@@ -1,6 +1,7 @@
export * from "./array-set";
export * from "./common-keys";
export * from "./difference";
+export * from "./dissoc";
export * from "./equiv-map";
export * from "./hash-map";
export * from "./indexed";
diff --git a/packages/associative/src/internal/equiv.ts b/packages/associative/src/internal/equiv.ts
new file mode 100644
index 0000000000..cd02679f61
--- /dev/null
+++ b/packages/associative/src/internal/equiv.ts
@@ -0,0 +1,31 @@
+import { equiv } from "@thi.ng/equiv";
+
+export const equivMap = (a: Map, b: any) => {
+ if (a === b) {
+ return true;
+ }
+ if (!(b instanceof Map) || a.size !== b.size) {
+ return false;
+ }
+ for (let p of a.entries()) {
+ if (!equiv(b.get(p[0]), p[1])) {
+ return false;
+ }
+ }
+ return true;
+};
+
+export const equivSet = (a: Set, b: any) => {
+ if (a === b) {
+ return true;
+ }
+ if (!(b instanceof Set) || a.size !== b.size) {
+ return false;
+ }
+ for (let k of a.keys()) {
+ if (!b.has(k)) {
+ return false;
+ }
+ }
+ return true;
+};
diff --git a/packages/associative/src/into.ts b/packages/associative/src/into.ts
index c7aac008b7..e68ae0d576 100644
--- a/packages/associative/src/into.ts
+++ b/packages/associative/src/into.ts
@@ -7,10 +7,8 @@ import { isMap } from "@thi.ng/checks";
* @param dest
* @param src
*/
-export function into(
- dest: Map,
- src: Iterable>
-): Map;
+// prettier-ignore
+export function into(dest: Map, src: Iterable>): Map;
export function into(dest: Set, src: Iterable): Set;
export function into(dest: Map | Set, src: Iterable) {
if (isMap(dest)) {
diff --git a/packages/associative/src/ll-set.ts b/packages/associative/src/ll-set.ts
index 7a4a418c7e..700db7bbab 100644
--- a/packages/associative/src/ll-set.ts
+++ b/packages/associative/src/ll-set.ts
@@ -7,6 +7,9 @@ import {
import { DCons } from "@thi.ng/dcons";
import { equiv } from "@thi.ng/equiv";
import { EquivSetOpts, IEquivSet } from "./api";
+import { dissoc } from "./dissoc";
+import { equivSet } from "./internal/equiv";
+import { into } from "./into";
interface SetProps {
vals: DCons;
@@ -15,6 +18,8 @@ interface SetProps {
const __private = new WeakMap, SetProps>();
+const __vals = (inst: LLSet) => __private.get(inst)!.vals;
+
/**
* Similar to `ArraySet`, this class is an alternative implementation of
* the native ES6 Set API using a @thi.ng/dcons linked list as backing
@@ -38,7 +43,7 @@ export class LLSet extends Set implements IEquivSet {
}
*[Symbol.iterator](): IterableIterator {
- yield* __private.get(this)!.vals;
+ yield* __vals(this);
}
get [Symbol.species]() {
@@ -50,7 +55,7 @@ export class LLSet extends Set implements IEquivSet {
}
get size(): number {
- return __private.get(this)!.vals.length;
+ return __vals(this).length;
}
copy() {
@@ -65,44 +70,41 @@ export class LLSet extends Set implements IEquivSet {
}
clear() {
- __private.get(this)!.vals.clear();
+ __vals(this).clear();
}
first(): T | undefined {
if (this.size) {
- return __private.get(this)!.vals.head!.value;
+ return __vals(this).head!.value;
}
}
- add(x: T) {
- !this.has(x) && __private.get(this)!.vals.push(x);
+ add(key: T) {
+ !this.has(key) && __vals(this).push(key);
return this;
}
- into(xs: Iterable) {
- for (let x of xs) {
- this.add(x);
- }
- return this;
+ into(keys: Iterable) {
+ return into(this, keys);
}
- has(x: T) {
- return this.get(x, SEMAPHORE) !== SEMAPHORE;
+ has(key: T) {
+ return this.get(key, SEMAPHORE) !== SEMAPHORE;
}
/**
- * Returns the canonical value for `x`, if present. If the set
- * contains no equivalent for `x`, returns `notFound`.
+ * Returns the canonical (stored) value for `key`, if present. If
+ * the set contains no equivalent for `key`, returns `notFound`.
*
- * @param x
+ * @param key
* @param notFound
*/
- get(x: T, notFound?: T): T | undefined {
+ get(key: T, notFound?: T): T | undefined {
const $this = __private.get(this)!;
const eq = $this.equiv;
let i = $this.vals.head;
while (i) {
- if (eq(i.value, x)) {
+ if (eq(i.value, key)) {
return i.value;
}
i = i.next;
@@ -110,12 +112,12 @@ export class LLSet extends Set implements IEquivSet {
return notFound;
}
- delete(x: T) {
+ delete(key: T) {
const $this = __private.get(this)!;
const eq = $this.equiv;
let i = $this.vals.head;
while (i) {
- if (eq(i.value, x)) {
+ if (eq(i.value, key)) {
$this.vals.splice(i, 1);
return true;
}
@@ -124,35 +126,16 @@ export class LLSet extends Set implements IEquivSet {
return false;
}
- disj(xs: Iterable) {
- for (let x of xs) {
- this.delete(x);
- }
- return this;
+ disj(keys: Iterable) {
+ return dissoc(this, keys);
}
equiv(o: any) {
- if (this === o) {
- return true;
- }
- if (!(o instanceof Set)) {
- return false;
- }
- if (this.size !== o.size) {
- return false;
- }
- let i = __private.get(this)!.vals.head;
- while (i) {
- if (!o.has(i.value)) {
- return false;
- }
- i = i.next;
- }
- return true;
+ return equivSet(this, o);
}
forEach(fn: Fn3, Readonly, Set, void>, thisArg?: any) {
- let i = __private.get(this)!.vals.head;
+ let i = __vals(this).head;
while (i) {
fn.call(thisArg, i.value, i.value, this);
i = i.next;
@@ -160,17 +143,17 @@ export class LLSet extends Set implements IEquivSet {
}
*entries(): IterableIterator> {
- for (let v of __private.get(this)!.vals) {
+ for (let v of __vals(this)) {
yield [v, v];
}
}
*keys(): IterableIterator {
- yield* __private.get(this)!.vals;
+ yield* __vals(this);
}
*values(): IterableIterator {
- yield* this.keys();
+ yield* __vals(this);
}
opts(): EquivSetOpts {
diff --git a/packages/associative/src/sorted-map.ts b/packages/associative/src/sorted-map.ts
index ffb88e8c04..b53513ba7b 100644
--- a/packages/associative/src/sorted-map.ts
+++ b/packages/associative/src/sorted-map.ts
@@ -6,9 +6,11 @@ import {
SEMAPHORE
} from "@thi.ng/api";
import { compare } from "@thi.ng/compare";
-import { equiv } from "@thi.ng/equiv";
import { isReduced, map, ReductionFn } from "@thi.ng/transducers";
import { SortedMapOpts } from "./api";
+import { dissoc } from "./dissoc";
+import { equivMap } from "./internal/equiv";
+import { into } from "./into";
interface SortedMapState {
head: Node;
@@ -161,10 +163,10 @@ export class SortedMap extends Map {
let x: IteratorResult>, y: IteratorResult>;
let c: number;
while (((x = i.next()), (y = j.next()), !x.done && !y.done)) {
- if ((c = compare(x.value[0], y.value[0])) !== 0) {
- return c;
- }
- if ((c = compare(x.value[1], y.value[1])) !== 0) {
+ if (
+ (c = compare(x.value[0], y.value[0])) !== 0 ||
+ (c = compare(x.value[1], y.value[1])) !== 0
+ ) {
return c;
}
}
@@ -172,21 +174,7 @@ export class SortedMap extends Map {
}
equiv(o: any) {
- if (this === o) {
- return true;
- }
- if (!(o instanceof Map)) {
- return false;
- }
- if (this.size !== o.size) {
- return false;
- }
- for (let p of this.entries()) {
- if (!equiv(o.get(p[0]), p[1])) {
- return false;
- }
- }
- return true;
+ return equivMap(this, o);
}
first(): Pair | undefined {
@@ -272,17 +260,11 @@ export class SortedMap extends Map {
}
into(pairs: Iterable>) {
- for (let p of pairs) {
- this.set(p[0], p[1]);
- }
- return this;
+ return into(this, pairs);
}
- dissoc(...keys: K[]) {
- for (let k of keys) {
- this.delete(k);
- }
- return this;
+ dissoc(keys: Iterable) {
+ return dissoc(this, keys);
}
forEach(fn: Fn3, Map, void>, thisArg?: any) {
diff --git a/packages/associative/src/sorted-set.ts b/packages/associative/src/sorted-set.ts
index aaca4c4fcb..5e45b78f24 100644
--- a/packages/associative/src/sorted-set.ts
+++ b/packages/associative/src/sorted-set.ts
@@ -2,6 +2,9 @@ import { Fn3, ICompare, Pair } from "@thi.ng/api";
import { compare } from "@thi.ng/compare";
import { IReducible, map, ReductionFn } from "@thi.ng/transducers";
import { IEquivSet, SortedSetOpts } from "./api";
+import { dissoc } from "./dissoc";
+import { equivSet } from "./internal/equiv";
+import { into } from "./into";
import { SortedMap } from "./sorted-map";
const __private = new WeakMap, SortedMap>();
@@ -87,21 +90,7 @@ export class SortedSet extends Set
}
equiv(o: any) {
- if (this === o) {
- return true;
- }
- if (!(o instanceof Set)) {
- return false;
- }
- if (this.size !== o.size) {
- return false;
- }
- for (let k of this.keys()) {
- if (!o.has(k)) {
- return false;
- }
- }
- return true;
+ return equivSet(this, o);
}
$reduce(rfn: ReductionFn, acc: any): any {
@@ -120,16 +109,13 @@ export class SortedSet extends Set
return __private.get(this)!.values(key, max);
}
- add(value: T) {
- __private.get(this)!.set(value, value);
+ add(key: T) {
+ __private.get(this)!.set(key, key);
return this;
}
- into(xs: Iterable) {
- for (let x of xs) {
- this.add(x);
- }
- return this;
+ into(keys: Iterable) {
+ return into(this, keys);
}
clear(): void {
@@ -141,15 +127,12 @@ export class SortedSet extends Set
return first ? first[0] : undefined;
}
- delete(value: T): boolean {
- return __private.get(this)!.delete(value);
+ delete(key: T): boolean {
+ return __private.get(this)!.delete(key);
}
- disj(xs: Iterable) {
- for (let x of xs) {
- this.delete(x);
- }
- return this;
+ disj(keys: Iterable) {
+ return dissoc(this, keys);
}
forEach(
@@ -161,12 +144,12 @@ export class SortedSet extends Set
}
}
- has(value: T): boolean {
- return __private.get(this)!.has(value);
+ has(key: T): boolean {
+ return __private.get(this)!.has(key);
}
- get(value: T, notFound?: T): T | undefined {
- return __private.get(this)!.get(value, notFound);
+ get(key: T, notFound?: T): T | undefined {
+ return __private.get(this)!.get(key, notFound);
}
opts(): SortedSetOpts {
diff --git a/packages/associative/src/sparse-set.ts b/packages/associative/src/sparse-set.ts
index af7e96e51b..5c93d8efca 100644
--- a/packages/associative/src/sparse-set.ts
+++ b/packages/associative/src/sparse-set.ts
@@ -7,6 +7,8 @@ import {
import { isNumber } from "@thi.ng/checks";
import { illegalArgs } from "@thi.ng/errors";
import { IEquivSet } from "./api";
+import { dissoc } from "./dissoc";
+import { into } from "./into";
interface SparseSetProps {
dense: UIntArray;
@@ -53,10 +55,7 @@ export abstract class ASparseSet extends Set
if (this === o) {
return true;
}
- if (!(o instanceof Set)) {
- return false;
- }
- if (this.size !== o.size) {
+ if (!(o instanceof Set) || this.size !== o.size) {
return false;
}
const $this = __private.get(this)!;
@@ -69,27 +68,27 @@ export abstract class ASparseSet extends Set
return true;
}
- add(k: number) {
+ add(key: number) {
const $this = __private.get(this)!;
const dense = $this.dense;
const sparse = $this.sparse;
const max = dense.length;
- const i = sparse[k];
+ const i = sparse[key];
const n = $this.n;
- if (k < max && n < max && !(i < n && dense[i] === k)) {
- dense[n] = k;
- sparse[k] = n;
+ if (key < max && n < max && !(i < n && dense[i] === key)) {
+ dense[n] = key;
+ sparse[key] = n;
$this.n++;
}
return this;
}
- delete(k: number) {
+ delete(key: number) {
const $this = __private.get(this)!;
const dense = $this.dense;
const sparse = $this.sparse;
- const i = sparse[k];
- if (i < $this.n && dense[i] === k) {
+ const i = sparse[key];
+ if (i < $this.n && dense[i] === key) {
const j = dense[--$this.n];
dense[i] = j;
sparse[j] = i;
@@ -98,14 +97,14 @@ export abstract class ASparseSet extends Set
return false;
}
- has(k: number): boolean {
+ has(key: number): boolean {
const $this = __private.get(this)!;
- const i = $this.sparse[k];
- return i < $this.n && $this.dense[i] === k;
+ const i = $this.sparse[key];
+ return i < $this.n && $this.dense[i] === key;
}
- get(k: number, notFound = -1) {
- return this.has(k) ? k : notFound;
+ get(key: number, notFound = -1) {
+ return this.has(key) ? key : notFound;
}
first() {
@@ -113,18 +112,12 @@ export abstract class ASparseSet extends Set
return $this.n ? $this.dense[0] : undefined;
}
- into(ks: Iterable) {
- for (let k of ks) {
- this.add(k);
- }
- return this;
+ into(keys: Iterable) {
+ return into(this, keys);
}
- disj(ks: Iterable) {
- for (let k of ks) {
- this.delete(k);
- }
- return this;
+ disj(keys: Iterable) {
+ return dissoc(this, keys);
}
forEach(fn: Fn3, void>, thisArg?: any) {
@@ -159,12 +152,13 @@ export abstract class ASparseSet extends Set
return this.keys();
}
- protected __copy(c: ASparseSet) {
+ protected __copyTo>(dest: S) {
const $this = __private.get(this)!;
- const $c = __private.get(c)!;
+ const $c = __private.get(dest)!;
$c.dense = $this.dense.slice();
$c.sparse = $this.sparse.slice();
$c.n = $this.n;
+ return dest;
}
}
@@ -189,9 +183,7 @@ export class SparseSet8 extends ASparseSet
}
copy() {
- const c = new SparseSet8(0);
- this.__copy(c);
- return c;
+ return this.__copyTo(new SparseSet8(0));
}
empty() {
@@ -220,9 +212,7 @@ export class SparseSet16 extends ASparseSet
}
copy() {
- const c = new SparseSet16(0);
- this.__copy(c);
- return c;
+ return this.__copyTo(new SparseSet16(0));
}
empty() {
@@ -251,9 +241,7 @@ export class SparseSet32 extends ASparseSet
}
copy() {
- const c = new SparseSet8(0);
- this.__copy(c);
- return c;
+ return this.__copyTo(new SparseSet32(0));
}
empty() {
diff --git a/packages/atom/CHANGELOG.md b/packages/atom/CHANGELOG.md
index 846d51d0ea..ae682b7639 100644
--- a/packages/atom/CHANGELOG.md
+++ b/packages/atom/CHANGELOG.md
@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+## [3.0.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/atom@3.0.3...@thi.ng/atom@3.0.4) (2019-08-21)
+
+**Note:** Version bump only for package @thi.ng/atom
+
+
+
+
+
## [3.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/atom@3.0.2...@thi.ng/atom@3.0.3) (2019-08-16)
**Note:** Version bump only for package @thi.ng/atom
diff --git a/packages/atom/package.json b/packages/atom/package.json
index e7d80537da..50c5869218 100644
--- a/packages/atom/package.json
+++ b/packages/atom/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/atom",
- "version": "3.0.3",
+ "version": "3.0.4",
"description": "Mutable wrappers for nested immutable values w/ optional undo/redo history",
"module": "./index.js",
"main": "./lib/index.js",
@@ -33,11 +33,11 @@
"typescript": "^3.5.3"
},
"dependencies": {
- "@thi.ng/api": "^6.3.2",
+ "@thi.ng/api": "^6.3.3",
"@thi.ng/checks": "^2.3.0",
"@thi.ng/equiv": "^1.0.9",
- "@thi.ng/errors": "^1.1.2",
- "@thi.ng/paths": "^2.1.3"
+ "@thi.ng/errors": "^1.2.0",
+ "@thi.ng/paths": "^2.1.4"
},
"keywords": [
"derived views",
diff --git a/packages/bencode/CHANGELOG.md b/packages/bencode/CHANGELOG.md
index e031538b1a..2b7e9139f3 100644
--- a/packages/bencode/CHANGELOG.md
+++ b/packages/bencode/CHANGELOG.md
@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+## [0.3.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/bencode@0.3.3...@thi.ng/bencode@0.3.4) (2019-08-21)
+
+**Note:** Version bump only for package @thi.ng/bencode
+
+
+
+
+
## [0.3.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/bencode@0.3.2...@thi.ng/bencode@0.3.3) (2019-08-16)
**Note:** Version bump only for package @thi.ng/bencode
diff --git a/packages/bencode/package.json b/packages/bencode/package.json
index 48b3427a52..eccb9052cf 100644
--- a/packages/bencode/package.json
+++ b/packages/bencode/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/bencode",
- "version": "0.3.3",
+ "version": "0.3.4",
"description": "Bencode binary encoder / decoder with optional UTF8 encoding",
"module": "./index.js",
"main": "./lib/index.js",
@@ -33,13 +33,13 @@
"typescript": "^3.5.3"
},
"dependencies": {
- "@thi.ng/api": "^6.3.2",
- "@thi.ng/arrays": "^0.2.3",
+ "@thi.ng/api": "^6.3.3",
+ "@thi.ng/arrays": "^0.2.4",
"@thi.ng/checks": "^2.3.0",
- "@thi.ng/defmulti": "^1.1.2",
- "@thi.ng/errors": "^1.1.2",
- "@thi.ng/transducers": "^5.4.3",
- "@thi.ng/transducers-binary": "^0.4.3"
+ "@thi.ng/defmulti": "^1.1.3",
+ "@thi.ng/errors": "^1.2.0",
+ "@thi.ng/transducers": "^5.4.4",
+ "@thi.ng/transducers-binary": "^0.4.4"
},
"keywords": [
"bencode",
diff --git a/packages/bitfield/CHANGELOG.md b/packages/bitfield/CHANGELOG.md
index 1f59075fda..14c85b771a 100644
--- a/packages/bitfield/CHANGELOG.md
+++ b/packages/bitfield/CHANGELOG.md
@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+## [0.1.12](https://github.com/thi-ng/umbrella/compare/@thi.ng/bitfield@0.1.11...@thi.ng/bitfield@0.1.12) (2019-08-21)
+
+**Note:** Version bump only for package @thi.ng/bitfield
+
+
+
+
+
## [0.1.11](https://github.com/thi-ng/umbrella/compare/@thi.ng/bitfield@0.1.10...@thi.ng/bitfield@0.1.11) (2019-07-31)
**Note:** Version bump only for package @thi.ng/bitfield
diff --git a/packages/bitfield/package.json b/packages/bitfield/package.json
index 9a11b37e52..8db8bda3d0 100644
--- a/packages/bitfield/package.json
+++ b/packages/bitfield/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/bitfield",
- "version": "0.1.11",
+ "version": "0.1.12",
"description": "1D / 2D bit field implementations",
"module": "./index.js",
"main": "./lib/index.js",
@@ -33,9 +33,9 @@
"typescript": "^3.5.3"
},
"dependencies": {
- "@thi.ng/api": "^6.3.2",
+ "@thi.ng/api": "^6.3.3",
"@thi.ng/binary": "^1.1.0",
- "@thi.ng/strings": "^1.2.2"
+ "@thi.ng/strings": "^1.2.3"
},
"keywords": [
"1D",
diff --git a/packages/bitstream/CHANGELOG.md b/packages/bitstream/CHANGELOG.md
index 2bda5d565e..5e4cfec3da 100644
--- a/packages/bitstream/CHANGELOG.md
+++ b/packages/bitstream/CHANGELOG.md
@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+## [1.1.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/bitstream@1.1.2...@thi.ng/bitstream@1.1.3) (2019-08-21)
+
+**Note:** Version bump only for package @thi.ng/bitstream
+
+
+
+
+
## [1.1.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/bitstream@1.1.1...@thi.ng/bitstream@1.1.2) (2019-07-31)
**Note:** Version bump only for package @thi.ng/bitstream
diff --git a/packages/bitstream/package.json b/packages/bitstream/package.json
index 6ba9a47329..d333af133c 100644
--- a/packages/bitstream/package.json
+++ b/packages/bitstream/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/bitstream",
- "version": "1.1.2",
+ "version": "1.1.3",
"description": "ES6 iterator based read/write bit streams & support for variable word widths",
"module": "./index.js",
"main": "./lib/index.js",
@@ -25,7 +25,7 @@
"pub": "yarn build:release && yarn publish --access public"
},
"dependencies": {
- "@thi.ng/errors": "^1.1.2"
+ "@thi.ng/errors": "^1.2.0"
},
"devDependencies": {
"@types/mocha": "^5.2.6",
diff --git a/packages/cache/CHANGELOG.md b/packages/cache/CHANGELOG.md
index 7e23849aeb..2208727a9d 100644
--- a/packages/cache/CHANGELOG.md
+++ b/packages/cache/CHANGELOG.md
@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+## [1.0.24](https://github.com/thi-ng/umbrella/compare/@thi.ng/cache@1.0.23...@thi.ng/cache@1.0.24) (2019-08-21)
+
+**Note:** Version bump only for package @thi.ng/cache
+
+
+
+
+
## [1.0.23](https://github.com/thi-ng/umbrella/compare/@thi.ng/cache@1.0.22...@thi.ng/cache@1.0.23) (2019-08-16)
**Note:** Version bump only for package @thi.ng/cache
diff --git a/packages/cache/package.json b/packages/cache/package.json
index 04d2725c64..8e3cb9368a 100644
--- a/packages/cache/package.json
+++ b/packages/cache/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/cache",
- "version": "1.0.23",
+ "version": "1.0.24",
"description": "In-memory cache implementations with ES6 Map-like API and different eviction strategies",
"module": "./index.js",
"main": "./lib/index.js",
@@ -33,9 +33,9 @@
"typescript": "^3.5.3"
},
"dependencies": {
- "@thi.ng/api": "^6.3.2",
- "@thi.ng/dcons": "^2.1.3",
- "@thi.ng/transducers": "^5.4.3"
+ "@thi.ng/api": "^6.3.3",
+ "@thi.ng/dcons": "^2.1.4",
+ "@thi.ng/transducers": "^5.4.4"
},
"keywords": [
"cache",
diff --git a/packages/cache/src/lru.ts b/packages/cache/src/lru.ts
index 1c42b537b6..1d1c479894 100644
--- a/packages/cache/src/lru.ts
+++ b/packages/cache/src/lru.ts
@@ -100,24 +100,8 @@ export class LRUCache implements ICache {
set(key: K, value: V) {
const size = this.opts.ksize(key) + this.opts.vsize(value);
const e = this.map.get(key);
- if (e) {
- this._size -= e.value.s;
- }
- this._size += size;
- if (this.ensureSize()) {
- if (e) {
- e.value.v = value;
- e.value.s = size;
- this.items.asTail(e);
- } else {
- this.items.push({
- k: key,
- v: value,
- s: size
- });
- this.map.set(key, this.items.tail!);
- }
- }
+ this._size += Math.max(0, size - (e ? e.value.s : 0));
+ this.ensureSize() && this.doSetEntry(e, key, value, size);
return value;
}
@@ -173,4 +157,20 @@ export class LRUCache implements ICache {
this.opts.release && this.opts.release(ee.k, ee.v);
this._size -= ee.s;
}
+
+ protected doSetEntry(
+ e: ConsCell> | undefined,
+ k: K,
+ v: V,
+ s: number
+ ) {
+ if (e) {
+ e.value.v = v;
+ e.value.s = s;
+ this.items.asTail(e);
+ } else {
+ this.items.push({ k, v, s });
+ this.map.set(k, this.items.tail!);
+ }
+ }
}
diff --git a/packages/cache/src/mru.ts b/packages/cache/src/mru.ts
index e00213cb33..47800530f3 100644
--- a/packages/cache/src/mru.ts
+++ b/packages/cache/src/mru.ts
@@ -14,32 +14,24 @@ export class MRUCache extends LRUCache {
return new MRUCache(null, this.opts);
}
- set(key: K, value: V) {
- const size = this.opts.ksize(key) + this.opts.vsize(value);
- const e = this.map.get(key);
- if (e) {
- this._size -= e.value.s;
- }
- this._size += size;
- if (this.ensureSize()) {
- if (e) {
- e.value.v = value;
- e.value.s = size;
- this.items.asHead(e);
- } else {
- this.items.cons({
- k: key,
- v: value,
- s: size
- });
- this.map.set(key, this.items.head!);
- }
- }
- return value;
- }
-
protected resetEntry(e: ConsCell>) {
this.items.asHead(e);
return e.value.v;
}
+
+ protected doSetEntry(
+ e: ConsCell> | undefined,
+ k: K,
+ v: V,
+ s: number
+ ) {
+ if (e) {
+ e.value.v = v;
+ e.value.s = s;
+ this.items.asHead(e);
+ } else {
+ this.items.cons({ k, v, s });
+ this.map.set(k, this.items.head!);
+ }
+ }
}
diff --git a/packages/cache/src/tlru.ts b/packages/cache/src/tlru.ts
index e21940b3ee..99794b6b67 100644
--- a/packages/cache/src/tlru.ts
+++ b/packages/cache/src/tlru.ts
@@ -56,10 +56,7 @@ export class TLRUCache extends LRUCache {
set(key: K, value: V, ttl = this.opts.ttl) {
const size = this.opts.ksize(key) + this.opts.vsize(value);
const e = this.map.get(key);
- if (e) {
- this._size -= e.value.s;
- }
- this._size += size;
+ this._size += Math.max(0, size - (e ? e.value.s : 0));
if (this.ensureSize()) {
const t = Date.now() + ttl;
if (e) {
diff --git a/packages/color/CHANGELOG.md b/packages/color/CHANGELOG.md
index 8f26d263e8..b3d95e02da 100644
--- a/packages/color/CHANGELOG.md
+++ b/packages/color/CHANGELOG.md
@@ -3,6 +3,25 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+# [1.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/color@1.0.3...@thi.ng/color@1.1.0) (2019-08-21)
+
+
+### Features
+
+* **color:** add resolveAsCSS(), update deps ([f96ac92](https://github.com/thi-ng/umbrella/commit/f96ac92))
+
+
+
+
+
+## [1.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/color@1.0.2...@thi.ng/color@1.0.3) (2019-08-17)
+
+**Note:** Version bump only for package @thi.ng/color
+
+
+
+
+
## [1.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/color@1.0.1...@thi.ng/color@1.0.2) (2019-08-16)
diff --git a/packages/color/package.json b/packages/color/package.json
index 0fabc587be..e6fdc3b553 100644
--- a/packages/color/package.json
+++ b/packages/color/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/color",
- "version": "1.0.2",
+ "version": "1.1.0",
"description": "Raw, array-based, color ops, conversions, opt. type wrappers, multi-color gradients",
"module": "./index.js",
"main": "./lib/index.js",
@@ -33,14 +33,15 @@
"typescript": "^3.5.3"
},
"dependencies": {
- "@thi.ng/api": "^6.3.2",
- "@thi.ng/compose": "^1.3.2",
- "@thi.ng/defmulti": "^1.1.2",
- "@thi.ng/errors": "^1.1.2",
+ "@thi.ng/api": "^6.3.3",
+ "@thi.ng/checks": "^2.3.0",
+ "@thi.ng/compose": "^1.3.3",
+ "@thi.ng/defmulti": "^1.1.3",
+ "@thi.ng/errors": "^1.2.0",
"@thi.ng/math": "^1.4.2",
- "@thi.ng/strings": "^1.2.2",
- "@thi.ng/transducers": "^5.4.3",
- "@thi.ng/vectors": "^3.1.1"
+ "@thi.ng/strings": "^1.2.3",
+ "@thi.ng/transducers": "^5.4.4",
+ "@thi.ng/vectors": "^3.3.0"
},
"keywords": [
"alpha",
diff --git a/packages/color/src/index.ts b/packages/color/src/index.ts
index ad0a393a15..5c9e6aacd9 100644
--- a/packages/color/src/index.ts
+++ b/packages/color/src/index.ts
@@ -13,6 +13,7 @@ export * from "./hue-rgba";
export * from "./int-css";
export * from "./int-rgba";
export * from "./kelvin-rgba";
+export * from "./resolve";
export * from "./rgba-css";
export * from "./rgba-hcva";
export * from "./rgba-hcya";
diff --git a/packages/color/src/resolve.ts b/packages/color/src/resolve.ts
new file mode 100644
index 0000000000..80fa1b4c7c
--- /dev/null
+++ b/packages/color/src/resolve.ts
@@ -0,0 +1,23 @@
+import { isArrayLike, isNumber } from "@thi.ng/checks";
+import { ColorMode, ReadonlyColor } from "./api";
+import { asCSS } from "./convert";
+
+/**
+ * Takes a color in one of the following formats and tries to convert it
+ * to a CSS string:
+ *
+ * - any IColor instance
+ * - raw RGBA vector
+ * - number ((A)RGB int)
+ * - string (unchanged)
+ *
+ * @param col
+ */
+export const resolveAsCSS = (col: any) =>
+ isArrayLike(col)
+ ? isNumber((col).mode)
+ ? asCSS(col)
+ : asCSS(col, ColorMode.RGBA)
+ : isNumber(col)
+ ? asCSS(col, ColorMode.INT32)
+ : col;
diff --git a/packages/compose/CHANGELOG.md b/packages/compose/CHANGELOG.md
index 6fd888eee3..d691cdb82b 100644
--- a/packages/compose/CHANGELOG.md
+++ b/packages/compose/CHANGELOG.md
@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+## [1.3.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/compose@1.3.2...@thi.ng/compose@1.3.3) (2019-08-21)
+
+**Note:** Version bump only for package @thi.ng/compose
+
+
+
+
+
## [1.3.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/compose@1.3.1...@thi.ng/compose@1.3.2) (2019-07-31)
**Note:** Version bump only for package @thi.ng/compose
diff --git a/packages/compose/package.json b/packages/compose/package.json
index 63cf3c8af4..b5d1258b5a 100644
--- a/packages/compose/package.json
+++ b/packages/compose/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/compose",
- "version": "1.3.2",
+ "version": "1.3.3",
"description": "Arity-optimized functional composition helpers",
"module": "./index.js",
"main": "./lib/index.js",
@@ -33,8 +33,8 @@
"typescript": "^3.5.3"
},
"dependencies": {
- "@thi.ng/api": "^6.3.2",
- "@thi.ng/errors": "^1.1.2"
+ "@thi.ng/api": "^6.3.3",
+ "@thi.ng/errors": "^1.2.0"
},
"keywords": [
"composition",
diff --git a/packages/csp/CHANGELOG.md b/packages/csp/CHANGELOG.md
index bbf2147c16..e779c6bad1 100644
--- a/packages/csp/CHANGELOG.md
+++ b/packages/csp/CHANGELOG.md
@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+## [1.1.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/csp@1.1.3...@thi.ng/csp@1.1.4) (2019-08-21)
+
+**Note:** Version bump only for package @thi.ng/csp
+
+
+
+
+
## [1.1.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/csp@1.1.2...@thi.ng/csp@1.1.3) (2019-08-16)
**Note:** Version bump only for package @thi.ng/csp
diff --git a/packages/csp/package.json b/packages/csp/package.json
index a5c98c2d95..1f639e8b6b 100644
--- a/packages/csp/package.json
+++ b/packages/csp/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/csp",
- "version": "1.1.3",
+ "version": "1.1.4",
"description": "ES6 promise based CSP implementation",
"module": "./index.js",
"main": "./lib/index.js",
@@ -37,12 +37,12 @@
"typescript": "^3.5.3"
},
"dependencies": {
- "@thi.ng/api": "^6.3.2",
- "@thi.ng/arrays": "^0.2.3",
+ "@thi.ng/api": "^6.3.3",
+ "@thi.ng/arrays": "^0.2.4",
"@thi.ng/checks": "^2.3.0",
- "@thi.ng/dcons": "^2.1.3",
- "@thi.ng/errors": "^1.1.2",
- "@thi.ng/transducers": "^5.4.3"
+ "@thi.ng/dcons": "^2.1.4",
+ "@thi.ng/errors": "^1.2.0",
+ "@thi.ng/transducers": "^5.4.4"
},
"keywords": [
"async",
diff --git a/packages/dcons/CHANGELOG.md b/packages/dcons/CHANGELOG.md
index 0ac855f943..b54a90e2da 100644
--- a/packages/dcons/CHANGELOG.md
+++ b/packages/dcons/CHANGELOG.md
@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+## [2.1.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/dcons@2.1.3...@thi.ng/dcons@2.1.4) (2019-08-21)
+
+**Note:** Version bump only for package @thi.ng/dcons
+
+
+
+
+
## [2.1.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/dcons@2.1.2...@thi.ng/dcons@2.1.3) (2019-08-16)
**Note:** Version bump only for package @thi.ng/dcons
diff --git a/packages/dcons/package.json b/packages/dcons/package.json
index 9321e07780..a57577c4f3 100644
--- a/packages/dcons/package.json
+++ b/packages/dcons/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/dcons",
- "version": "2.1.3",
+ "version": "2.1.4",
"description": "Comprehensive doubly linked list structure w/ iterator support",
"module": "./index.js",
"main": "./lib/index.js",
@@ -33,12 +33,12 @@
"typescript": "^3.5.3"
},
"dependencies": {
- "@thi.ng/api": "^6.3.2",
+ "@thi.ng/api": "^6.3.3",
"@thi.ng/checks": "^2.3.0",
"@thi.ng/compare": "^1.0.9",
"@thi.ng/equiv": "^1.0.9",
- "@thi.ng/errors": "^1.1.2",
- "@thi.ng/transducers": "^5.4.3"
+ "@thi.ng/errors": "^1.2.0",
+ "@thi.ng/transducers": "^5.4.4"
},
"keywords": [
"datastructure",
diff --git a/packages/defmulti/CHANGELOG.md b/packages/defmulti/CHANGELOG.md
index e73de684cd..071ea06608 100644
--- a/packages/defmulti/CHANGELOG.md
+++ b/packages/defmulti/CHANGELOG.md
@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+## [1.1.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/defmulti@1.1.2...@thi.ng/defmulti@1.1.3) (2019-08-21)
+
+**Note:** Version bump only for package @thi.ng/defmulti
+
+
+
+
+
## [1.1.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/defmulti@1.1.1...@thi.ng/defmulti@1.1.2) (2019-07-31)
**Note:** Version bump only for package @thi.ng/defmulti
diff --git a/packages/defmulti/package.json b/packages/defmulti/package.json
index b9c630d6a1..d1444d8b92 100644
--- a/packages/defmulti/package.json
+++ b/packages/defmulti/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/defmulti",
- "version": "1.1.2",
+ "version": "1.1.3",
"description": "Dynamically extensible multiple dispatch via user supplied dispatch function.",
"module": "./index.js",
"main": "./lib/index.js",
@@ -33,8 +33,8 @@
"typescript": "^3.5.3"
},
"dependencies": {
- "@thi.ng/api": "^6.3.2",
- "@thi.ng/errors": "^1.1.2"
+ "@thi.ng/api": "^6.3.3",
+ "@thi.ng/errors": "^1.2.0"
},
"keywords": [
"ES6",
diff --git a/packages/defmulti/src/api.ts b/packages/defmulti/src/api.ts
new file mode 100644
index 0000000000..75e504b538
--- /dev/null
+++ b/packages/defmulti/src/api.ts
@@ -0,0 +1,305 @@
+import {
+ Fn,
+ Fn2,
+ Fn3,
+ Fn4,
+ Fn5,
+ Fn6,
+ Fn7,
+ Fn8,
+ FnAny,
+ IObjectOf
+} from "@thi.ng/api";
+
+export const DEFAULT: unique symbol = Symbol();
+
+export type DispatchFn = FnAny;
+export type DispatchFn1 = Fn;
+export type DispatchFn1O = (a: A, b?: B) => PropertyKey;
+export type DispatchFn2 = Fn2;
+export type DispatchFn2O = (a: A, b: B, c?: C) => PropertyKey;
+export type DispatchFn3 = Fn3;
+export type DispatchFn3O = (a: A, b: B, c: C, d?: D) => PropertyKey;
+export type DispatchFn4 = Fn4;
+export type DispatchFn4O = (
+ a: A,
+ b: B,
+ c: C,
+ d: D,
+ e?: E
+) => PropertyKey;
+export type DispatchFn5 = Fn5;
+export type DispatchFn5O = (
+ a: A,
+ b: B,
+ c: C,
+ d: D,
+ e: E,
+ f?: F
+) => PropertyKey;
+export type DispatchFn6 = Fn6;
+export type DispatchFn6O = (
+ a: A,
+ b: B,
+ c: C,
+ d: D,
+ e: E,
+ f: F,
+ g?: G
+) => PropertyKey;
+export type DispatchFn7 = Fn7<
+ A,
+ B,
+ C,
+ D,
+ E,
+ F,
+ G,
+ PropertyKey
+>;
+export type DispatchFn7O = (
+ a: A,
+ b: B,
+ c: C,
+ d: D,
+ e: E,
+ f: F,
+ g: G,
+ h?: H
+) => PropertyKey;
+export type DispatchFn8 = Fn8<
+ A,
+ B,
+ C,
+ D,
+ E,
+ F,
+ G,
+ H,
+ PropertyKey
+>;
+export type DispatchFn8O = (
+ a: A,
+ b: B,
+ c: C,
+ d: D,
+ e: E,
+ f: F,
+ g: G,
+ h: H,
+ i?: I
+) => PropertyKey;
+
+export type Implementation = FnAny;
+export type Implementation1 = Fn;
+export type Implementation1O = (a: A, b?: B) => T;
+export type Implementation2 = Fn2;
+export type Implementation2O = (a: A, b: B, c?: C) => T;
+export type Implementation3 = Fn3;
+export type Implementation3O = (a: A, b: B, c: C, d?: D) => T;
+export type Implementation4 = Fn4;
+export type Implementation4O = (
+ a: A,
+ b: B,
+ c: C,
+ d: D,
+ e?: E
+) => T;
+export type Implementation5 = Fn5;
+export type Implementation5O = (
+ a: A,
+ b: B,
+ c: C,
+ d: D,
+ e: E,
+ f?: F
+) => T;
+export type Implementation6 = Fn6;
+export type Implementation6O = (
+ a: A,
+ b: B,
+ c: C,
+ d: D,
+ e: E,
+ f: F,
+ g?: G
+) => T;
+export type Implementation7 = Fn7<
+ A,
+ B,
+ C,
+ D,
+ E,
+ F,
+ G,
+ T
+>;
+export type Implementation7O = (
+ a: A,
+ b: B,
+ c: C,
+ d: D,
+ e: E,
+ f: F,
+ g: G,
+ h?: H
+) => T;
+export type Implementation8 = Fn8<
+ A,
+ B,
+ C,
+ D,
+ E,
+ F,
+ G,
+ H,
+ T
+>;
+export type Implementation8O = (
+ a: A,
+ b: B,
+ c: C,
+ d: D,
+ e: E,
+ f: F,
+ g: G,
+ h: H,
+ i?: I
+) => T;
+
+export interface MultiFnBase {
+ /**
+ * Registers implementation for dispatch value `id`. Returns true,
+ * if successful. Returns false if an implementation already exists
+ * (and does nothing in this case).
+ *
+ * @param id
+ * @param impl
+ */
+ add(id: PropertyKey, impl: I): boolean;
+ /**
+ * Takes an object of dispatch values and their implementations and
+ * calls `.add()` for each KV pair. Returns true, if all impls were
+ * added successfully. Note: Only numbers or strings are accepted as
+ * dispatch values here.
+ *
+ * @param impls
+ */
+ addAll(impls: IObjectOf): boolean;
+ /**
+ * Removes implementation for dispatch value `id`. Returns true, if
+ * successful.
+ *
+ * @param id
+ */
+ remove(id: PropertyKey): boolean;
+ /**
+ * Returns true, if the function is callable (has a valid
+ * implementation) for given arguments.
+ *
+ * @param args
+ */
+ callable(...args: any[]): boolean;
+ /**
+ * Returns a set of all registered dispatch values.
+ */
+ impls(): Set;
+ /**
+ * Updates dispatch hierarchy by declaring dispatch value `id` to
+ * delegate to `parent`'s implementation. I.e. in terms of dispatch
+ * logic, `id` is considered the same as `parent.
+ *
+ * @param id
+ * @param parent
+ */
+ isa(id: PropertyKey, parent: PropertyKey): boolean;
+ /**
+ * Returns all known dispatch relationships. This is an object with
+ * all registered dispatch values as keys, each with a set of parent
+ * dispatch values.
+ */
+ rels(): IObjectOf>;
+ /**
+ * Returns a set of immediate parent dispatch values for given
+ * dispatch value `id`.
+ *
+ * @param id
+ */
+ parents(id: PropertyKey): Set;
+ /**
+ * Similar to `parents()`, but includes all transitive parent dispatch
+ * values for given dispatch value `id`.
+ * @param id
+ */
+ ancestors(id: PropertyKey): Set