UNPKG

@naimi/alib

Version:
79 lines (30 loc) 1 kB
//! nodejs only lib jscript = 0; WScript = {}; fs = require('fs'); var alib = require('../shared/alib'); console.log(alib.default); const stringify = require("json-stringify-pretty-compact"); del = function (fn) { try { if (fn.includes("function")) { console.log("del - wrong fn: " + fn); return -1; } fs.unlink(fn, function (error) { if (error) { console.log("del - wrong fn2: " + error); } }); } catch (err) { console.log(err.message); } } beautify = function (str) { var json_opts = { indent: 2, //! Defaults to 2. Works exactly like the third parameter of JSON.stringify. maxLength: 67, //! Defaults to 80. Lines will be tried to be kept at maximum this many characters long. Infinity //! replacer: undefined, //! Defaults to undefined. Works exactly like the second parameter of JSON.stringify. } return stringify(JSON.parse(str), json_opts) }