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


TypeScript json-stable-stringify.default函數代碼示例

本文整理匯總了TypeScript中json-stable-stringify.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了default函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: default

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export default (obj: any): string => {
  if (Array.isArray(obj) && obj.length === 0) {
    return "[]";
  } else if (typeof obj === "object" && Object.keys(obj).length === 0) {
    return "{}";
  }

  return stringify(obj, { space: 2 });
};
開發者ID:jlenoble,項目名稱:generator-wupjs,代碼行數:10,代碼來源:stringify.ts

示例2: callback

		fs.stat(filePath, (err:Error, stats:fs.Stats) => {
			if (err) {
				return callback(err, false, null);
			}
			else if (!stats.isFile() && !stats.isDirectory()) {
				return callback(new Error('PathValidator.validateStats: The specified path is not a valid file or directory. "' + filePath + '"'), false, null);
			}

			// remove device id from stats
			if (statsToValidate.dev) {
				delete statsToValidate.dev;
			}

			delete stats.dev;

			// remove time of last access from stats
			if (statsToValidate.atime) {
				delete statsToValidate.atime;
			}

			delete stats.atime;

			// @see http://stackoverflow.com/a/1144249
			var isValid:boolean = stringify(stats) === stringify(statsToValidate);

			callback(null, isValid, stats);

		});
開發者ID:jcostantini,項目名稱:core,代碼行數:28,代碼來源:PathValidator.ts

示例3: to_key

export function to_key(s: any): string {
  if (immutable.Map.isMap(s)) {
    s = s.toJS();
  }
  // NOTE: s is not undefined.
  return json_stable(s) as string;
}
開發者ID:DrXyzzy,項目名稱:smc,代碼行數:7,代碼來源:util.ts

示例4: to_key

export function to_key(x: string[] | string | undefined): string | undefined {
  if (typeof x === "object") {
    return json_stable_stringify(x);
  } else {
    return x;
  }
}
開發者ID:DrXyzzy,項目名稱:smc,代碼行數:7,代碼來源:util.ts

示例5: output

export function output(v: any[]): string {
  let s = "";
  let x: any;
  for (x of v) {
    if (x.content == null) continue;
    if (x.content.data != null) {
      return json(x.content.data);
    }
    if (x.content.text != null) {
      s += x.content.text;
    }
    if (x.content.ename != null) {
      return json(x.content);
    }
  }
  return s;
}
開發者ID:DrXyzzy,項目名稱:smc,代碼行數:17,代碼來源:common.ts

示例6: stringify

 format: (fields: Fields) => {
   const value = fields[formattingInstruction.field];
   return [
     {
       field: formattingInstruction.field,
       value: typeof value === 'object' ? stringify(value) : `${value}`,
       highlights: [],
     },
   ];
 },
開發者ID:njd5475,項目名稱:kibana,代碼行數:10,代碼來源:message.ts

示例7: add_shortcut

 function add_shortcut(s: any, name: any, val: any) {
   if (s.mode == null) {
     for (let mode of ["escape", "edit"]) {
       add_shortcut(merge(s, { mode }), name, val);
     }
     return;
   }
   shortcut_to_command[json(s)] = { name, val };
   if (s.alt) {
     s = copy_without(s, "alt");
     s.meta = true;
     return add_shortcut(s, name, val);
   }
 }
開發者ID:DrXyzzy,項目名稱:smc,代碼行數:14,代碼來源:keyboard.ts

示例8: if

 columns: logColumns.map(logColumn => {
   if (SavedSourceConfigurationTimestampColumnRuntimeType.is(logColumn)) {
     return {
       timestamp: document.key.time,
     };
   } else if (SavedSourceConfigurationMessageColumnRuntimeType.is(logColumn)) {
     return {
       message: formatLogMessage(document.fields),
     };
   } else {
     return {
       field: logColumn.fieldColumn.field,
       value: stringify(document.fields[logColumn.fieldColumn.field] || null),
     };
   }
 }),
開發者ID:elastic,項目名稱:kibana,代碼行數:16,代碼來源:log_entries_domain.ts

示例9: hash

export function hash(a: any) {
  if (isNumber(a)) {
    return a;
  }

  const str = isString(a) ? a : stableStringify(a);

  // short strings can be used as hash directly, longer strings are hashed to reduce memory usage
  if (str.length < 100) {
    return str;
  }

  // from http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/
  let h = 0;
  for (let i = 0; i < str.length; i++) {
    const char = str.charCodeAt(i);
    h = ((h<<5)-h)+char;
    h = h & h; // Convert to 32bit integer
  }
  return h;
}
開發者ID:troystribling,項目名稱:dotfiles,代碼行數:21,代碼來源:util.ts

示例10: synctable

export function synctable(
  query,
  options,
  client,
  throttle_changes : undefined | number,
  use_cache : boolean = true
): SyncTable {
  if (options == null) {
    options = [];
  }
  if (!use_cache) {
    return new SyncTable(query, options, client, throttle_changes);
  }

  const cache_key = json_stable_stringify({
    query,
    options,
    throttle_changes
  });
  let S: SyncTable | undefined = synctables[cache_key];
  if (S != null) {
    if (S.get_state() === "connected") {
      // same behavior as newly created synctable
      emit_connected_in_next_tick(S);
    }
  } else {
    S = synctables[cache_key] = new SyncTable(
      query,
      options,
      client,
      throttle_changes
    );
    S.cache_key = cache_key;
  }
  S.reference_count += 1;
  return S;
}
開發者ID:DrXyzzy,項目名稱:smc,代碼行數:37,代碼來源:global-cache.ts


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