当前位置: 首页>>代码示例>>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;未经允许,请勿转载。