Skip to content

Commit c472b77

Browse files
committed
Fix tiny typo and add "PERCENT" formula function
1 parent 40c5ff7 commit c472b77

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/formula-functions.svelte.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,15 @@ functions.dollars = undefinedArgsToIdentity(function (d) {
134134
return d;
135135
});
136136

137+
const percentFormat = new Intl.NumberFormat("en-US", {
138+
style: "percent",
139+
maximumFractionDigits: 4,
140+
});
141+
functions.percent = function (p) {
142+
this.element = document.createTextNode(percentFormat.format(p));
143+
return p;
144+
};
145+
137146
functions.sparkbars = (...args) => {
138147
const lines = "▁▂▃▄▅▆▇█";
139148
const min = Math.min(...args),

src/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function debounce(f, delay, max = undefined) {
1717
}
1818

1919
export function sum(l) {
20-
return l.reduce((x, accum) => x + accum, 0);
20+
return l.reduce((accum, x) => accum + x, 0);
2121
}
2222

2323
// Wrap a function such that its args are automatically converted to additive

0 commit comments

Comments
 (0)