
Company News
Socket Partners with Replit to Block Malicious Packages in AI-Powered Development
Replit is integrating Socket Firewall into its AI-powered development experience to help protect builders from malicious open source packages.
Serializes circular references and other unserializable types like Dates, .prototype and functions to JSON.
Serializes circular references and other unserializable types like Dates, .prototype and functions to JSON.
| Type | JSON.stringify | Serially.serialize |
|---|---|---|
| Strings | Yes | Yes |
| Numbers | Yes | Yes |
| Dates | As a string | Yes |
| NaN / Infinity / Undefined | No | Yes |
| Circular references | No | Yes |
| Functions | No | Yes |
| Native functions | No | Yes* |
npm install --save serially
var should = require("chai");
var expect = chai.expect;
chai.should();
var serially = require("serially");
var toBeSerialized = {
int: 1,
float: 2.99e81,
str: "test",
obj: {
int: 1,
str: "test"
},
nullValue: null,
arrayValue: [{}],
infinityValue: Infinity,
negInfinityValue: -Infinity,
nanValue: NaN,
dateValue: new Date(),
func: function(a, b) {
return a + b;
}
};
toBeSerialized.circularReference = toBeSerialized;
//Serialize the whole graph to a string
var str = serially.serialize(toBeSerialized);
//Deserialize the graph
var deserialized = serially.deserialize(str);
toBeSerialized.int.should.equal(deserialized.int);
toBeSerialized.str.should.equal(deserialized.str);
toBeSerialized.float.should.equal(deserialized.float);
toBeSerialized.obj.int.should.equal(deserialized.obj.int);
toBeSerialized.obj.str.should.equal(deserialized.obj.str);
expect(toBeSerialized.nullValue).to.equal(deserialized.nullValue);
toBeSerialized.infinityValue.should.equal(deserialized.infinityValue);
toBeSerialized.negInfinityValue.should.equal(deserialized.negInfinityValue);
expect(deserialized.nanValue).to.be.NaN;
toBeSerialized.func.toString().should.equal(deserialized.func.toString());
deserialized.func(2, 2).should.equal(4);
deserialized.circularReference.circularReference.circularReference.circularReference.should.equal(deserialized);
Pull requests are welcome, please file any bugs on https://github.com/tsavo/serially
FAQs
Serializes circular references and other unserializable types like Dates, .prototype and functions to JSON.
The npm package serially receives a total of 5 weekly downloads. As such, serially popularity was classified as not popular.
We found that serially 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.

Company News
Replit is integrating Socket Firewall into its AI-powered development experience to help protect builders from malicious open source packages.

Security News
npm confirmed a tooling bug incorrectly marked several one-character packages as security holders and said it was working on a rollback.

Research
/Security News
Newer packages in this compromise use native extensions and .pth loaders to execute JavaScript stealers in developer environments.