Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report

serialize-javascript 6.0.2

Serialize JavaScript to a superset of JSON that includes regular expressions and functions.
Package summary
Share
0
issues
0
licenses
Package created
16 Sep 2014
Version published
9 Jan 2024
Maintainers
3
Total deps
0
Direct deps
0
License
BSD-3-Clause
Generating a report...
Hold on while we generate a fresh audit report for this package.

Frequently Asked Questions

What does serialize-javascript do?

Serialize-javascript is a powerful npm package that converts JavaScript to a superset of JSON that includes regular expressions, functions, dates, sets, and maps. Its initial creation was as an internal module to express-state. However, due to its wide range of applicability, it now exists as serialize-javascript, a standalone package on npm. This tool allows seamless serialization of JavaScript on both the server and client sides and can be especially efficient for web applications using client-side URL routing.

How do you use serialize-javascript?

To use serialize-javascript, firstly, install the package using npm by running npm install serialize-javascript in your terminal. Once installed, import it in your JavaScript file with var serialize = require('serialize-javascript');. Then you can simply call serialize() function on your JavaScript object.

Example usage:

var serialize = require('serialize-javascript');

serialize({
    str  : 'string',
    num  : 0,
    obj  : {foo: 'foo'},
    arr  : [1, 2, 3],
    bool : true,
    nil  : null,
    undef: undefined,
    inf  : Infinity,
    date : new Date("Thu, 28 Apr 2016 22:02:17 GMT"),
    map  : new Map([['hello', 'world']]),
    set  : new Set([123, 456]),
    fn   : function echo(arg) { return arg; },
    re   : /([^\s]+)/g,
    big  : BigInt(10),
});

Where are the serialize-javascript docs?

The documentation for serialize-javascript can be found in the README file on the GitHub repository at git+https://github.com/yahoo/serialize-javascript.git. The README file is highly informative and contains a comprehensive guide on installation, usage, available options, and deserialization process.