Skip to content
This repository was archived by the owner on Sep 3, 2022. It is now read-only.

Commit 01f29dc

Browse files
Replace @ndhoule/foldl with Array.prototype.reduce (#186)
1 parent eec02e1 commit 01f29dc

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

HISTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 4.0.2 / 2020-09-01
2+
3+
- Replace @ndhoule/foldl with Array.prototype.reduce
4+
15
# 4.0.1 / 2020-08-21
26

37
- Minor version bump since previous version was published incorrectly. No code change.

lib/analytics.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -939,17 +939,13 @@ Analytics.prototype._parseQuery = function(query: string): SegmentAnalytics {
939939
function pickPrefix(prefix: string, object: object) {
940940
var length = prefix.length;
941941
var sub;
942-
return foldl(
943-
function(acc, val, key) {
944-
if (key.substr(0, length) === prefix) {
945-
sub = key.substr(length);
946-
acc[sub] = val;
947-
}
948-
return acc;
949-
},
950-
{},
951-
object
952-
);
942+
return Object.keys(object).reduce(function(acc, key) {
943+
if (key.substr(0, length) === prefix) {
944+
sub = key.substr(length);
945+
acc[sub] = object[key];
946+
}
947+
return acc;
948+
}, {});
953949
}
954950
};
955951

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"dependencies": {
3333
"@ndhoule/defaults": "^2.0.1",
3434
"@ndhoule/extend": "^2.0.0",
35-
"@ndhoule/foldl": "^2.0.1",
3635
"@ndhoule/includes": "^2.0.1",
3736
"@ndhoule/keys": "^2.0.0",
3837
"@ndhoule/pick": "^2.0.0",

0 commit comments

Comments
 (0)