
Security News
Django Joins curl in Pushing Back on AI Slop Security Reports
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
node-serialization
Advanced tools
A serialization library for node. Serialize/Deserialize a huge object to/from a file.
A serialization library for node. Serialize/Deserialize a huge object to/from a file.
Using v8 Serialization API as default. You can provide custom serialization functions, like JSON(stringify/parse), json-stream-stringify, etc.
const { readFile, writeFile } = require("node-serialization");
Write a object to a file and read the file restore a object.
var path = "cache.data";
var data = {
foo: "bar",
};
writeFile(path, data).then(() => console.log("saved"));
readFile(path).then((data) => console.log(data));
Use a custom serialization method.
const { serialization } = require("node-serialization");
const serialize = function (object) {
return JSON.stringify(object);
};
const deserialize = function (string) {
return JSON.parse(string);
};
const { readFile: readJsonFile, writeFile: writeJsonFile } = serialization(
serialize,
deserialize
);
var path = "cache.json";
var data = {
foo: "bar",
};
writeJsonFile(path, data).then(() => console.log("saved"));
readJsonFile(path).then((data) => console.log(data));
Deserialize a file then serialize into another file with different serialization.
const {
convert,
serializeJson,
deserialize: deserializeV8,
} = require("node-serialization");
convert(
"cache.data",
deserializeV8,
"cache.data.json",
serializeJson
).catch((err) => console.error(err));
If file
parameter is a file path (type is string, not a buffer or a file descriptor), the writeXxx
functions will write content to a temporary file while writing, and rename to the path of file
parameter when success. So even if an exception(such as OOM) occurs, the file will not be a file with content loss.
Copyright (c) 2020 dailyrandomphoto. Licensed under the MIT license.
FAQs
A serialization library for node. Serialize/Deserialize a huge object to/from a file.
The npm package node-serialization receives a total of 29 weekly downloads. As such, node-serialization popularity was classified as not popular.
We found that node-serialization demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.