本文整理汇总了TypeScript中circular-json.stringify函数的典型用法代码示例。如果您正苦于以下问题:TypeScript stringify函数的具体用法?TypeScript stringify怎么用?TypeScript stringify使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了stringify函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: computeData
function computeData(data) {
if (data && util.isObject(data)) {
if (data instanceof Error) {
data = { message: data.message, error: data.stack };
}
if (typeof(data.toLogObj) === 'function') {
return CircularJSON.stringify(snipsecret(data.toLogObj()));
} else {
return CircularJSON.stringify(snipsecret(data));
}
} else {
return data;
}
}
示例2: __beforeEach
/**
* Automatically triggered before each called method.
* Allow to execute some code that will be executed by all methods of all controllers.
*
* @param req Request.
* @param res Response.
* @param callback Function to execute.
* @param options Object that contains options.
* @private
*/
private __beforeEach(req, res, callback: any, options: any = {}){
// Default user.
if(!req.session.user){
req.session.user = {
// Ensure that we always know if the user is logged in or not and what is default access is.
connected: false,
};
}
// Add debug information.
// TODO Use express middleware instead...
console.log('-------------------- start -------------------', 'debug');
console.log('Url: ' + req.method + ' ' + req.baseUrl + req._parsedUrl.href, 'debug');
if(!_.isEmpty(req.body)){
console.log('Parameters: ' + JSON.stringify(req.body), 'debug');
}
console.log('Options: ' + CircularJSON.stringify(options), 'debug');
console.log('Route: ' + req.route.method + ' => ' + req.path + ' (' + req.route.regexp + ')', 'debug');
if(typeof req.headers.cookie !== "undefined"){
console.log('Cookies: ' + req.headers.cookie, 'debug');
}
if(typeof req.headers['user-agent'] !== "undefined"){
console.log('User agent: ' + req.headers['user-agent'], 'debug');
}
console.log('Session: ' + JSON.stringify(req.session), 'debug');
console.log('---------------------------------------', 'debug');
// Once we have done the stuff common to all methods, execute the actual callback.
callback(req, res, options);
}
示例3: function
descriptor.value = function (...args: any[]) {
if (_.isNil(this) || _.isNil(this.action)) {
return originalMethod.apply(this, args);
}
let action = !_.isNil(this.action) ? this.action : this.dynamicComponent.inputs['action'];
let result = undefined;
const data = getLocalData();
const code = getLangCode(data);
const group = getGroup(groups, data); // session.User;
const acl = getAcl(acls, data);
langFile = _.find(langFiles, { code: code })['file'];
if (isAdminUser(group, acl)) {
// call function if access is granted
result = originalMethod.apply(this, args);
} else {
if (canExecuteAction(group, group.Acl, action)) {
result = originalMethod.apply(this, args);
} else {
showWarning(langFile['WarnInsufficientRights'], langFile['Error']);
}
}
console.log(`Calling: ${fn}(${args}) => ${json.stringify(result)}`);
return result;
};
示例4:
.map(object => CircularJSON.stringify(object));
示例5: setObject
public setObject(key: string, value: any): void {
this.localStorage[key] = circularJson.stringify(value);
}
示例6: debugLogWrap
descriptor.value = function debugLogWrap(...args) {
const now = Date.now();
console.log(`-> ${this.constructor.name}.${method} with ${args.length} args -> ${CircularJSON.stringify(args)}`);
const toRet = old.apply(this, args);
if (toRet instanceof Promise) {
return toRet
.then((res) => {
console.log(`<- ${this.constructor.name}.${method} in ${Date.now() - now} with Promise(${CircularJSON.stringify(res)})`);
return res;
})
.catch((err) => {
let theErrMessage: string = err;
if (err instanceof Error) {
theErrMessage = err.message;
}
console.log(`<- ${this.constructor.name}.${method} in ${Date.now() - now} with Promise.reject('${theErrMessage}')`);
return Promise.reject(err);
});
} else {
console.log(`<- ${this.constructor.name}.${method} in ${Date.now() - now} with ${CircularJSON.stringify(toRet)}`);
return toRet;
}
};
示例7: Promise
.then((res) => {
console.log(`<- ${this.constructor.name}.${method} in ${Date.now() - now} with Promise(${CircularJSON.stringify(res)})`);
return res;
})
示例8: objectToJson
static objectToJson(val): string {
enforce(val).isNotNull();
return circularJson.stringify(val);
}