Skip to content

Commit

Permalink
refactor(examples): update crypto-chart to use @thi.ng/strings
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Aug 8, 2018
1 parent df067d8 commit 56d64c5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
1 change: 1 addition & 0 deletions examples/crypto-chart/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
7 changes: 2 additions & 5 deletions examples/crypto-chart/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 56d64c5

Please sign in to comment.