Skip to content

Commit

Permalink
v0.1.18: reduce-kv
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Sep 5, 2023
1 parent e7d5de1 commit 274501c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

[Squint](https://github.com/squint-cljs/squint): ClojureScript syntax to JavaScript compiler

## 0.1.18

- Add `reduce-kv`

## 0.1.17

- [#320](https://github.com/squint-cljs/squint/issues/320): fix overriding core vars
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "squint-cljs",
"type": "module",
"sideEffects": false,
"version": "0.1.17",
"version": "0.1.18",
"files": [
"core.js",
"src/squint/core.js",
Expand Down
1 change: 1 addition & 0 deletions resources/squint/core.edn
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
range
re_matches
reduce
reduce_kv
reduced
reduced_QMARK_
remove
Expand Down
11 changes: 11 additions & 0 deletions src/squint/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1221,3 +1221,14 @@ export function add_watch(ref, key, fn) {
export function remove_watch(ref, key) {
return ref._remove_watch(key);
}

export function reduce_kv(f, init, m) {
if (!m) {
return init;
}
var ret = init;
for (let o of Object.entries(m)) {
ret = f(ret, o[0], o[1]);
}
return ret;
}

0 comments on commit 274501c

Please sign in to comment.