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