本文整理汇总了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);
}