ram64
Version:
Multi-threaded 64bit memory cache database inspired by redis-like features
35 lines (34 loc) • 827 B
JavaScript
;
exports.fn = void 0;
var _shards = require("../shards");
var _promises = require("fs/promises");
const fn = async (opts)=>{
const { dirPath } = opts.args;
for (let shard of _shards.Shards){
const filePath = `${dirPath}/shard${shard.shardIndex}.json`;
const arr = [
...shard.map
];
const json = JSON.stringify(arr, replacer);
await (0, _promises).writeFile(filePath, json);
}
};
exports.fn = fn;
function replacer(key, value) {
if (value instanceof Map) {
return {
$map: [
...value
]
};
} else if (value instanceof Set) {
return {
$set: [
...value
]
};
} else {
return value;
}
}
//# sourceMappingURL=save.js.map