node-stringify is a JavaScript utility for serializing objects into a string representation that can be directly re-evaluated using JavaScript's `eval()` function. Unlike `JSON.stringify`, it aims to preserve more JavaScript-specific constructs like `Date` objects, `RegExp`, and `function` definitions, making the output directly executable. The current stable version is 0.2.1. Given its low version number and the inherent security risks associated with `eval`, this library is not intended for general-purpose data serialization or secure environments. It explicitly warns against its use as a `JSON.stringify` replacement and does not support circular references or deeply nested objects due to its recursive implementation.
npm install node-stringifyVerified import paths — ran on the pinned version, not inferred.
Demonstrates stringifying various JavaScript data types, including numbers, strings, null, undefined, dates, functions, arrays, and objects, showing output with and without optional parentheses.
For general data serialization, always use `JSON.stringify()` and `JSON.parse()`. If you must re-evaluate code, ensure the source is entirely trusted and controlled.
Ensure that objects passed to `stringify` do not contain circular references. Manual pre-processing to remove or replace circular references might be necessary, or consider alternatives that handle them (e.g., `flatted` or custom JSON replacers).
If you need the object literal without parentheses, pass `{ parenthesis: false }` as the second argument: `stringify(obj, { parenthesis: false })`.Evaluate if this specific functionality is critical. If so, consider porting the necessary logic into your own codebase or finding a more actively maintained alternative if one exists for `eval`-targeted serialization. Otherwise, migrate to standard serialization methods.
Refactor your object structure to avoid circular dependencies, or manually remove/replace offending properties before stringifying. The library is not designed to handle these cases.
Use the CommonJS `require` syntax: `const stringify = require('node-stringify');`No dependency data recorded yet.