当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript fast-json-stable-stringify.default函数代码示例

本文整理汇总了TypeScript中fast-json-stable-stringify.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了default函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1:

  const reporter: ChangeReporter = (path, parent, node, old, current) => {
    if (options.listener) {
      if (old === current || stableStringify(old) === stableStringify(current)) {
        return;
      }

      const op = old === undefined ? 'add' : current === undefined ? 'remove' : 'replace';
      options.listener(
        op,
        path,
        parent,
        current,
      );
    }
  };
开发者ID:angular,项目名称:angular-cli,代码行数:15,代码来源:utilities.ts

示例2: getStoreKeyName

export function getStoreKeyName(
  fieldName: string,
  args?: Object,
  directives?: Directives,
): string {
  if (
    directives &&
    directives['connection'] &&
    directives['connection']['key']
  ) {
    if (
      directives['connection']['filter'] &&
      (directives['connection']['filter'] as string[]).length > 0
    ) {
      const filterKeys = directives['connection']['filter']
        ? (directives['connection']['filter'] as string[])
        : [];
      filterKeys.sort();

      const queryArgs = args as { [key: string]: any };
      const filteredArgs = {} as { [key: string]: any };
      filterKeys.forEach(key => {
        filteredArgs[key] = queryArgs[key];
      });

      return `${directives['connection']['key']}(${JSON.stringify(
        filteredArgs,
      )})`;
    } else {
      return directives['connection']['key'];
    }
  }

  let completeFieldName: string = fieldName;

  if (args) {
    // We can't use `JSON.stringify` here since it's non-deterministic,
    // and can lead to different store key names being created even though
    // the `args` object used during creation has the same properties/values.
    const stringifiedArgs: string = stringify(args);
    completeFieldName += `(${stringifiedArgs})`;
  }

  if (directives) {
    Object.keys(directives).forEach(key => {
      if (KNOWN_DIRECTIVES.indexOf(key) !== -1) return;
      if (directives[key] && Object.keys(directives[key]).length) {
        completeFieldName += `@${key}(${JSON.stringify(directives[key])})`;
      } else {
        completeFieldName += `@${key}`;
      }
    });
  }

  return completeFieldName;
}
开发者ID:cj5,项目名称:fantasy-golf-server,代码行数:56,代码来源:storeUtils.ts

示例3: stableStringify

      const newHandler = (argument: A, context: JobHandlerContext<A, I, O>) => {
        const argumentJson = stableStringify(argument);
        const maybeJob = runs.get(argumentJson);

        if (maybeJob) {
          return maybeJob;
        }

        const run = handler(argument, context).pipe(
          replayMessages ? shareReplay() : share(),
        );
        runs.set(argumentJson, run);

        return run;
      };
开发者ID:DevIntent,项目名称:angular-cli,代码行数:15,代码来源:strategy.ts

示例4: constructor

  constructor(config: Config.ProjectConfig) {
    this._config = config;
    this._transformCache = new Map();

    let projectCache = projectCaches.get(config);

    if (!projectCache) {
      projectCache = {
        configString: stableStringify(this._config),
        ignorePatternsRegExp: calcIgnorePatternRegexp(this._config),
        transformedFiles: new Map(),
      };

      projectCaches.set(config, projectCache);
    }

    this._cache = projectCache;
  }
开发者ID:Volune,项目名称:jest,代码行数:18,代码来源:ScriptTransformer.ts

示例5: hash

export function hash(a: any): string | number {
  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 < 250) {
    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:vega,项目名称:vega-lite,代码行数:21,代码来源:util.ts

示例6: generateSchemaHash

export function generateSchemaHash(schema: GraphQLSchema): string {
  const introspectionQuery = getIntrospectionQuery();
  const documentAST = parse(introspectionQuery);
  const result = execute(schema, documentAST) as ExecutionResult;

  // If the execution of an introspection query results in a then-able, it
  // indicates that one or more of its resolvers is behaving in an asynchronous
  // manner.  This is not the expected behavior of a introspection query
  // which does not have any asynchronous resolvers.
  if (
    result &&
    typeof (result as PromiseLike<typeof result>).then === 'function'
  ) {
    throw new Error(
      [
        'The introspection query is resolving asynchronously; execution of an introspection query is not expected to return a `Promise`.',
        '',
        'Wrapped type resolvers should maintain the existing execution dynamics of the resolvers they wrap (i.e. async vs sync) or introspection types should be excluded from wrapping by checking them with `graphql/type`s, `isIntrospectionType` predicate function prior to wrapping.',
      ].join('\n'),
    );
  }

  if (!result || !result.data || !result.data.__schema) {
    throw new Error('Unable to generate server introspection document.');
  }

  const introspectionSchema: IntrospectionSchema = result.data.__schema;

  // It's important that we perform a deterministic stringification here
  // since, depending on changes in the underlying `graphql-js` execution
  // layer, varying orders of the properties in the introspection
  const stringifiedSchema = stableStringify(introspectionSchema);

  return createSHA('sha512')
    .update(stringifiedSchema)
    .digest('hex');
}
开发者ID:apollostack,项目名称:apollo-server,代码行数:37,代码来源:schemaHash.ts

示例7: stableStringify

 return `Set(${[...this].map(x => stableStringify(x)).join(',')})`;
开发者ID:vega,项目名称:vega-lite,代码行数:1,代码来源:util.ts


注:本文中的fast-json-stable-stringify.default函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。