Socket
Socket
Sign inDemoInstall

js-stringify

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    js-stringify

Stringify an object so it can be safely inlined in JavaScript code


Version published
Weekly downloads
1.6M
decreased by-1.56%
Maintainers
1
Install size
4.61 kB
Created
Weekly downloads
 

Readme

Source

js-stringify

Stringify an object so it can be safely inlined in JavaScript code

Build Status Dependency Status NPM version

Installation

npm install js-stringify

Usage


var assert = require('assert');
var stringify = require('js-stringify');

assert(stringify('foo') === '"foo"');
assert(stringify('foo\u2028bar\u2029baz') === '"foo\\u2028bar\\u2029baz"');
assert(stringify(new Date('2014-12-19T03:42:00.000Z')) === 'new Date("2014-12-19T03:42:00.000Z")');
assert(stringify({foo: 'bar'}) === '{"foo":"bar"}');
assert(stringify(undefined) === 'undefined');
assert(stringify(null) === 'null');
assert(
  stringify({val: "</script><script>alert('bad actor')</script>"}) ===
  '{"val":"\\u003C\\u002Fscript\\u003E\\u003Cscript\\u003Ealert(\'bad actor\')\\u003C\\u002Fscript\\u003E"}'
);

License

MIT

FAQs

Last updated on 28 Sep 2015

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc