Skip to content

Commit 461adee

Browse files
docs(resolve-map): fix thi-ng#35, update docs & tests
1 parent 0673f0f commit 461adee

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

packages/resolve-map/README.md

+12-10
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ Any function values are called using two possible conventions:
5858
2) If no de-structure form is found in the function's arguments, the
5959
function is only called with `resolve` as argument.
6060

61-
**Important:** Since ES6 var names can't contain special characters,
62-
destructured keys can ALWAYS only be looked up as siblings of the
63-
currently processed key.
61+
**Important:** ES6 destructuring can *only* be used for ES6 compile
62+
targets and *will fail when transpiling to ES5*. If you're not sure, use
63+
the 2nd (legacy) form. Also, since ES6 var names can't contain special
64+
characters, destructured keys can ALWAYS only be looked up as siblings
65+
of the currently processed key.
6466

6567
The `resolve` function provided as arg to the user function accepts a
6668
path (**without `@` prefix**) to look up any other values in the root
@@ -135,22 +137,22 @@ import * as tx from "@thi.ng/transducers";
135137
// will be injected later as well
136138
const stats = {
137139
// sequence average
138-
mean: ({src}) => tx.reduce(tx.mean(), src),
140+
mean: ({ src }) => tx.mean(src),
139141
// sequence range
140-
range: ({min,max}) => max - min,
142+
range: ({ min, max }) => max - min,
141143
// computes sequence min val
142-
min: ({src}) => tx.reduce(tx.min(), src),
144+
min: ({ src }) => tx.min(src),
143145
// computes sequence max val
144-
max: ({src}) => tx.reduce(tx.max(), src),
146+
max: ({ src }) => tx.max(src),
145147
// sorted copy
146-
sorted: ({src}) => [...src].sort((a, b) => a - b),
148+
sorted: ({ src }) => [...src].sort((a, b) => a - b),
147149
// standard deviation
148-
sd: ({src, mean})=>
150+
sd: ({ src, mean })=>
149151
Math.sqrt(
150152
tx.transduce(tx.map((x) => Math.pow(x - mean, 2)), tx.add(), src) /
151153
(src.length - 1)),
152154
// compute 10th - 90th percentiles
153-
percentiles: ({sorted}) => {
155+
percentiles: ({ sorted }) => {
154156
return tx.transduce(
155157
tx.map((x) => sorted[Math.floor(x / 100 * sorted.length)]),
156158
tx.push(),

packages/resolve-map/test/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ describe("resolve-map", () => {
7373
it("destructure", () => {
7474
const stats = {
7575
// sequence average
76-
mean: ({ src: a }) => tx.reduce(tx.mean(), a),
76+
mean: ({ src: a }) => tx.mean(a),
7777
// sequence range
7878
range: ({ min, max }) => max - min,
7979
// computes sequence min val
80-
min: ({ src }) => tx.reduce(tx.min(), src),
80+
min: ({ src }) => tx.min(src),
8181
// computes sequence max val
82-
max: ({ src }) => tx.reduce(tx.max(), src),
82+
max: ({ src }) => tx.max(src),
8383
// sorted copy
8484
sorted: ({ src }) => [...src].sort((a, b) => a - b),
8585
// standard deviation

0 commit comments

Comments
 (0)