diff --git a/README.md b/README.md
index 4f425d0c69..ca30b0bfd5 100644
--- a/README.md
+++ b/README.md
@@ -4,9 +4,16 @@
[![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)
-Mono-repository for thi.ng TypeScript/ES6 projects, a collection of largely
-data / transformation oriented packages and building blocks for reactive
-applications, dataflow graphs, components (not just UI related).
+Mono-repository for thi.ng TypeScript/ES6 projects, a collection of
+largely data transformation oriented packages and building blocks for
+functional programming, reactive applications, dataflow graphs /
+pipelines, components (not just UI related), all with a keen eye on
+simplicity & minimalism without sacrificing flexibility.
+
+**This project is NOT a framework**, provides no one-size-fits-all
+approach and instead encourages a mix & match philosophy for various key
+aspects of (web) application design. Most customization points only
+expect certain interfaces rather than concrete implementations.
All / most packages:
@@ -18,6 +25,7 @@ All / most packages:
single function / class per file to help w/ tree shaking
- provide re-exports of all their publics for full library imports
- have either none or only @thi.ng internal runtime dependencies
+- have been used in production
- declare public interfaces, enums & types in an `src/api.ts` file
(larger packages only)
- auto-generated online documentation at [docs.thi.ng](http://docs.thi.ng)
@@ -56,6 +64,7 @@ packages) in the [examples](./examples) directory.
| [`@thi.ng/iges`](./packages/iges) | [![version](https://img.shields.io/npm/v/@thi.ng/iges.svg)](https://www.npmjs.com/package/@thi.ng/iges) | [changelog](./packages/iges/CHANGELOG.md) | IGES format geometry serialization |
| [`@thi.ng/interceptors`](./packages/interceptors) | [![version](https://img.shields.io/npm/v/@thi.ng/interceptors.svg)](https://www.npmjs.com/package/@thi.ng/interceptors) | [changelog](./packages/interceptors/CHANGELOG.md) | Composable event handlers & processor |
| [`@thi.ng/iterators`](./packages/iterators) | [![version](https://img.shields.io/npm/v/@thi.ng/iterators.svg)](https://www.npmjs.com/package/@thi.ng/iterators) | [changelog](./packages/iterators/CHANGELOG.md) | ES6 generators / iterators |
+| [`@thi.ng/memoize`](./packages/memoize) | [![version](https://img.shields.io/npm/v/@thi.ng/memoize.svg)](https://www.npmjs.com/package/@thi.ng/memoize) | [changelog](./packages/memoize/CHANGELOG.md) | Function memoization w/ customizable caching |
| [`@thi.ng/paths`](./packages/paths) | [![version](https://img.shields.io/npm/v/@thi.ng/paths.svg)](https://www.npmjs.com/package/@thi.ng/paths) | [changelog](./packages/paths/CHANGELOG.md) | Immutable nested object accessors |
| [`@thi.ng/pointfree`](./packages/pointfree) | [![version](https://img.shields.io/npm/v/@thi.ng/pointfree.svg)](https://www.npmjs.com/package/@thi.ng/pointfree) | [changelog](./packages/pointfree/CHANGELOG.md) | stack-based DSL & functional composition |
| [`@thi.ng/pointfree-lang`](./packages/pointfree-lang) | [![version](https://img.shields.io/npm/v/@thi.ng/pointfree-lang.svg)](https://www.npmjs.com/package/@thi.ng/pointfree-lang) | [changelog](./packages/pointfree-lang/CHANGELOG.md) | Forth-like syntax layer for @thi.ng/pointfree |
@@ -71,6 +80,7 @@ packages) in the [examples](./examples) directory.
| [`@thi.ng/rstream-log`](./packages/rstream-log) | [![version](https://img.shields.io/npm/v/@thi.ng/rstream-log.svg)](https://www.npmjs.com/package/@thi.ng/rstream-log) | [changelog](./packages/rstream-log/CHANGELOG.md) | Hierarchical structured data logging |
| [`@thi.ng/rstream-query`](./packages/rstream-query) | [![version](https://img.shields.io/npm/v/@thi.ng/rstream-query.svg)](https://www.npmjs.com/package/@thi.ng/rstream-query) | [changelog](./packages/rstream-query/CHANGELOG.md) | Triple store & query engine |
| [`@thi.ng/sax`](./packages/sax) | [![version](https://img.shields.io/npm/v/@thi.ng/sax.svg)](https://www.npmjs.com/package/@thi.ng/sax) | [changelog](./packages/sax/CHANGELOG.md) | SAX-like XML parser / transducer |
+| [`@thi.ng/strings`](./packages/strings) | [![version](https://img.shields.io/npm/v/@thi.ng/strings.svg)](https://www.npmjs.com/package/@thi.ng/strings) | [changelog](./packages/strings/CHANGELOG.md) | Higher-order string formatting utils |
| [`@thi.ng/transducers`](./packages/transducers) | [![version](https://img.shields.io/npm/v/@thi.ng/transducers.svg)](https://www.npmjs.com/package/@thi.ng/transducers) | [changelog](./packages/transducers/CHANGELOG.md) | Composable data transformations |
| [`@thi.ng/transducers-fsm`](./packages/transducers-fsm) | [![version](https://img.shields.io/npm/v/@thi.ng/transducers-fsm.svg)](https://www.npmjs.com/package/@thi.ng/transducers-fsm) | [changelog](./packages/transducers-fsm/CHANGELOG.md) | Finite State Machine |
| [`@thi.ng/transducers-hdom`](./packages/transducers-hdom) | [![version](https://img.shields.io/npm/v/@thi.ng/transducers-hdom.svg)](https://www.npmjs.com/package/@thi.ng/transducers-hdom) | [changelog](./packages/transducers-hdom/CHANGELOG.md) | Transducer based hdom UI updates |
diff --git a/examples/README.md b/examples/README.md
index 9df199b81d..cf3c9dcfbc 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -25,5 +25,6 @@ If you want to [contribute](../CONTRIBUTING.md) an example, please get in touch
| 17 | [svg-particles](./svg-particles) | hdom SVG generation / animation | hdom, transducers | basic |
| 18 | [svg-waveform](./svg-waveform) | hdom SVG generation / undo history | atom, hdom, hiccup-svg, interceptors, iterators | intermediate |
| 19 | [todo-list](./todo-list) | Canonical Todo list with undo/redo | atom, hdom, transducers | intermediate |
-| 20 | [triple-query](./triple-query) | Triple store query results & sortable table | atom, hdom, hdom-components, rstream-query, transducers | intermediate |
-| 21 | [webgl](./webgl) | Canvas component handling | hdom, hdom-components | basic |
+| 20 | [transducers-hdom](./transducers-hdom) | Transducer & rstream based hdom UI updates | hdom, rstream, transducers-hdom | basic |
+| 21 | [triple-query](./triple-query) | Triple store query results & sortable table | atom, hdom, hdom-components, rstream-query, transducers | intermediate |
+| 22 | [webgl](./webgl) | Canvas component handling | hdom, hdom-components | basic |
diff --git a/examples/crypto-chart/package.json b/examples/crypto-chart/package.json
index 9b0b1996ef..c5e36c6c07 100644
--- a/examples/crypto-chart/package.json
+++ b/examples/crypto-chart/package.json
@@ -22,6 +22,7 @@
"@thi.ng/hiccup-svg": "latest",
"@thi.ng/resolve-map": "latest",
"@thi.ng/rstream": "latest",
+ "@thi.ng/strings": "latest",
"@thi.ng/transducers": "latest",
"@thi.ng/transducers-stats": "latest"
}
diff --git a/examples/crypto-chart/src/index.ts b/examples/crypto-chart/src/index.ts
index bf52bc751c..73a0852cbe 100644
--- a/examples/crypto-chart/src/index.ts
+++ b/examples/crypto-chart/src/index.ts
@@ -15,6 +15,7 @@ import { stream } from "@thi.ng/rstream/stream";
import { sync } from "@thi.ng/rstream/stream-sync";
import { resolve as resolvePromise } from "@thi.ng/rstream/subs/resolve";
import { trace } from "@thi.ng/rstream/subs/trace";
+import { padLeft } from "@thi.ng/strings/pad-left";
import { ema } from "@thi.ng/transducers-stats/ema";
import { hma } from "@thi.ng/transducers-stats/hma";
import { sma } from "@thi.ng/transducers-stats/sma";
@@ -160,11 +161,7 @@ const API_URL = (market, symbol, period) =>
// helper functions
const clamp = (x: number, min: number, max: number) => x < min ? min : x > max ? max : x;
const fit = (x, a, b, c, d) => c + (d - c) * clamp((x - a) / (b - a), 0, 1);
-const padl = (n: number, ch: string) => {
- const buf = new Array(n).fill(ch).join("");
- return (x: any) => (x = x.toString(), x.length < n ? buf.substr(x.length) + x : x);
-};
-const Z2 = padl(2, "0");
+const Z2 = padLeft(2, "0");
const emitOnStream = (stream) => (e) => stream.next(e.target.value);
diff --git a/examples/hdom-benchmark/package.json b/examples/hdom-benchmark/package.json
index 50a0ab2e65..144b2c1404 100644
--- a/examples/hdom-benchmark/package.json
+++ b/examples/hdom-benchmark/package.json
@@ -20,6 +20,7 @@
"@thi.ng/hdom": "latest",
"@thi.ng/hdom-components": "latest",
"@thi.ng/rstream": "latest",
+ "@thi.ng/strings": "latest",
"@thi.ng/transducers": "latest"
}
}
\ No newline at end of file
diff --git a/examples/hdom-benchmark/src/index.ts b/examples/hdom-benchmark/src/index.ts
index 45fdf5b31c..ea665bc1d5 100644
--- a/examples/hdom-benchmark/src/index.ts
+++ b/examples/hdom-benchmark/src/index.ts
@@ -2,8 +2,8 @@ import { start } from "@thi.ng/hdom";
import { dropdown } from "@thi.ng/hdom-components/dropdown";
import { fromRAF } from "@thi.ng/rstream/from/raf";
import { Stream } from "@thi.ng/rstream/stream";
+import { radix } from "@thi.ng/strings/radix";
import { comp } from "@thi.ng/transducers/func/comp";
-import { hex } from "@thi.ng/transducers/func/hex";
import { range } from "@thi.ng/transducers/iter/range";
import { iterator } from "@thi.ng/transducers/iterator";
import { benchmark } from "@thi.ng/transducers/xform/benchmark";
@@ -13,8 +13,8 @@ import { movingAverage } from "@thi.ng/transducers/xform/moving-average";
import { partition } from "@thi.ng/transducers/xform/partition";
// pre-defined hex formatters
-const hex4 = hex(4);
-const hex6 = hex(6);
+const hex4 = radix(16, 4);
+const hex6 = radix(16, 6);
/**
* Single box component. Uses given id to switch between using `div` or
diff --git a/examples/svg-particles/package.json b/examples/svg-particles/package.json
index a6db945db8..f7e8302cf5 100644
--- a/examples/svg-particles/package.json
+++ b/examples/svg-particles/package.json
@@ -17,6 +17,7 @@
},
"dependencies": {
"@thi.ng/hdom": "latest",
+ "@thi.ng/strings": "latest",
"@thi.ng/transducers": "latest"
}
}
\ No newline at end of file
diff --git a/examples/svg-particles/src/index.ts b/examples/svg-particles/src/index.ts
index f0cb42aa06..98b644f188 100644
--- a/examples/svg-particles/src/index.ts
+++ b/examples/svg-particles/src/index.ts
@@ -1,10 +1,10 @@
import { start } from "@thi.ng/hdom";
-import { hex } from "@thi.ng/transducers/func/hex";
+import { radix } from "@thi.ng/strings/radix";
import { repeatedly } from "@thi.ng/transducers/iter/repeatedly";
const width = window.innerWidth;
const height = window.innerHeight;
-const hex6 = hex(6);
+const hex6 = radix(16, 6);
const updateParticle = (p, v) => {
let x = p.cx + v[0];
diff --git a/packages/csp/CHANGELOG.md b/packages/csp/CHANGELOG.md
index 05830dca7f..174cf47b51 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.
+
+## [0.3.55](https://github.com/thi-ng/umbrella/compare/@thi.ng/csp@0.3.54...@thi.ng/csp@0.3.55) (2018-08-08)
+
+
+
+
+**Note:** Version bump only for package @thi.ng/csp
+
## [0.3.54](https://github.com/thi-ng/umbrella/compare/@thi.ng/csp@0.3.53...@thi.ng/csp@0.3.54) (2018-08-02)
diff --git a/packages/csp/package.json b/packages/csp/package.json
index 58db97d3a2..0c5ca6b148 100644
--- a/packages/csp/package.json
+++ b/packages/csp/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/csp",
- "version": "0.3.54",
+ "version": "0.3.55",
"description": "ES6 promise based CSP implementation",
"main": "./index.js",
"typings": "./index.d.ts",
@@ -36,7 +36,7 @@
"@thi.ng/checks": "^1.5.7",
"@thi.ng/dcons": "^1.0.7",
"@thi.ng/errors": "^0.1.6",
- "@thi.ng/transducers": "^1.15.0"
+ "@thi.ng/transducers": "^1.16.0"
},
"keywords": [
"async",
diff --git a/packages/hiccup-css/CHANGELOG.md b/packages/hiccup-css/CHANGELOG.md
index 28e58a8f4c..572573b5f1 100644
--- a/packages/hiccup-css/CHANGELOG.md
+++ b/packages/hiccup-css/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.14](https://github.com/thi-ng/umbrella/compare/@thi.ng/hiccup-css@0.2.13...@thi.ng/hiccup-css@0.2.14) (2018-08-08)
+
+
+
+
+**Note:** Version bump only for package @thi.ng/hiccup-css
+
## [0.2.13](https://github.com/thi-ng/umbrella/compare/@thi.ng/hiccup-css@0.2.12...@thi.ng/hiccup-css@0.2.13) (2018-08-02)
diff --git a/packages/hiccup-css/package.json b/packages/hiccup-css/package.json
index d3363026a6..0d38b59268 100644
--- a/packages/hiccup-css/package.json
+++ b/packages/hiccup-css/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/hiccup-css",
- "version": "0.2.13",
+ "version": "0.2.14",
"description": "CSS from nested JS data structures",
"main": "./index.js",
"typings": "./index.d.ts",
@@ -31,7 +31,7 @@
"@thi.ng/api": "^4.0.6",
"@thi.ng/checks": "^1.5.7",
"@thi.ng/errors": "^0.1.6",
- "@thi.ng/transducers": "^1.15.0"
+ "@thi.ng/transducers": "^1.16.0"
},
"keywords": [
"clojure",
diff --git a/packages/iges/CHANGELOG.md b/packages/iges/CHANGELOG.md
index 6c11cd643f..814ea35ad3 100644
--- a/packages/iges/CHANGELOG.md
+++ b/packages/iges/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.
+
+## [0.2.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/iges@0.2.3...@thi.ng/iges@0.2.4) (2018-08-08)
+
+
+
+
+**Note:** Version bump only for package @thi.ng/iges
+
+
+## [0.2.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/iges@0.2.2...@thi.ng/iges@0.2.3) (2018-08-08)
+
+
+
+
+**Note:** Version bump only for package @thi.ng/iges
+
+
+## [0.2.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/iges@0.2.1...@thi.ng/iges@0.2.2) (2018-08-08)
+
+
+
+
+**Note:** Version bump only for package @thi.ng/iges
+
## [0.2.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/iges@0.2.0...@thi.ng/iges@0.2.1) (2018-08-02)
diff --git a/packages/iges/package.json b/packages/iges/package.json
index 248cd67e45..f415d313c1 100644
--- a/packages/iges/package.json
+++ b/packages/iges/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/iges",
- "version": "0.2.1",
+ "version": "0.2.4",
"description": "IGES 5.3 serializer for (currently only) polygonal geometry, both open & closed",
"main": "./index.js",
"typings": "./index.d.ts",
@@ -30,7 +30,8 @@
"dependencies": {
"@thi.ng/api": "^4.0.6",
"@thi.ng/defmulti": "^0.3.7",
- "@thi.ng/transducers": "^1.15.0"
+ "@thi.ng/strings": "^0.2.0",
+ "@thi.ng/transducers": "^1.16.0"
},
"keywords": [
"CAD",
diff --git a/packages/iges/src/index.ts b/packages/iges/src/index.ts
index 21fcc1394c..76f4109ad8 100644
--- a/packages/iges/src/index.ts
+++ b/packages/iges/src/index.ts
@@ -1,4 +1,7 @@
import { defmulti } from "@thi.ng/defmulti";
+import { float } from "@thi.ng/strings/float";
+import { padLeft } from "@thi.ng/strings/pad-left";
+import { padRight } from "@thi.ng/strings/pad-right";
import {
comp,
iterator,
@@ -12,7 +15,6 @@ import {
wordWrap,
wrap
} from "@thi.ng/transducers";
-
import {
DEFAULT_GLOBALS,
DictEntry,
@@ -28,25 +30,13 @@ import {
const LINEWIDTH_GLOBALS = 72;
const LINEWIDTH_PARAMS = 64;
-const padl = (n: number, ch: string) => {
- const buf = new Array(n).fill(ch).join("");
- return (x: any) => (x = x.toString(), x.length < n ? buf.substr(x.length) + x : x);
-};
-
-const padr = (n: number, ch: string) => {
- const buf = new Array(n).fill(ch).join("");
- return (x: any) => (x = x.toString(), x.length < n ? x + buf.substr(x.length) : x);
-};
-
-const ff = (prec = 3) => (x: number) => x.toFixed(prec);
-
-const $Z2 = padl(2, "0");
-const $Z7 = padl(7, "0");
-const $F8 = padl(8, " ");
+const $Z2 = padLeft(2, "0");
+const $Z7 = padLeft(7, "0");
+const $F8 = padLeft(8, " ");
const $STR = (x: any) => (x != null ? (x = x.toString(), `${x.length}H${x}`) : "");
-const $SEQ = padl(7, " ");
-const $BODY = padr(72, " ");
-const $PBODY = padr(64, " ");
+const $SEQ = padLeft(7, " ");
+const $BODY = padRight(72, " ");
+const $PBODY = padRight(64, " ");
const $DATE = (d: Date) =>
$STR([
d.getUTCFullYear(),
@@ -60,7 +50,7 @@ const $DATE = (d: Date) =>
export const newDocument = (g?: Partial, start?: string[]): IGESDocument => {
const globals = { ...DEFAULT_GLOBALS, ...g };
- const $FF = ff(globals.precision);
+ const $FF = float(globals.precision);
const $PARAM = defmulti((x) => x[1]);
$PARAM.add(Type.INT, (x) => x[0].toString());
$PARAM.add(Type.FLOAT, (x) => $FF(x[0]));
diff --git a/packages/memoize/.npmignore b/packages/memoize/.npmignore
new file mode 100644
index 0000000000..d703bda97a
--- /dev/null
+++ b/packages/memoize/.npmignore
@@ -0,0 +1,10 @@
+build
+coverage
+dev
+doc
+src*
+test
+.nyc_output
+tsconfig.json
+*.tgz
+*.html
diff --git a/packages/memoize/CHANGELOG.md b/packages/memoize/CHANGELOG.md
new file mode 100644
index 0000000000..cc3cdbf2c9
--- /dev/null
+++ b/packages/memoize/CHANGELOG.md
@@ -0,0 +1,13 @@
+# Change Log
+
+All notable changes to this project will be documented in this file.
+See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+
+
+# 0.1.0 (2018-08-08)
+
+
+### Features
+
+* **memoize:** add [@thi](https://github.com/thi).ng/memoize package ([adc4928](https://github.com/thi-ng/umbrella/commit/adc4928))
+* **memoize:** add optional cache arg for memoizeJ() ([2bc092d](https://github.com/thi-ng/umbrella/commit/2bc092d))
diff --git a/packages/memoize/LICENSE b/packages/memoize/LICENSE
new file mode 100644
index 0000000000..8dada3edaf
--- /dev/null
+++ b/packages/memoize/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "{}"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright {yyyy} {name of copyright owner}
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/packages/memoize/README.md b/packages/memoize/README.md
new file mode 100644
index 0000000000..c989125cb9
--- /dev/null
+++ b/packages/memoize/README.md
@@ -0,0 +1,113 @@
+# @thi.ng/memoize
+
+[![npm (scoped)](https://img.shields.io/npm/v/@thi.ng/memoize.svg)](https://www.npmjs.com/package/@thi.ng/memoize)
+
+This project is part of the
+[@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo.
+
+
+
+- [About](#about)
+- [Installation](#installation)
+- [Usage examples](#usage-examples)
+ - [Optimized version for single arg functions](#optimized-version-for-single-arg-functions)
+ - [Arbitrary args](#arbitrary-args)
+ - [Via JSON.stringify()](#via-jsonstringify)
+- [Authors](#authors)
+- [License](#license)
+
+
+
+## About
+
+This package provides different function memoization implementations for
+functions with 1 or more arguments and custom result caching using ES6
+Map API like implementations. Unlike native ES6 Maps, **the
+implementations MUST support value, not referential, equality
+semantics** (e.g. those provided by
+[@thi.ng/associative](https://github.com/thi-ng/umbrella/tree/master/packages/associative))
+or
+[@thi.ng/cache](https://github.com/thi-ng/umbrella/tree/master/packages/cache)).
+The latter also support automatically pruning of memoization caches,
+based on different strategies. See doc strings for further details.
+
+## Installation
+
+```bash
+yarn add @thi.ng/memoize
+```
+
+## Usage examples
+
+```ts
+import * as m from "@thi.ng/memoize";
+
+// (optional, for custom caching)
+import { EquivMap } from "@thi.ng/associative";
+import { LRUCache } from "@thi.ng/cache";
+```
+
+### Optimized version for single arg functions
+
+```ts
+foo = m.memoize1((x) => (console.log("exec"), x * 10));
+foo(1);
+// exec
+// 10
+foo(1);
+// 10
+
+// with custom cache
+foo = m.memoize1(
+ (x) => (console.log("exec"), x[0] * 10),
+ new EquivMap()
+);
+
+foo([1]);
+// exec
+// 10
+foo([1]); // wouldn't work w/ native ES6 Map as cache
+// 10
+
+// use LRU cache to limit cache size
+foo = m.memoize1(
+ (x) => (console.log("exec"), x[0] * 10),
+ new LRUCache(null, { maxlen: 3 })
+);
+```
+
+### Arbitrary args
+
+```ts
+dotProduct = m.memoize(
+ (x, y) => (console.log("exec"), x[0] * y[0] + x[1] * y[1]),
+ new EquivMap()
+);
+
+dotProduct([1,2], [3,4]);
+// exec
+// 11
+dotProduct([1,2], [3,4]);
+// 11
+```
+
+### Via JSON.stringify()
+
+```ts
+dotProduct = m.memoizeJ(
+ (x, y) => (console.log("exec"), x[0] * y[0] + x[1] * y[1])
+);
+dotProduct([1,2], [3,4]);
+// exec
+// 11
+dotProduct([1,2], [3,4]);
+// 11
+```
+
+## Authors
+
+- Karsten Schmidt
+
+## License
+
+© 2018 Karsten Schmidt // Apache Software License 2.0
diff --git a/packages/memoize/package.json b/packages/memoize/package.json
new file mode 100644
index 0000000000..887336eb4f
--- /dev/null
+++ b/packages/memoize/package.json
@@ -0,0 +1,45 @@
+{
+ "name": "@thi.ng/memoize",
+ "version": "0.1.0",
+ "description": "Function memoization with configurable caches",
+ "main": "./index.js",
+ "typings": "./index.d.ts",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/thi-ng/umbrella.git"
+ },
+ "homepage": "https://github.com/thi-ng/umbrella/tree/master/packages/memoize",
+ "author": "Karsten Schmidt ",
+ "license": "Apache-2.0",
+ "scripts": {
+ "build": "yarn run clean && tsc --declaration",
+ "clean": "rm -rf *.js *.d.ts .nyc_output build coverage doc",
+ "cover": "yarn test && nyc report --reporter=lcov",
+ "doc": "node_modules/.bin/typedoc --mode modules --out doc src",
+ "pub": "yarn run build && yarn publish --access public",
+ "test": "rm -rf build && tsc -p test && nyc mocha build/test/*.js"
+ },
+ "devDependencies": {
+ "@thi.ng/associative": "^0.5.11",
+ "@thi.ng/cache": "^0.2.15",
+ "@types/mocha": "^5.2.5",
+ "@types/node": "^10.5.5",
+ "mocha": "^5.2.0",
+ "nyc": "^12.0.2",
+ "typedoc": "^0.11.1",
+ "typescript": "^3.0.1"
+ },
+ "dependencies": {
+ "@thi.ng/api": "^4.0.6"
+ },
+ "keywords": [
+ "cache",
+ "ES6",
+ "function",
+ "memoization",
+ "typescript"
+ ],
+ "publishConfig": {
+ "access": "public"
+ }
+}
diff --git a/packages/memoize/src/api.ts b/packages/memoize/src/api.ts
new file mode 100644
index 0000000000..fadebca20c
--- /dev/null
+++ b/packages/memoize/src/api.ts
@@ -0,0 +1,11 @@
+export type Fn1 = (a: A) => B;
+export type Fn2 = (a: A, b: B) => C;
+export type Fn3 = (a: A, b: B, c: C) => D;
+export type Fn4 = (a: A, b: B, c: C, d: D) => E;
+export type FnAny = (...xs: any[]) => any;
+
+export interface MapLike {
+ has(key: A): boolean;
+ get(key: A): B | undefined;
+ set(key: A, val: B): any;
+}
\ No newline at end of file
diff --git a/packages/memoize/src/index.ts b/packages/memoize/src/index.ts
new file mode 100644
index 0000000000..c5efad54c6
--- /dev/null
+++ b/packages/memoize/src/index.ts
@@ -0,0 +1,4 @@
+export * from "./api";
+export * from "./memoize";
+export * from "./memoize1";
+export * from "./memoizej";
diff --git a/packages/memoize/src/memoize.ts b/packages/memoize/src/memoize.ts
new file mode 100644
index 0000000000..24b5415a70
--- /dev/null
+++ b/packages/memoize/src/memoize.ts
@@ -0,0 +1,28 @@
+import { Fn1, Fn2, Fn3, Fn4, FnAny, MapLike } from "./api";
+
+/**
+ * Function memoization for arbitrary argument counts. Returns augmented
+ * function, which uses the given `Map` implementation to obtain and
+ * store memoized result of given args. Supports generics for up to 4
+ * args (otherwise untyped).
+ *
+ * **Important:** It only makes sense to use `Map` types which support
+ * value (rather than object) equality, e.g. those provided by
+ * thi.ng/associative. Using a native `Map` type here will lead to
+ * memory leaks! Alternatively, use `memoizeJ`.
+ *
+ * @param fn
+ * @param cache
+ */
+export function memoize(fn: Fn1, cache: MapLike): Fn1;
+export function memoize(fn: Fn2, cache: MapLike<[A, B], C>): Fn2;
+export function memoize(fn: Fn3, cache: MapLike<[A, B, C], D>): Fn3;
+export function memoize(fn: Fn4, cache: MapLike<[A, B, C, D], E>): Fn4;
+export function memoize(fn: FnAny, cache: Map): FnAny {
+ return (...args: any[]) => {
+ let res;
+ return cache.has(args) ?
+ cache.get(args) :
+ (cache.set(args, res = fn.apply(null, args)), res);
+ };
+}
diff --git a/packages/memoize/src/memoize1.ts b/packages/memoize/src/memoize1.ts
new file mode 100644
index 0000000000..0abf995abf
--- /dev/null
+++ b/packages/memoize/src/memoize1.ts
@@ -0,0 +1,22 @@
+import { Fn1, MapLike } from "./api";
+
+/**
+ * Optimized memoization for single arg functions. If the function
+ * expects args other than strings or numbers, you MUST provide a `Map`
+ * implementation which supports value (rather than object) equality,
+ * e.g. one of those provided by thi.ng/associative. Using a native
+ * `Map` type here will lead to memory leaks! Alternatively, use
+ * `memoizeJ`.
+ *
+ * @param fn
+ * @param cache
+ */
+export function memoize1(fn: Fn1, cache?: MapLike) {
+ !cache && (cache = new Map());
+ return (x: A) => {
+ let res;
+ return cache.has(x) ?
+ cache.get(x) :
+ (cache.set(x, res = fn(x)), res);
+ }
+}
diff --git a/packages/memoize/src/memoizej.ts b/packages/memoize/src/memoizej.ts
new file mode 100644
index 0000000000..e3cb361313
--- /dev/null
+++ b/packages/memoize/src/memoizej.ts
@@ -0,0 +1,31 @@
+import { IObjectOf } from "@thi.ng/api/api";
+import { Fn1, Fn2, Fn3, Fn4, FnAny } from "./api";
+
+/**
+ * Function memoization for arbitrary argument counts. Returns augmented
+ * function, which uses `JSON.stringify()` to obtain (and store)
+ * memoized result for given args. Supports generics for up to 4 args
+ * (otherwise untyped).
+ *
+ * **Important:** If the given args cannot be stringified, the user
+ * function will ALWAYS be called (without caching result).
+ *
+ * @param fn
+ * @param cache
+ */
+export function memoizeJ(fn: Fn1, cache?: IObjectOf): Fn1;
+export function memoizeJ(fn: Fn2, cache?: IObjectOf): Fn2;
+export function memoizeJ(fn: Fn3, cache?: IObjectOf): Fn3;
+export function memoizeJ(fn: Fn4, cache?: IObjectOf): Fn4;
+export function memoizeJ(fn: FnAny, cache?: IObjectOf): FnAny {
+ !cache && (cache = {});
+ return (...args: any[]) => {
+ const key = JSON.stringify(args);
+ if (key !== undefined) {
+ return key in cache ?
+ cache[key] :
+ (cache[key] = fn.apply(null, args));
+ }
+ return fn.apply(null, args);
+ };
+}
diff --git a/packages/memoize/test/index.ts b/packages/memoize/test/index.ts
new file mode 100644
index 0000000000..2c3036ad2b
--- /dev/null
+++ b/packages/memoize/test/index.ts
@@ -0,0 +1,50 @@
+import * as assert from "assert";
+import { EquivMap } from "@thi.ng/associative";
+import { LRUCache } from "@thi.ng/cache";
+import * as m from "../src/index";
+
+describe("memoize", () => {
+
+ it("memoize1", () => {
+ const calls = [];
+ const f = m.memoize1((x) => (calls.push(x), x * 10));
+ assert.equal(f(1), 10);
+ assert.equal(f(2), 20);
+ assert.equal(f(2), 20);
+ assert.equal(f(1), 10);
+ assert.equal(f(3), 30);
+ assert.deepEqual(calls, [1, 2, 3]);
+ });
+
+ it("memoize1 (equivmap)", () => {
+ const calls = [];
+ const f = m.memoize1(
+ (x) => (calls.push(x), x[0] + x[1]),
+ new EquivMap()
+ );
+ assert.equal(f([1, 2]), 3);
+ assert.equal(f([3, 4]), 7);
+ assert.equal(f([3, 4]), 7);
+ assert.equal(f([1, 2]), 3);
+ assert.equal(f([5, 6]), 11);
+ assert.deepEqual(calls, [[1, 2], [3, 4], [5, 6]]);
+ });
+
+ it("memoize1 (lru)", () => {
+ const calls = [];
+ const cache = new LRUCache(null, { maxlen: 3, map: () => new EquivMap() });
+ const f = m.memoize1(
+ (x) => (calls.push(x), x[0] + x[1]),
+ cache
+ );
+ assert.equal(f([1, 2]), 3);
+ assert.equal(f([3, 4]), 7);
+ assert.equal(f([3, 4]), 7);
+ assert.equal(f([1, 2]), 3);
+ assert.equal(f([5, 6]), 11);
+ assert.equal(f([7, 8]), 15);
+ assert.equal(f([3, 4]), 7); // <-- recompute
+ assert.deepEqual(calls, [[1, 2], [3, 4], [5, 6], [7, 8], [3, 4]]);
+ assert.deepEqual([...cache.keys()], [[5, 6], [7, 8], [3, 4]]);
+ });
+});
diff --git a/packages/memoize/test/tsconfig.json b/packages/memoize/test/tsconfig.json
new file mode 100644
index 0000000000..bcf29ace54
--- /dev/null
+++ b/packages/memoize/test/tsconfig.json
@@ -0,0 +1,10 @@
+{
+ "extends": "../../../tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../build"
+ },
+ "include": [
+ "./**/*.ts",
+ "../src/**/*.ts"
+ ]
+}
diff --git a/packages/memoize/tsconfig.json b/packages/memoize/tsconfig.json
new file mode 100644
index 0000000000..bd6481a5a6
--- /dev/null
+++ b/packages/memoize/tsconfig.json
@@ -0,0 +1,9 @@
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "outDir": "."
+ },
+ "include": [
+ "./src/**/*.ts"
+ ]
+}
diff --git a/packages/range-coder/CHANGELOG.md b/packages/range-coder/CHANGELOG.md
index 32d9017683..9f011827df 100644
--- a/packages/range-coder/CHANGELOG.md
+++ b/packages/range-coder/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.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/range-coder@0.1.3...@thi.ng/range-coder@0.1.4) (2018-08-08)
+
+
+
+
+**Note:** Version bump only for package @thi.ng/range-coder
+
## [0.1.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/range-coder@0.1.2...@thi.ng/range-coder@0.1.3) (2018-08-02)
diff --git a/packages/range-coder/package.json b/packages/range-coder/package.json
index 5f126b326e..1479fd5a5e 100644
--- a/packages/range-coder/package.json
+++ b/packages/range-coder/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/range-coder",
- "version": "0.1.3",
+ "version": "0.1.4",
"description": "Binary data range encoder / decoder",
"main": "./index.js",
"typings": "./index.d.ts",
@@ -20,7 +20,7 @@
"test": "rm -rf build && tsc -p test && nyc mocha build/test/*.js"
},
"devDependencies": {
- "@thi.ng/transducers": "^1.15.0",
+ "@thi.ng/transducers": "^1.16.0",
"@types/mocha": "^5.2.5",
"@types/node": "^10.5.5",
"mocha": "^5.2.0",
diff --git a/packages/rstream-csp/CHANGELOG.md b/packages/rstream-csp/CHANGELOG.md
index 1d79462d89..a594a2b9f1 100644
--- a/packages/rstream-csp/CHANGELOG.md
+++ b/packages/rstream-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.
+
+## [0.1.96](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-csp@0.1.95...@thi.ng/rstream-csp@0.1.96) (2018-08-08)
+
+
+
+
+**Note:** Version bump only for package @thi.ng/rstream-csp
+
## [0.1.95](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-csp@0.1.94...@thi.ng/rstream-csp@0.1.95) (2018-08-06)
diff --git a/packages/rstream-csp/package.json b/packages/rstream-csp/package.json
index d04d71e123..998b0b0356 100644
--- a/packages/rstream-csp/package.json
+++ b/packages/rstream-csp/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/rstream-csp",
- "version": "0.1.95",
+ "version": "0.1.96",
"description": "@thi.ng/csp bridge module for @thi.ng/rstream",
"main": "./index.js",
"typings": "./index.d.ts",
@@ -28,8 +28,8 @@
"typescript": "^3.0.1"
},
"dependencies": {
- "@thi.ng/csp": "^0.3.54",
- "@thi.ng/rstream": "^1.11.1"
+ "@thi.ng/csp": "^0.3.55",
+ "@thi.ng/rstream": "^1.11.2"
},
"keywords": [
"bridge",
diff --git a/packages/rstream-dot/CHANGELOG.md b/packages/rstream-dot/CHANGELOG.md
index e300656479..07b5a21a8e 100644
--- a/packages/rstream-dot/CHANGELOG.md
+++ b/packages/rstream-dot/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.35](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-dot@0.2.34...@thi.ng/rstream-dot@0.2.35) (2018-08-08)
+
+
+
+
+**Note:** Version bump only for package @thi.ng/rstream-dot
+
## [0.2.34](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-dot@0.2.33...@thi.ng/rstream-dot@0.2.34) (2018-08-06)
diff --git a/packages/rstream-dot/package.json b/packages/rstream-dot/package.json
index f7d5eb8f36..21bade3336 100644
--- a/packages/rstream-dot/package.json
+++ b/packages/rstream-dot/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/rstream-dot",
- "version": "0.2.34",
+ "version": "0.2.35",
"description": "Graphviz DOT conversion of @thi.ng/rstream dataflow graph topologies",
"main": "./index.js",
"typings": "./index.d.ts",
@@ -28,7 +28,7 @@
"typescript": "^3.0.1"
},
"dependencies": {
- "@thi.ng/rstream": "^1.11.1"
+ "@thi.ng/rstream": "^1.11.2"
},
"keywords": [
"conversion",
diff --git a/packages/rstream-gestures/CHANGELOG.md b/packages/rstream-gestures/CHANGELOG.md
index 43cfc9ac5c..0f48ee9225 100644
--- a/packages/rstream-gestures/CHANGELOG.md
+++ b/packages/rstream-gestures/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.4.16](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-gestures@0.4.15...@thi.ng/rstream-gestures@0.4.16) (2018-08-08)
+
+
+
+
+**Note:** Version bump only for package @thi.ng/rstream-gestures
+
## [0.4.15](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-gestures@0.4.14...@thi.ng/rstream-gestures@0.4.15) (2018-08-06)
diff --git a/packages/rstream-gestures/package.json b/packages/rstream-gestures/package.json
index 60c063cb11..89ec46963d 100644
--- a/packages/rstream-gestures/package.json
+++ b/packages/rstream-gestures/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/rstream-gestures",
- "version": "0.4.15",
+ "version": "0.4.16",
"description": "Unified mouse, mouse wheel & single-touch event stream abstraction",
"main": "./index.js",
"typings": "./index.d.ts",
@@ -29,8 +29,8 @@
},
"dependencies": {
"@thi.ng/api": "^4.0.6",
- "@thi.ng/rstream": "^1.11.1",
- "@thi.ng/transducers": "^1.15.0"
+ "@thi.ng/rstream": "^1.11.2",
+ "@thi.ng/transducers": "^1.16.0"
},
"keywords": [
"dataflow",
diff --git a/packages/rstream-graph/CHANGELOG.md b/packages/rstream-graph/CHANGELOG.md
index ef2046ebb4..20a00a093b 100644
--- a/packages/rstream-graph/CHANGELOG.md
+++ b/packages/rstream-graph/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.20](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-graph@2.1.19...@thi.ng/rstream-graph@2.1.20) (2018-08-08)
+
+
+
+
+**Note:** Version bump only for package @thi.ng/rstream-graph
+
## [2.1.19](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-graph@2.1.18...@thi.ng/rstream-graph@2.1.19) (2018-08-06)
diff --git a/packages/rstream-graph/package.json b/packages/rstream-graph/package.json
index 984fed2bec..b365aa1c54 100644
--- a/packages/rstream-graph/package.json
+++ b/packages/rstream-graph/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/rstream-graph",
- "version": "2.1.19",
+ "version": "2.1.20",
"description": "Declarative dataflow graph construction for @thi.ng/rstream",
"main": "./index.js",
"typings": "./index.d.ts",
@@ -33,8 +33,8 @@
"@thi.ng/errors": "^0.1.6",
"@thi.ng/paths": "^1.5.2",
"@thi.ng/resolve-map": "^3.0.7",
- "@thi.ng/rstream": "^1.11.1",
- "@thi.ng/transducers": "^1.15.0"
+ "@thi.ng/rstream": "^1.11.2",
+ "@thi.ng/transducers": "^1.16.0"
},
"keywords": [
"compute",
diff --git a/packages/rstream-log/CHANGELOG.md b/packages/rstream-log/CHANGELOG.md
index 9ee59ce2c3..fda5d78d35 100644
--- a/packages/rstream-log/CHANGELOG.md
+++ b/packages/rstream-log/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.47](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-log@1.0.46...@thi.ng/rstream-log@1.0.47) (2018-08-08)
+
+
+
+
+**Note:** Version bump only for package @thi.ng/rstream-log
+
## [1.0.46](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-log@1.0.45...@thi.ng/rstream-log@1.0.46) (2018-08-06)
diff --git a/packages/rstream-log/package.json b/packages/rstream-log/package.json
index 31f869ccec..56af579fe3 100644
--- a/packages/rstream-log/package.json
+++ b/packages/rstream-log/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/rstream-log",
- "version": "1.0.46",
+ "version": "1.0.47",
"description": "Structured, multilevel & hierarchical loggers based on @thi.ng/rstream",
"main": "./index.js",
"typings": "./index.d.ts",
@@ -31,8 +31,8 @@
"@thi.ng/api": "^4.0.6",
"@thi.ng/checks": "^1.5.7",
"@thi.ng/errors": "^0.1.6",
- "@thi.ng/rstream": "^1.11.1",
- "@thi.ng/transducers": "^1.15.0"
+ "@thi.ng/rstream": "^1.11.2",
+ "@thi.ng/transducers": "^1.16.0"
},
"keywords": [
"ES6",
diff --git a/packages/rstream-query/CHANGELOG.md b/packages/rstream-query/CHANGELOG.md
index 3dd2663732..5764dcb1ae 100644
--- a/packages/rstream-query/CHANGELOG.md
+++ b/packages/rstream-query/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.34](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-query@0.3.33...@thi.ng/rstream-query@0.3.34) (2018-08-08)
+
+
+
+
+**Note:** Version bump only for package @thi.ng/rstream-query
+
## [0.3.33](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream-query@0.3.32...@thi.ng/rstream-query@0.3.33) (2018-08-06)
diff --git a/packages/rstream-query/package.json b/packages/rstream-query/package.json
index e70ba85eaf..bed0ffb37a 100644
--- a/packages/rstream-query/package.json
+++ b/packages/rstream-query/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/rstream-query",
- "version": "0.3.33",
+ "version": "0.3.34",
"description": "@thi.ng/rstream based triple store & reactive query engine",
"main": "./index.js",
"typings": "./index.d.ts",
@@ -33,9 +33,9 @@
"@thi.ng/checks": "^1.5.7",
"@thi.ng/equiv": "^0.1.7",
"@thi.ng/errors": "^0.1.6",
- "@thi.ng/rstream": "^1.11.1",
- "@thi.ng/rstream-dot": "^0.2.34",
- "@thi.ng/transducers": "^1.15.0"
+ "@thi.ng/rstream": "^1.11.2",
+ "@thi.ng/rstream-dot": "^0.2.35",
+ "@thi.ng/transducers": "^1.16.0"
},
"keywords": [
"dataflow",
diff --git a/packages/rstream/CHANGELOG.md b/packages/rstream/CHANGELOG.md
index 95255e6312..93238a4c82 100644
--- a/packages/rstream/CHANGELOG.md
+++ b/packages/rstream/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.11.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream@1.11.1...@thi.ng/rstream@1.11.2) (2018-08-08)
+
+
+
+
+**Note:** Version bump only for package @thi.ng/rstream
+
## [1.11.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/rstream@1.11.0...@thi.ng/rstream@1.11.1) (2018-08-06)
diff --git a/packages/rstream/package.json b/packages/rstream/package.json
index 1f7c6259bf..fd93485f6b 100644
--- a/packages/rstream/package.json
+++ b/packages/rstream/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/rstream",
- "version": "1.11.1",
+ "version": "1.11.2",
"description": "Reactive multi-tap streams, dataflow & transformation pipeline constructs",
"main": "./index.js",
"typings": "./index.d.ts",
@@ -34,7 +34,7 @@
"@thi.ng/checks": "^1.5.7",
"@thi.ng/errors": "^0.1.6",
"@thi.ng/paths": "^1.5.2",
- "@thi.ng/transducers": "^1.15.0"
+ "@thi.ng/transducers": "^1.16.0"
},
"keywords": [
"datastructure",
diff --git a/packages/sax/CHANGELOG.md b/packages/sax/CHANGELOG.md
index 49cf57d607..e4a1de4409 100644
--- a/packages/sax/CHANGELOG.md
+++ b/packages/sax/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.13](https://github.com/thi-ng/umbrella/compare/@thi.ng/sax@0.3.12...@thi.ng/sax@0.3.13) (2018-08-08)
+
+
+
+
+**Note:** Version bump only for package @thi.ng/sax
+
## [0.3.12](https://github.com/thi-ng/umbrella/compare/@thi.ng/sax@0.3.11...@thi.ng/sax@0.3.12) (2018-08-02)
diff --git a/packages/sax/package.json b/packages/sax/package.json
index 318d6e078b..0e2072e7bf 100644
--- a/packages/sax/package.json
+++ b/packages/sax/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/sax",
- "version": "0.3.12",
+ "version": "0.3.13",
"description": "Transducer-based, SAX-like, non-validating, speedy & tiny XML parser",
"main": "./index.js",
"typings": "./index.d.ts",
@@ -29,8 +29,8 @@
},
"dependencies": {
"@thi.ng/api": "^4.0.6",
- "@thi.ng/transducers": "^1.15.0",
- "@thi.ng/transducers-fsm": "^0.2.11"
+ "@thi.ng/transducers": "^1.16.0",
+ "@thi.ng/transducers-fsm": "^0.2.12"
},
"keywords": [
"ES6",
diff --git a/packages/strings/.npmignore b/packages/strings/.npmignore
new file mode 100644
index 0000000000..d703bda97a
--- /dev/null
+++ b/packages/strings/.npmignore
@@ -0,0 +1,10 @@
+build
+coverage
+dev
+doc
+src*
+test
+.nyc_output
+tsconfig.json
+*.tgz
+*.html
diff --git a/packages/strings/CHANGELOG.md b/packages/strings/CHANGELOG.md
new file mode 100644
index 0000000000..2777331297
--- /dev/null
+++ b/packages/strings/CHANGELOG.md
@@ -0,0 +1,34 @@
+# Change Log
+
+All notable changes to this project will be documented in this file.
+See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+
+
+# [0.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/strings@0.1.1...@thi.ng/strings@0.2.0) (2018-08-08)
+
+
+### Features
+
+* **strings:** add opt prefix arg for radix() ([5864f2c](https://github.com/thi-ng/umbrella/commit/5864f2c))
+
+
+
+
+
+## [0.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/strings@0.1.0...@thi.ng/strings@0.1.1) (2018-08-08)
+
+
+### Bug Fixes
+
+* **strings:** float type decl ([b2ebbfc](https://github.com/thi-ng/umbrella/commit/b2ebbfc))
+
+
+
+
+
+# 0.1.0 (2018-08-08)
+
+
+### Features
+
+* **strings:** re-import & update [@thi](https://github.com/thi).ng/strings from MBP2010 ([40781eb](https://github.com/thi-ng/umbrella/commit/40781eb))
diff --git a/packages/strings/LICENSE b/packages/strings/LICENSE
new file mode 100644
index 0000000000..8dada3edaf
--- /dev/null
+++ b/packages/strings/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "{}"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright {yyyy} {name of copyright owner}
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/packages/strings/README.md b/packages/strings/README.md
new file mode 100644
index 0000000000..689e9735cc
--- /dev/null
+++ b/packages/strings/README.md
@@ -0,0 +1,41 @@
+# @thi.ng/strings
+
+[![npm (scoped)](https://img.shields.io/npm/v/@thi.ng/strings.svg)](https://www.npmjs.com/package/@thi.ng/strings)
+
+This project is part of the
+[@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo.
+
+
+
+- [About](#about)
+- [Installation](#installation)
+- [Usage examples](#usage-examples)
+- [Authors](#authors)
+- [License](#license)
+
+
+
+## About
+
+Various higher-order, but low-level string formatting & utility
+functions, some memoized. WIP / Alpha.
+
+## Installation
+
+```bash
+yarn add @thi.ng/strings
+```
+
+## Usage examples
+
+```ts
+import * as str from "@thi.ng/strings";
+```
+
+## Authors
+
+- Karsten Schmidt
+
+## License
+
+© 2018 Karsten Schmidt // Apache Software License 2.0
diff --git a/packages/strings/package.json b/packages/strings/package.json
new file mode 100644
index 0000000000..0ade10c618
--- /dev/null
+++ b/packages/strings/package.json
@@ -0,0 +1,46 @@
+{
+ "name": "@thi.ng/strings",
+ "version": "0.2.0",
+ "description": "Various string formatting & utility functions",
+ "main": "./index.js",
+ "typings": "./index.d.ts",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/thi-ng/umbrella.git"
+ },
+ "homepage": "https://github.com/thi-ng/umbrella/tree/master/packages/format",
+ "author": "Karsten Schmidt ",
+ "license": "Apache-2.0",
+ "scripts": {
+ "build": "yarn run clean && tsc --declaration",
+ "clean": "rm -rf *.js *.d.ts .nyc_output build coverage doc",
+ "cover": "yarn test && nyc report --reporter=lcov",
+ "doc": "node_modules/.bin/typedoc --mode modules --out doc src",
+ "pub": "yarn run build && yarn publish --access public",
+ "test": "rm -rf build && tsc -p test && nyc mocha build/test/*.js"
+ },
+ "devDependencies": {
+ "@types/mocha": "^5.2.5",
+ "@types/node": "^10.5.5",
+ "mocha": "^5.2.0",
+ "nyc": "^12.0.2",
+ "typedoc": "^0.11.1",
+ "typescript": "^3.0.1"
+ },
+ "dependencies": {
+ "@thi.ng/memoize": "^0.1.0"
+ },
+ "keywords": [
+ "ES6",
+ "format",
+ "functional",
+ "higher order",
+ "padding",
+ "number",
+ "string",
+ "typescript"
+ ],
+ "publishConfig": {
+ "access": "public"
+ }
+}
diff --git a/packages/strings/src/api.ts b/packages/strings/src/api.ts
new file mode 100644
index 0000000000..f7b027b5bb
--- /dev/null
+++ b/packages/strings/src/api.ts
@@ -0,0 +1 @@
+export type Stringer = (x: T) => string;
diff --git a/packages/strings/src/case.ts b/packages/strings/src/case.ts
new file mode 100644
index 0000000000..53cd218387
--- /dev/null
+++ b/packages/strings/src/case.ts
@@ -0,0 +1,25 @@
+import { Stringer } from "./api";
+
+/**
+ * Uppercase string formatter.
+ *
+ * @param x string to transform
+ */
+export const upper: Stringer =
+ (x: string) => x.toUpperCase();
+
+/**
+ * Lowercase string formatter.
+ *
+ * @param x string to transform
+ */
+export const lower: Stringer =
+ (x: string) => x.toLowerCase();
+
+/**
+ * String formatter which capitalizes first character.
+ *
+ * @param x string to transform
+ */
+export const capitalize: Stringer =
+ (x: string) => x[0].toUpperCase() + x.substr(1);
diff --git a/packages/strings/src/center.ts b/packages/strings/src/center.ts
new file mode 100644
index 0000000000..82e4fa586d
--- /dev/null
+++ b/packages/strings/src/center.ts
@@ -0,0 +1,21 @@
+import { memoizeJ } from "@thi.ng/memoize/memoizej";
+
+import { Stringer } from "./api";
+import { repeat } from "./repeat";
+
+/**
+ * @param n target length
+ * @param ch pad character(s)
+ */
+export const center: (n: number, ch?: string | number) => Stringer =
+ memoizeJ>((n, ch = " ") => {
+ const buf = repeat(ch, ((n + 1) & ~1) / 2);
+ return (x: any) => {
+ if (x == null) return buf;
+ x = x.toString();
+ const r = (n - x.length) / 2;
+ return x.length < n ?
+ buf.substr(0, r) + x + buf.substr(0, r + ((n & 1) === (x.length & 1) ? 0 : 1)) :
+ x;
+ }
+ });
diff --git a/packages/strings/src/float.ts b/packages/strings/src/float.ts
new file mode 100644
index 0000000000..5b8d2f71d6
--- /dev/null
+++ b/packages/strings/src/float.ts
@@ -0,0 +1,12 @@
+import { memoizeJ } from "@thi.ng/memoize/memoizej";
+
+import { Stringer } from "./api";
+
+/**
+ * Returns `Stringer` which formats numbers to given precision.
+ *
+ * @param len number of fractional digits
+ * @kind function
+ */
+export const float: (prec: number) => Stringer =
+ memoizeJ((prec) => (x: number) => x.toFixed(prec));
diff --git a/packages/strings/src/format.ts b/packages/strings/src/format.ts
new file mode 100644
index 0000000000..cb3f15c0c9
--- /dev/null
+++ b/packages/strings/src/format.ts
@@ -0,0 +1,15 @@
+export const format = (fmt: any[], ...args: any[]) => {
+ const acc: any[] = [];
+ for (let i = 0, j = 0, n = fmt.length; i < n; i++) {
+ const f = fmt[i];
+ const t = typeof f;
+ acc.push(
+ t === "function" ?
+ f(args[j++]) :
+ t === "object" ?
+ f[args[j++]] :
+ f
+ );
+ }
+ return acc.join("");
+};
diff --git a/packages/strings/src/index.ts b/packages/strings/src/index.ts
new file mode 100644
index 0000000000..6abe1783b5
--- /dev/null
+++ b/packages/strings/src/index.ts
@@ -0,0 +1,12 @@
+export * from "./api";
+export * from "./case";
+export * from "./center";
+export * from "./float";
+export * from "./format";
+export * from "./pad-left";
+export * from "./pad-right";
+export * from "./parse";
+export * from "./percent";
+export * from "./radix";
+export * from "./repeat";
+export * from "./truncate";
diff --git a/packages/strings/src/pad-left.ts b/packages/strings/src/pad-left.ts
new file mode 100644
index 0000000000..9f77c0153f
--- /dev/null
+++ b/packages/strings/src/pad-left.ts
@@ -0,0 +1,17 @@
+import { memoizeJ } from "@thi.ng/memoize/memoizej";
+
+import { Stringer } from "./api";
+import { repeat } from "./repeat";
+
+/**
+ * @param n target length
+ * @param ch pad character(s)
+ */
+export const padLeft: (n: number, ch?: string | number) => Stringer =
+ memoizeJ>((n, ch = " ") => {
+ const buf = repeat(ch, n);
+ return (x: any) =>
+ x != null ?
+ (x = x.toString(), x.length < n ? buf.substr(x.length) + x : x) :
+ buf;
+ });
diff --git a/packages/strings/src/pad-right.ts b/packages/strings/src/pad-right.ts
new file mode 100644
index 0000000000..2b2ff2e29f
--- /dev/null
+++ b/packages/strings/src/pad-right.ts
@@ -0,0 +1,17 @@
+import { memoizeJ } from "@thi.ng/memoize/memoizej";
+
+import { Stringer } from "./api";
+import { repeat } from "./repeat";
+
+/**
+ * @param n target length
+ * @param ch pad character(s)
+ */
+export const padRight: (n: number, ch?: string | number) => Stringer =
+ memoizeJ>((n, ch = " ") => {
+ const buf = repeat(ch, n);
+ return (x: any) =>
+ x != null ?
+ (x = x.toString(), x.length < n ? x + buf.substr(x.length) : x) :
+ buf;
+ });
diff --git a/packages/strings/src/parse.ts b/packages/strings/src/parse.ts
new file mode 100644
index 0000000000..efaef03f42
--- /dev/null
+++ b/packages/strings/src/parse.ts
@@ -0,0 +1,9 @@
+export const parseInt = (x: string, defaultVal = 0, radix = 10) => {
+ const n = parseInt(x, radix);
+ return isNaN(n) ? defaultVal : n;
+};
+
+export const parseFloat = (x: string, defaultVal = 0) => {
+ const n = parseFloat(x);
+ return isNaN(n) ? defaultVal : n;
+};
diff --git a/packages/strings/src/percent.ts b/packages/strings/src/percent.ts
new file mode 100644
index 0000000000..cd6bd93645
--- /dev/null
+++ b/packages/strings/src/percent.ts
@@ -0,0 +1,10 @@
+import { Stringer } from "./api";
+
+/**
+ * Returns `Stringer` which formats given fractions as percentage (e.g.
+ * `0.1234 => 12.34%`).
+ *
+ * @param prec number of fractional digits (default: 0)
+ */
+export const percent = (prec = 0): Stringer =>
+ (x: number) => (x * 100).toFixed(prec) + "%";
diff --git a/packages/strings/src/radix.ts b/packages/strings/src/radix.ts
new file mode 100644
index 0000000000..61f81ffd29
--- /dev/null
+++ b/packages/strings/src/radix.ts
@@ -0,0 +1,29 @@
+import { memoizeJ } from "@thi.ng/memoize/memoizej";
+
+import { Stringer } from "./api";
+import { repeat } from "./repeat";
+
+/**
+ * Returns a `Stringer` which formats given numbers to `radix`, `len`
+ * and with optional prefix (not included in `len`).
+ *
+ * @param radix
+ * @param len
+ * @param prefix
+ */
+export const radix: (radix: number, len: number, prefix?: string) => Stringer =
+ memoizeJ(
+ (radix: number, n: number, prefix = "") => {
+ const buf = repeat("0", n);
+ return (x: any) => {
+ x = (x >>> 0).toString(radix);
+ return prefix + (x.length < n ? buf.substr(x.length) + x : x);
+ };
+ }
+ );
+
+export const B8 = radix(2, 8);
+export const U8 = radix(16, 2);
+export const U16 = radix(16, 4);
+export const U32 = radix(16, 8);
+export const U64 = (hi: number, lo: number) => U32(hi) + U32(lo);
diff --git a/packages/strings/src/repeat.ts b/packages/strings/src/repeat.ts
new file mode 100644
index 0000000000..8a5101500a
--- /dev/null
+++ b/packages/strings/src/repeat.ts
@@ -0,0 +1,9 @@
+import { memoizeJ } from "@thi.ng/memoize/memoizej";
+
+/**
+ * @param ch character
+ * @param n repeat count
+ */
+export const repeat = memoizeJ(
+ (ch: string, n: number) => new Array(n).fill(ch).join("")
+);
diff --git a/packages/strings/src/truncate.ts b/packages/strings/src/truncate.ts
new file mode 100644
index 0000000000..c470a25fd1
--- /dev/null
+++ b/packages/strings/src/truncate.ts
@@ -0,0 +1,12 @@
+import { memoizeJ } from "@thi.ng/memoize/memoizej";
+
+import { Stringer } from "./api";
+
+export const truncate: (n: number, suffix?: string) => Stringer =
+ memoizeJ(
+ (n: number, suffix = "") =>
+ (x) =>
+ x.length > n ?
+ x.substr(0, n - suffix.length) + suffix :
+ x
+ );
diff --git a/packages/strings/test/index.ts b/packages/strings/test/index.ts
new file mode 100644
index 0000000000..dac73b9054
--- /dev/null
+++ b/packages/strings/test/index.ts
@@ -0,0 +1,26 @@
+import * as assert from "assert";
+import * as str from "../src/index";
+
+describe("strings", () => {
+ it("padLeft", () => {
+ assert.equal(str.padLeft(4)(undefined), " ");
+ assert.equal(str.padLeft(4, "0")(null), "0000");
+ assert.equal(str.padLeft(4)(1), " 1");
+ assert.equal(str.padLeft(4)(12), " 12");
+ assert.equal(str.padLeft(4)(123), " 123");
+ assert.equal(str.padLeft(4)(1234), "1234");
+ assert.equal(str.padLeft(4)(12345), "12345");
+ assert.strictEqual(str.padLeft(5), str.padLeft(5));
+ });
+
+ it("padr", () => {
+ assert.equal(str.padRight(4)(undefined), " ");
+ assert.equal(str.padRight(4, "0")(null), "0000");
+ assert.equal(str.padRight(4)(1), "1 ");
+ assert.equal(str.padRight(4)(12), "12 ");
+ assert.equal(str.padRight(4)(123), "123 ");
+ assert.equal(str.padRight(4)(1234), "1234");
+ assert.equal(str.padRight(4)(12345), "12345");
+ assert.strictEqual(str.padRight(5), str.padRight(5));
+ });
+});
diff --git a/packages/strings/test/tsconfig.json b/packages/strings/test/tsconfig.json
new file mode 100644
index 0000000000..bcf29ace54
--- /dev/null
+++ b/packages/strings/test/tsconfig.json
@@ -0,0 +1,10 @@
+{
+ "extends": "../../../tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../build"
+ },
+ "include": [
+ "./**/*.ts",
+ "../src/**/*.ts"
+ ]
+}
diff --git a/packages/strings/tsconfig.json b/packages/strings/tsconfig.json
new file mode 100644
index 0000000000..bd6481a5a6
--- /dev/null
+++ b/packages/strings/tsconfig.json
@@ -0,0 +1,9 @@
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "outDir": "."
+ },
+ "include": [
+ "./src/**/*.ts"
+ ]
+}
diff --git a/packages/transducers-fsm/CHANGELOG.md b/packages/transducers-fsm/CHANGELOG.md
index b4b56ac9f8..6acab0c0a9 100644
--- a/packages/transducers-fsm/CHANGELOG.md
+++ b/packages/transducers-fsm/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.12](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers-fsm@0.2.11...@thi.ng/transducers-fsm@0.2.12) (2018-08-08)
+
+
+
+
+**Note:** Version bump only for package @thi.ng/transducers-fsm
+
## [0.2.11](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers-fsm@0.2.10...@thi.ng/transducers-fsm@0.2.11) (2018-08-02)
diff --git a/packages/transducers-fsm/package.json b/packages/transducers-fsm/package.json
index 3c2859c17a..113f63b278 100644
--- a/packages/transducers-fsm/package.json
+++ b/packages/transducers-fsm/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/transducers-fsm",
- "version": "0.2.11",
+ "version": "0.2.12",
"description": "Transducer-based Finite State Machine transformer",
"main": "./index.js",
"typings": "./index.d.ts",
@@ -29,7 +29,7 @@
},
"dependencies": {
"@thi.ng/api": "^4.0.6",
- "@thi.ng/transducers": "^1.15.0"
+ "@thi.ng/transducers": "^1.16.0"
},
"keywords": [
"ES6",
diff --git a/packages/transducers-hdom/CHANGELOG.md b/packages/transducers-hdom/CHANGELOG.md
index 812eeb684c..ce84f6e27d 100644
--- a/packages/transducers-hdom/CHANGELOG.md
+++ b/packages/transducers-hdom/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.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers-hdom@0.1.1...@thi.ng/transducers-hdom@0.1.2) (2018-08-08)
+
+
+
+
+**Note:** Version bump only for package @thi.ng/transducers-hdom
+
## [0.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers-hdom@0.1.0...@thi.ng/transducers-hdom@0.1.1) (2018-08-02)
diff --git a/packages/transducers-hdom/package.json b/packages/transducers-hdom/package.json
index 07ad1bdd46..b55c2b286a 100644
--- a/packages/transducers-hdom/package.json
+++ b/packages/transducers-hdom/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/transducers-hdom",
- "version": "0.1.1",
+ "version": "0.1.2",
"description": "Transducer based UI updater for @thi.ng/hdom",
"main": "./index.js",
"typings": "./index.d.ts",
@@ -30,7 +30,7 @@
"dependencies": {
"@thi.ng/checks": "^1.5.7",
"@thi.ng/hdom": "^3.0.32",
- "@thi.ng/transducers": "^1.15.0"
+ "@thi.ng/transducers": "^1.16.0"
},
"keywords": [
"diff",
diff --git a/packages/transducers-stats/CHANGELOG.md b/packages/transducers-stats/CHANGELOG.md
index 5b969ac598..40ca613732 100644
--- a/packages/transducers-stats/CHANGELOG.md
+++ b/packages/transducers-stats/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/transducers-stats@0.3.3...@thi.ng/transducers-stats@0.3.4) (2018-08-08)
+
+
+
+
+**Note:** Version bump only for package @thi.ng/transducers-stats
+
## [0.3.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers-stats@0.3.2...@thi.ng/transducers-stats@0.3.3) (2018-08-02)
diff --git a/packages/transducers-stats/package.json b/packages/transducers-stats/package.json
index 661842c8df..efb4541a8f 100644
--- a/packages/transducers-stats/package.json
+++ b/packages/transducers-stats/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/transducers-stats",
- "version": "0.3.3",
+ "version": "0.3.4",
"description": "Transducers for statistical / technical analysis",
"main": "./index.js",
"typings": "./index.d.ts",
@@ -30,7 +30,7 @@
"dependencies": {
"@thi.ng/dcons": "^1.0.7",
"@thi.ng/errors": "^0.1.6",
- "@thi.ng/transducers": "^1.15.0"
+ "@thi.ng/transducers": "^1.16.0"
},
"keywords": [
"ES6",
diff --git a/packages/transducers/CHANGELOG.md b/packages/transducers/CHANGELOG.md
index 1e6af91295..94bcbe0d66 100644
--- a/packages/transducers/CHANGELOG.md
+++ b/packages/transducers/CHANGELOG.md
@@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+
+# [1.16.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers@1.15.0...@thi.ng/transducers@1.16.0) (2018-08-08)
+
+
+### Features
+
+* **transducers:** add partitionBits() xform & tests ([a5e2c28](https://github.com/thi-ng/umbrella/commit/a5e2c28))
+
+
+
+
# [1.15.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers@1.14.3...@thi.ng/transducers@1.15.0) (2018-08-02)
diff --git a/packages/transducers/package.json b/packages/transducers/package.json
index 18b0c4842b..d1a16bc03c 100644
--- a/packages/transducers/package.json
+++ b/packages/transducers/package.json
@@ -1,6 +1,6 @@
{
"name": "@thi.ng/transducers",
- "version": "1.15.0",
+ "version": "1.16.0",
"description": "Lightweight transducer implementations for ES6 / TypeScript",
"main": "./index.js",
"typings": "./index.d.ts",
@@ -32,7 +32,8 @@
"@thi.ng/checks": "^1.5.7",
"@thi.ng/compare": "^0.1.6",
"@thi.ng/equiv": "^0.1.7",
- "@thi.ng/errors": "^0.1.6"
+ "@thi.ng/errors": "^0.1.6",
+ "@thi.ng/strings": "^0.2.0"
},
"keywords": [
"ES6",
diff --git a/packages/transducers/src/func/hex.ts b/packages/transducers/src/func/hex.ts
index 4f67059678..d5228cf139 100644
--- a/packages/transducers/src/func/hex.ts
+++ b/packages/transducers/src/func/hex.ts
@@ -1,8 +1,9 @@
-const ZEROES = "00000000";
+import { radix } from "@thi.ng/strings/radix";
-export function hex(digits = 2, prefix = "") {
- return (x: number) => {
- const s = x.toString(16);
- return prefix + (s.length >= digits ? s : ZEROES.substring(0, digits - s.length) + s);
- }
-}
+/**
+ * @deprecated use thi.ng/strings `radix()` instead
+ *
+ * @param digits
+ * @param prefix
+ */
+export const hex = (digits = 2, prefix = "") => radix(16, digits, prefix);
diff --git a/packages/transducers/src/index.ts b/packages/transducers/src/index.ts
index 9820ad436e..01bb5989dd 100644
--- a/packages/transducers/src/index.ts
+++ b/packages/transducers/src/index.ts
@@ -68,6 +68,7 @@ export * from "./xform/multiplex-obj";
export * from "./xform/noop";
export * from "./xform/pad-last";
export * from "./xform/page";
+export * from "./xform/partition-bits";
export * from "./xform/partition-by";
export * from "./xform/partition-of";
export * from "./xform/partition-sort";
diff --git a/packages/transducers/src/xform/hex-dump.ts b/packages/transducers/src/xform/hex-dump.ts
index 4d38423921..5f9b3bc594 100644
--- a/packages/transducers/src/xform/hex-dump.ts
+++ b/packages/transducers/src/xform/hex-dump.ts
@@ -1,7 +1,8 @@
+import { U8, U32 } from "@thi.ng/strings/radix";
+
import { Transducer } from "../api";
import { comp } from "../func/comp";
-import { hex } from "../func/hex";
import { juxt } from "../func/juxt";
import { map } from "./map";
@@ -29,7 +30,7 @@ import { partition } from "./partition";
export function hexDump(cols = 16, addr = 0): Transducer {
return comp(
padLast(cols, 0),
- map(juxt(hex(), (x) => x > 31 && x < 128 ? String.fromCharCode(x) : ".")),
+ map(juxt(U8, (x) => x > 31 && x < 128 ? String.fromCharCode(x) : ".")),
partition(cols, true),
map(
juxt(
@@ -37,6 +38,6 @@ export function hexDump(cols = 16, addr = 0): Transducer {
(x) => x.map(y => y[1]).join("")
)
),
- mapIndexed((i, [h, a]) => `${hex(8)(addr + i * cols)} | ${h} | ${a}`)
+ mapIndexed((i, [h, a]) => `${U32(addr + i * cols)} | ${h} | ${a}`)
);
}
diff --git a/packages/transducers/src/xform/partition-bits.ts b/packages/transducers/src/xform/partition-bits.ts
new file mode 100644
index 0000000000..bc33d25408
--- /dev/null
+++ b/packages/transducers/src/xform/partition-bits.ts
@@ -0,0 +1,56 @@
+import { Transducer } from "../api";
+import { isReduced } from "../reduced";
+
+/**
+ * Transducer.
+ *
+ * @param fn
+ * @param stateful
+ */
+export function partitionBits(n: number, wordSize = 8): Transducer {
+ return ([init, complete, reduce]) => {
+ const maxb = wordSize - n;
+ const m1 = (1 << wordSize) - 1;
+ const m2 = (1 << n) - 1;
+ let r = 0;
+ let y = 0;
+ return [
+ init,
+ (acc) => complete(r > 0 ? reduce(acc, y) : acc),
+ n < wordSize ?
+ (acc, x) => {
+ let b = 0;
+ do {
+ acc = reduce(acc, y + ((x >>> (maxb + r)) & m2));
+ b += n - r;
+ x = (x << (n - r)) & m1;
+ y = 0;
+ r = 0;
+ } while (b <= maxb && !isReduced(acc));
+ r = wordSize - b;
+ y = r > 0 ? (x >>> maxb) & m2 : 0;
+ return acc;
+ } :
+ n > wordSize ?
+ (acc, x) => {
+ if (r + wordSize <= n) {
+ y |= (x & m1) << (n - wordSize - r);
+ r += wordSize;
+ if (r === n) {
+ acc = reduce(acc, y);
+ y = 0;
+ r = 0;
+ }
+ }
+ else {
+ const k = n - r;
+ r = wordSize - k;
+ acc = reduce(acc, y | ((x >>> r) & ((1 << k) - 1)));
+ y = (x & ((1 << r) - 1)) << (n - r);
+ }
+ return acc;
+ } :
+ reduce
+ ];
+ };
+}
diff --git a/packages/transducers/test/partition-bits.ts b/packages/transducers/test/partition-bits.ts
new file mode 100644
index 0000000000..9e6d09809e
--- /dev/null
+++ b/packages/transducers/test/partition-bits.ts
@@ -0,0 +1,33 @@
+import * as assert from "assert";
+import { radix } from "@thi.ng/strings/radix";
+
+import { comp } from "../src/func/comp";
+import { range } from "../src/iter/range";
+import { iterator } from "../src/iterator";
+import { run } from "../src/run";
+import { bits } from "../src/xform/bits";
+import { map } from "../src/xform/map";
+import { padLast } from "../src/xform/pad-last";
+import { partition } from "../src/xform/partition";
+import { partitionBits } from "../src/xform/partition-bits";
+
+const src = [0xff, 0xa5, 0xfe, 0xf7];
+
+const xform = (n: number) =>
+ comp(partitionBits(n), map(radix(2, n)));
+
+const xformB = (n: number) =>
+ comp(bits(8), padLast(n, 0), partition(n, true), map((x) => x.join("")));
+
+const check = (n: number) =>
+ assert.deepEqual(
+ [...iterator(xform(n), src)],
+ [...iterator(xformB(n), src)],
+ `bits=${n}`
+ );
+
+describe("partitionBits", () => {
+
+ it("all sizes", () => run(map((n: number) => check(n)), range(1, 33)));
+
+});
\ No newline at end of file