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; });
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; }
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)}`, ); });
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)); }
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)}`); }
it("encodes and decodes a date with milliseconds (timestamp 64)", () => { const date = new Date(1556633024123); const encoded = defaultCodec.tryToEncode(date); assert.deepStrictEqual( defaultCodec.decode(encoded!.data, EXT_TIMESTAMP), date, `date: ${date.toISOString()}, encoded: ${util.inspect(encoded)}`, ); });
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) })
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(); } });
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; });
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); }