JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8846
  • Score
    100M100P100Q121146F
  • License MIT

Package Exports

  • node-stringify

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (node-stringify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

node-stringify Build Status

Install

npm install node-stringify --save

Example

var stringify = require('node-stringify');

console.assert(stringify(123) === '123');

console.assert(stringify('abc') === '\'abc\'');

console.assert(stringify(null) === 'null');

console.assert(stringify(undefined) === 'undefined');

console.assert(stringify(new Date(1000)) === 'new Date(1000)');

console.assert(stringify(function (a,b,c) {}) === 'function (a,b,c) {}');

console.assert(stringify([1, 2, 3]) === '[1,2,3]');

// The parenthesis is to make the result work with `eval`
console.assert(stringify({a: 1, b: 2}) === '({a:1,b:2})');

console.assert(stringify({a: 1, b: [2, 3]}) === '({a:1,b:[2,3]})');

Supported types

  • null
  • undefined
  • number
  • string
  • date
  • regexp
  • function
  • array
  • object

Difference with JSON.stringify

  • node-stringify is designed to work with all kinds of objects in javascript. JSON.stringify is designed to work with objects.

  • The result of node-stringify can be retrieved directly using eval.

License

MIT License