當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript util.inspect函數代碼示例

本文整理匯總了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;
});
開發者ID:Polymer,項目名稱:plylog,代碼行數:9,代碼來源:index.ts

示例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;
  }
開發者ID:alangpierce,項目名稱:decaffeinate-parser,代碼行數:9,代碼來源:UnsupportedNodeError.ts

示例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)}`,
   );
 });
開發者ID:msgpack,項目名稱:msgpack-javascript,代碼行數:9,代碼來源:ExtensionCodec.test.ts

示例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));
 }
開發者ID:Microsoft,項目名稱:staticstaging,代碼行數:18,代碼來源:ssc.ts

示例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)}`);
 }
開發者ID:billyvg,項目名稱:node-client,代碼行數:9,代碼來源:index.ts

示例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)
    })
開發者ID:jeffijoe,項目名稱:awilix,代碼行數:18,代碼來源:container.test.ts

示例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();
   }
 });
開發者ID:DylanLacey,項目名稱:protractor,代碼行數:9,代碼來源:browserStack.ts

示例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;
 });
開發者ID:philcockfield,項目名稱:js-util-log,代碼行數:10,代碼來源:log.ts

示例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);
}
開發者ID:vega,項目名稱:vega-lite,代碼行數:10,代碼來源:examples.test.ts


注:本文中的util.inspect函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。