本文整理汇总了TypeScript中util.inspect函数的典型用法代码示例。如果您正苦于以下问题:TypeScript inspect函数的具体用法?TypeScript inspect怎么用?TypeScript inspect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了inspect函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: format
const plylogPrettify = format((info: TransformableInfo, opts: any) => {
if (info[SPLAT]) {
for (const splat of info[SPLAT]) {
info.message += '\n' + inspect(splat, false, opts.depth || null, opts.colorize);
}
}
info[MESSAGE] = `${info.level}:${info.message}`;
return info;
});
示例2: constructor
constructor(node: Base, message: string | null = null) {
let prefix = message ? `${message}\n\n` : '';
super(`${prefix}node type '${node.constructor.name}' is not supported: ${inspect(node)}`);
// https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
Object.setPrototypeOf(this, UnsupportedNodeError.prototype);
this.node = node;
}
示例3: it
it("encodes and decodes a future date (timestamp 96)", () => {
const date = new Date(0x400000000 * 1000);
const encoded = defaultCodec.tryToEncode(date);
assert.deepStrictEqual(
defaultCodec.decode(encoded!.data, EXT_TIMESTAMP),
date,
`date: ${date.toISOString()}, encoded: ${util.inspect(encoded)}`,
);
});
示例4: function
log = function (...msg: any[]) {
let out: string[] = [];
for (let m of msg) {
if (typeof(m) === "string") {
out.push(m);
} else if (m instanceof Array) {
for (let i = 0; i < m.length; ++i) {
out.push("\n" + i + ": " +
util.inspect(m[i], { depth: null, colors: true }));
}
} else {
out.push(util.inspect(m, { depth: null, colors: true }));
}
}
// Work around a TypeScript limitation:
// https://github.com/Microsoft/TypeScript/issues/4755
console.log(out[0], ...out.slice(1));
}
示例5: handleRequestSpecs
handleRequestSpecs(method, args, res) {
const filename = args[0];
logger.debug(`requested specs for ${filename}`);
// Can return null if there is nothing defined in plugin
const plugin = this.getPlugin(filename, { noCreateInstance: true });
const specs = (plugin && plugin.specs) || [];
res.send(specs);
logger.debug(`specs: ${util.inspect(specs)}`);
}
示例6: it
it('should return a summary', function() {
const container = createContainer().register({
val1: asValue(1),
val2: asValue(2),
fn1: asFunction(() => true),
c1: asClass(Repo)
})
expect(util.inspect(container)).toBe(
'[AwilixContainer (registrations: 4)]'
)
expect(
util.inspect(container.createScope().register({ val3: asValue(3) }))
).toBe('[AwilixContainer (scoped, registrations: 5)]')
expect(container.resolve('inspect')).toBeInstanceOf(Function)
expect(container.resolve(util.inspect.custom)).toBeInstanceOf(Function)
})
示例7: function
session.getId(), statusObj, function(error: Error, automate_session: any) {
if (error) {
throw new BrowserError(
logger, 'Error updating BrowserStack pass/fail status: ' + util.inspect(error));
} else {
logger.info(automate_session);
deferred.resolve();
}
});
示例8:
items = items.map(item => {
if (item instanceof Error) {
return item.stack;
}
if (R.is(Object, item)) {
// Object formatted with colors (JSON).
return nodeUtil.inspect(item, false, undefined, true);
}
return item;
});
示例9: validateVega
function validateVega(vegaSpec: VgSpec) {
const valid = validateVg(vegaSpec);
const errors = validateVg.errors;
if (!valid) {
console.log(inspect(errors, {depth: 10, colors: true}));
}
expect(errors && errors.map((err: Ajv.ErrorObject) => err.message).join(', ')).toBeNull();
expect(valid).toBe(true);
}