本文整理匯總了TypeScript中json-stringify-safe.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了default函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: handleObjectData
function handleObjectData(param, level: Level) {
//#region @backend
if (istartedInVscode()) {
consoleLog(param, level);
return;
}
let out = stringify(param, null, 4)
out = replace(out, /\".*"\:\ \"/g, /\"\: "/, chalk.green);
out = replace(out, /\".*"\:\ \{/g, /\"\: \{/, chalk.yellow);
out = replace(out, /\".*"\:\ \[/g, /\"\: \[/, chalk.red);
out = replace(out, /\".*"\:\ true/g, /\"\: true/, chalk.blue);
out = replace(out, /\".*"\:\ false/g, /\"\: false/, chalk.blue);
out = replace(out, /\".*"\:\ (\-|[0-9])/g, /\"\: (\-|[0-9])/, chalk.magenta);
out = out.replace(/\"/g, chalk.dim('"'))
.replace(/\{/g, chalk.dim('{'))
.replace(/\}/g, chalk.dim('}'))
.replace(/\}/g, chalk.dim('}'))
if (process.stdout.columns && process.stdout.columns > 0) {
out = out.split('\n').map(line => {
return (line.length < process.stdout.columns ?
line :
line.slice(0, process.stdout.columns - 6) + chalk.dim('...'));
}).join('\n');
}
consoleLog(out, level);
//#endregion
}
示例2: transform
transform(value: any): any {
var stringify = require('json-stringify-safe');
var json = stringify(value);
// console.log('stringified', json);
if ( json ) {
return JSON.parse(json);
} else {
return '';
}
}
示例3: setData
setData(fields) {
Object
.keys(fields)
.forEach(key => {
this._data[key] = fields[key];
});
this._data.__lastUpdated = Date.now();
// In page-bus, we must send non-identical data.
// Otherwise, it'll cache and won't trigger.
// That's why we are setting the __lastUpdated value here.
this._bus.emit(this.getDataKey(), stringify(this.getData()));
this._handlers.forEach(handler => handler(this.getData()));
}
示例4: stringify
this.executeCmd(req.body.command, (err: any, result: any) => {
if (err) {
return res.send({ result: err.message || err });
}
let response = result;
if (typeof result !== "string") {
response = stringify(result, jsonFunctionReplacer, 2);
} else {
// Avoid HTML injection in the Cockpit
response = escapeHtml(response);
}
const jsonResponse = {result: response};
if (res.headersSent) {
return res.end(jsonResponse);
}
return res.send(jsonResponse);
});
示例5: stringify
.map(action => stringify(action, null, 2))
示例6: jss
function jss(x: any) {
return _jss(x, null, 2);
}