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


TypeScript json-stable-stringify.default方法代码示例

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


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

示例1: testFn

 testFn(fullTestName, () => {
   let input = readFileSync(join(dir, 'input.coffee'), { encoding: 'utf8' });
   let actual = stripExtraInfo(stripContext(parse(input, {useCS2})));
   writeFileSync(join(dir, `_actual_${useCS2 ? 'cs2' : 'cs1'}.json`), stringify(actual, {space: 2}), { encoding: 'utf8' });
   if (process.env['OVERWRITE_EXPECTED_OUTPUT'] === 'true') {
     writeFileSync(join(dir, 'output.json'), stringify(actual, {space: 2}), { encoding: 'utf8' });
   }
   let expected = JSON.parse(readFileSync(join(dir, 'output.json'), { encoding: 'utf8' }));
   deepEqual(actual, expected);
 });
开发者ID:alangpierce,项目名称:decaffeinate-parser,代码行数:10,代码来源:test.ts

示例2: stringify

 .map(e => {
   const paramsKey = stringify(e.params)
   if (betterMessagesByParams[paramsKey]) {
     return betterMessagesByParams[paramsKey]
   }
   const params = Object.keys(e.params)
     .map(key => `${key}: ${e.params[key]}`)
     .join(', ')
   debug(stringify(e.params))
   return `${name}${e.dataPath} ${e.message}. ${params}`
 })
开发者ID:dhruvcodeword,项目名称:prisma,代码行数:11,代码来源:yaml.ts

示例3: merge

/*
 * Entity Entry Formatter
 */
async function merge(specEntries: StatusEntry[][]): Promise<MergedStatusEntry> {
    const merged = await normalizer.merge(specEntries);

    const text = stringify(merged, {
        replacer: (key: string, mapOrSet: Map<any, any> | Set<any>): any => {
            if (mapOrSet instanceof Map) {
                const obj = {};
                for (const pair of mapOrSet) {
                    obj[pair[0]] = pair[1];
                }
                return obj;
            }
            
            if (mapOrSet instanceof Set) {
                const array = [];
                for (const value of mapOrSet) {
                    array.push(value);
                }
                return array.sort();
            }

            return mapOrSet;
        },
        space: '\t',
    });

    await writeFile('data.json', text);
    
    return merged;
}
开发者ID:takenspc,项目名称:ps-data-normalizer,代码行数:33,代码来源:cli.ts

示例4: normalize

/*
 * Status Entry Formatter
 */
async function normalize(): Promise<StatusEntry[][]> {
    const specEntries = await normalizer.normalize();

    const text = stringify(specEntries);

    await writeFile('raw.json', text);

    return specEntries;
}
开发者ID:takenspc,项目名称:ps-data-normalizer,代码行数:12,代码来源:cli.ts

示例5: getPage

    public getPage(
        resultSpec: AFM.IResultSpec,
        limit: number[] = [],
        offset: number[] = []
    ): Promise<Execution.IExecutionResponses> {
        const resultSpecFingerprint = stringify(resultSpec);
        if (!this.responseFactory) {
            throw new Error('Missing responseFactory!');
        }
        if (!this.executionPromises[resultSpecFingerprint]) {
            this.executionPromises[resultSpecFingerprint] = this.responseFactory(resultSpec);
        }

        return this.executionPromises[resultSpecFingerprint].then(
            (executionResponse: Execution.IExecutionResponse) => {
                if (!this.resultFactory) {
                    throw new Error('Missing resultFactory!');
                }

                const safeOffset = offset.map((offsetItem = 0) => offsetItem);

                const safeLimit = limit.map((limitItem = DEFAULT_LIMIT) => {
                    const safeLimitItem = Math.min(limitItem, DEFAULT_LIMIT);
                    if (safeLimitItem < limitItem) {
                        // tslint:disable-next-line:no-console
                        console.warn('The maximum limit per page is ' + DEFAULT_LIMIT);
                    }
                    return safeLimitItem;
                });

                return this.resultFactory(
                    executionResponse.links.executionResult,
                    safeLimit,
                    safeOffset
                ).then(
                        (executionResult: Execution.IExecutionResult | null) => ({
                            executionResult,
                            executionResponse
                        })
                    );
            }
        );
    }
开发者ID:gooddata,项目名称:gooddata-js,代码行数:43,代码来源:DataSource.ts

示例6: stringifyOld

const stringify = (options:StringifyOptions = {}) => (obj:any) => stringifyOld(obj, options);
开发者ID:r-k-b,项目名称:newsblur-feed-info,代码行数:1,代码来源:index.ts

示例7: hash

export function hash(a: any) {
  if (isString(a) || isNumber(a) || isBoolean(a)) {
    return String(a);
  }
  return stringify(a);
}
开发者ID:glimpseio,项目名称:vega-lite,代码行数:6,代码来源:util.ts

示例8: getFingerprint

 public getFingerprint(): string {
     return this.fingerprint ? this.fingerprint : stringify(this.afm);
 }
开发者ID:gooddata,项目名称:gooddata-js,代码行数:3,代码来源:DataSource.ts

示例9: it

    it('should return correct fingerprint', () => {
        const execFactory = () => Promise.resolve({});
        const dataSource = new DataSource(execFactory, afm);

        expect(dataSource.getFingerprint()).toEqual(stringify(afm));
    });
开发者ID:gooddata,项目名称:gooddata-js,代码行数:6,代码来源:DataSource.spec.ts


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