Skip to content

Commit

Permalink
Fixing dump("indexes") such that Map keys remain the correct type
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Sep 3, 2020
1 parent 43a842a commit bc72535
Show file tree
Hide file tree
Showing 6 changed files with 644 additions and 1,063 deletions.
24 changes: 14 additions & 10 deletions lib/haro.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @author Jason Mulligan <jason.mulligan@avoidwork.com>
* @copyright 2020
* @license BSD-3-Clause
* @version 8.0.3
* @version 8.0.4
*/
"use strict";

Expand Down Expand Up @@ -189,16 +189,20 @@
}

dump (type = "records") {
const result = type === "records" ? Array.from(this.entries()) : Object.fromEntries(this.indexes);
let result;

if (type === "indexes") {
for (const key of Object.keys(result)) {
result[key] = Object.fromEntries(result[key]);
if (type === "records") {
result = Array.from(this.entries());
} else {
result = Array.from(this.indexes).map(i => {
i[1] = Array.from(i[1]).map(ii => {
ii[1] = Array.from(ii[1]);

for (const lkey of Object.keys(result[key])) {
result[key][lkey] = Array.from(result[key][lkey]);
}
}
return ii;
});

return i;
});
}

return result;
Expand Down Expand Up @@ -473,7 +477,7 @@
return obj;
}

factory.version = "8.0.3";
factory.version = "8.0.4";

// Node, AMD & window supported
if (typeof exports !== "undefined") {
Expand Down
4 changes: 2 additions & 2 deletions lib/haro.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bc72535

Please sign in to comment.