Skip to content

Commit

Permalink
fix(resolve-map): add support for alt ES6 destructure form {a: b}
Browse files Browse the repository at this point in the history
- also fixes issue w/ minimized builds
  • Loading branch information
postspectacular committed Jul 15, 2018
1 parent 08a7600 commit 2482945
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/resolve-map/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getIn, mutIn } from "@thi.ng/paths";

const SEMAPHORE = Symbol("SEMAPHORE");

const RE_ARGS = /^(function\s+\w+)?\s*\(\{([\w\s,]+)\}/
const RE_ARGS = /^(function\s+\w+)?\s*\(\{([\w\s,:]+)\}/

export type ResolveFn = (path: string) => any;

Expand Down Expand Up @@ -212,6 +212,7 @@ const resolveFunction = (fn: (x: any, r?: ResolveFn) => any, resolve: ResolveFn,
const args = match[2]
.replace(/\s/g, "")
.split(/,/g)
.map((k) => k.split(":")[0])
.reduce((acc, k) => (acc[k] = resolve(k), acc), {});
res = fn(args, resolve);
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/resolve-map/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe("resolve-map", () => {
it("destructure", () => {
const stats = {
// sequence average
mean: ({ src }) => tx.reduce(tx.mean(), src),
mean: ({ src: a }) => tx.reduce(tx.mean(), a),
// sequence range
range: ({ min, max }) => max - min,
// computes sequence min val
Expand Down

0 comments on commit 2482945

Please sign in to comment.