• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript d3-array.pairs函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: it

    it('should return empty and non-empty consecutive buckets', async () => {
      const start = EARLIEST_TIME_WITH_DATA;
      const end = LATEST_TIME_WITH_DATA + (LATEST_TIME_WITH_DATA - EARLIEST_TIME_WITH_DATA);
      const bucketSize = Math.ceil((end - start) / 10);

      const {
        data: {
          source: { logSummaryBetween },
        },
      } = await client.query<any>({
        query: logSummaryBetweenQuery,
        variables: {
          start,
          end,
          bucketSize,
        },
      });

      expect(logSummaryBetween).to.have.property('buckets');
      expect(logSummaryBetween.buckets).to.have.length(10);
      expect(
        logSummaryBetween.buckets.filter((bucket: any) => bucket.entriesCount > 0)
      ).to.have.length(5);
      expect(
        pairs(
          logSummaryBetween.buckets,
          (first: any, second: any) => first.end === second.start
        ).every(pair => pair)
      ).to.equal(true);
    });
开发者ID:,项目名称:,代码行数:30,代码来源:


示例2: Uint8ClampedArray

crossed = d3Array.cross<string, number>(readonlyChars, readonlyNums);

strArray = d3Array.cross<number, number, string>([2, 3] as ReadonlyArray<number>, new Uint8ClampedArray([5, 6]), (a, b) => (a + b) + 'px');
strArray = d3Array.cross([2, 3] as ReadonlyArray<number>, new Uint8ClampedArray([5, 6]), (a, b) => {
    const aa: number = a;
    const bb: number = b;
    return (aa + bb) + 'px';
});

d3Array.cross(new Uint8Array([1, 2, 3, 4, 5]), new Uint8Array([10, 20, 30, 40, 50]));

// pairs() ---------------------------------------------------------------------

let pairs: Array<[MixedObject, MixedObject]>;

pairs = d3Array.pairs(mergedArray);

numbersArray = d3Array.pairs<MixedObject, number>(mergedArray, (a, b) => b.num - a.num);
numbersArray = d3Array.pairs(mergedArray, (a, b) => {
    const aa: MixedObject = a;
    const bb: MixedObject = b;
    return bb.num - aa.num;
});

const readonlyMergedArray = mergedArray as ReadonlyArray<MixedObject>;
pairs = d3Array.pairs(readonlyMergedArray);

numbersArray = d3Array.pairs<MixedObject, number>(readonlyMergedArray, (a, b) => b.num - a.num);
numbersArray = d3Array.pairs(readonlyMergedArray, (a, b) => {
    const aa: MixedObject = a;
    const bb: MixedObject = b;
开发者ID:itslenny,项目名称:DefinitelyTyped,代码行数:31,代码来源:d3-array-tests.ts


示例3: return

crossed = d3Array.cross(['x', 'y'], [1, 2]);
crossed = d3Array.cross<string, number>(['x', 'y'], [1, 2]);

let strArray: string[] = d3Array.cross<number, number, string>([2, 3], [5, 6], (a, b) => (a + b) + 'px');
strArray = d3Array.cross([2, 3], [5, 6], (a, b) => {
    let aa: number = a;
    let bb: number = b;
    return (aa + bb) + 'px';
});


// pairs() ---------------------------------------------------------------------

let pairs: Array<[MixedObject, MixedObject]>;

pairs = d3Array.pairs(mergedArray);

numbersArray = d3Array.pairs<MixedObject, number>(mergedArray, (a, b) => b.num - a.num);
numbersArray = d3Array.pairs(mergedArray, (a, b) => {
    let aa: MixedObject = a;
    let bb: MixedObject = b;
    return bb.num - aa.num;
});

// permute() -------------------------------------------------------------------

// getting a permutation of array elements
mergedArray = d3Array.permute(mergedArray, [1, 0, 2, 5, 3, 4, 6]);

// Getting an ordered array with object properties
开发者ID:Kroisse,项目名称:DefinitelyTyped,代码行数:30,代码来源:d3-array-tests.ts


示例4: MixedObject

        new MixedObject(50, new Date(2016, 9, 30)),
    ]
];


let mergedArray: MixedObject[];

mergedArray = d3Array.merge(testArrays); // inferred type
mergedArray = d3Array.merge<MixedObject>(testArrays); // explicit type
// mergedArray = d3.merge<MixedObject>([[10, 40, 30], [15, 30]]); // fails, type mismatch

// pairs() ---------------------------------------------------------------------

let pairs: Array<[MixedObject, MixedObject]>;

pairs = d3Array.pairs(mergedArray);

// permute() -------------------------------------------------------------------

// getting a permutation of array elements
mergedArray = d3Array.permute(mergedArray, [1, 0, 2, 5, 3, 4, 6]);

// Getting an ordered array with object properties

let testObject = {
    val: 10,
    name: 'Test',
    when: new Date(),
    more: [10, 30, 40]
};
开发者ID:DmitryEfimenko,项目名称:DefinitelyTyped,代码行数:30,代码来源:d3-array-tests.ts


示例5: pairs

const isSorted = <Value>(comparator: (first: Value, second: Value) => number) => (
  values: Value[]
) => pairs(values, comparator).every(order => order <= 0);
开发者ID:,项目名称:,代码行数:3,代码来源:



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript d3-array.quantile函数代码示例发布时间:2022-05-24
下一篇:
TypeScript d3-array.min函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap