/ piacw.com / dev / final / node_modules / javascript-stringify /

[ICO]NameLast modifiedSizeDescription
[PARENTDIR]Parent Directory  -  
[DIR]dist/2 years ago -  
[   ]LICENSE2 years ago1.1K0fb859dc fixed mobile overflwo options [كارل مبارك]
[TXT]README.md2 years ago3.1K0fb859dc fixed mobile overflwo options [كارل مبارك]
[   ]package.json2 years ago2.7K0fb859dc fixed mobile overflwo options [كارل مبارك]
README.md

JavaScript Stringify

NPM version NPM downloads Build status Test coverage

Stringify is to eval as JSON.stringify is to JSON.parse.

Installation

npm install javascript-stringify --save

Buy Me A Coffee

Usage

import { stringify } from "javascript-stringify";

The API is similar JSON.stringify:

Examples

stringify({}); // "{}"
stringify(true); // "true"
stringify("foo"); // "'foo'"

stringify({ x: 5, y: 6 }); // "{x:5,y:6}"
stringify([1, 2, 3, "string"]); // "[1,2,3,'string']"

stringify({ a: { b: { c: 1 } } }, null, null, { maxDepth: 2 }); // "{a:{b:{}}}"

/**
 * Invalid key names are automatically stringified.
 */

stringify({ "some-key": 10 }); // "{'some-key':10}"

/**
 * Some object types and values can remain identical.
 */

stringify([/.+/gi, new Number(10), new Date()]); // "[/.+/gi,new Number(10),new Date(1406623295732)]"

/**
 * Unknown or circular references are removed.
 */

var obj = { x: 10 };
obj.circular = obj;

stringify(obj); // "{x:10}"
stringify(obj, null, null, { references: true }); // "(function(){var x={x:10};x.circular=x;return x;}())"

/**
 * Specify indentation - just like `JSON.stringify`.
 */

stringify({ a: 2 }, null, " "); // "{\n a: 2\n}"
stringify({ uno: 1, dos: 2 }, null, "\t"); // "{\n\tuno: 1,\n\tdos: 2\n}"

/**
 * Add custom replacer behaviour - like double quoted strings.
 */

stringify(["test", "string"], function(value, indent, stringify) {
  if (typeof value === "string") {
    return '"' + value.replace(/"/g, '\\"') + '"';
  }

  return stringify(value);
});
//=> '["test","string"]'

License

MIT

Apache/2.4.38 (Debian) Server at www.karls.computer Port 80