UNPKG

stromjs

Version:

Dependency-free streams utils for Node.js

18 lines (17 loc) 545 B
"use strict"; exports.__esModule = true; exports.stringify = void 0; var stream_1 = require("stream"); function stringify(options) { if (options === void 0) { options = { pretty: false }; } return new stream_1.Transform({ readableObjectMode: true, writableObjectMode: true, transform: function (chunk, encoding, callback) { callback(undefined, options.pretty ? JSON.stringify(chunk, null, 2) : JSON.stringify(chunk)); } }); } exports.stringify = stringify;