本文整理汇总了TypeScript中ix/iterable/zip.zip函数的典型用法代码示例。如果您正苦于以下问题:TypeScript zip函数的具体用法?TypeScript zip怎么用?TypeScript zip使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了zip函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
(() => {
let i = -1;
for (let [x1, x2] of zip(v1, v2)) {
++i;
if (!util.createElementComparator(x2)(x1)) {
iteratorFailures.push(`${i}: ${format(this, x1, x2, ' !== ')}`);
}
}
})();
示例2: test
test(`json and arrow buffers report the same values`, () => {
expect.hasAssertions();
const jsonVectors = toArray(read(jsonData));
const binaryVectors = toArray(read(arrowBuffers));
for (const [jVectors, bVectors] of zip(jsonVectors, binaryVectors)) {
expect(jVectors.length).toEqual(bVectors.length);
for (let i = -1, n = jVectors.length; ++i < n;) {
(expect(jVectors[i]) as any).toEqualVector(bVectors[i]);
}
}
});
示例3: test
test(`json and arrow record batches report the same values`, () => {
expect.hasAssertions();
const jsonRecordBatches = toArray(read(jsonData));
const binaryRecordBatches = toArray(read(arrowBuffer));
for (const [jsonRecordBatch, binaryRecordBatch] of zip(jsonRecordBatches, binaryRecordBatches)) {
expect(jsonRecordBatch.length).toEqual(binaryRecordBatch.length);
expect(jsonRecordBatch.numCols).toEqual(binaryRecordBatch.numCols);
for (let i = -1, n = jsonRecordBatch.numCols; ++i < n;) {
(jsonRecordBatch.getChildAt(i) as any).name = jsonRecordBatch.schema.fields[i].name;
(expect(jsonRecordBatch.getChildAt(i)) as any).toEqualVector(binaryRecordBatch.getChildAt(i));
}
}
});
示例4: getFileBuffer
.map((p) => path.resolve(p))
.map((p) => {
if (fs.existsSync(p)) {
return p;
}
console.error(`Could not find file "${p}"`);
return undefined;
});
}
const getOrReadFileBuffer = ((cache: any) => function getFileBuffer(path: string, ...args: any[]) {
return cache[path] || (cache[path] = fs.readFileSync(path, ...args));
})({});
const jsonAndArrowPaths = toArray(zip(
resolvePathArgs(process.env.JSON_PATHS!),
resolvePathArgs(process.env.ARROW_PATHS!)
))
.filter(([p1, p2]) => p1 !== undefined && p2 !== undefined) as [string, string][];
expect.extend({
toEqualVector([v1, format1, columnName]: [any, string, string], [v2, format2]: [any, string]) {
const format = (x: any, y: any, msg= ' ') => `${
this.utils.printExpected(x)}${
msg}${
this.utils.printReceived(y)
}`;
let getFailures = new Array<string>();
let propsFailures = new Array<string>();
let iteratorFailures = new Array<string>();
示例5:
for (let i = -1, n = props.length; ++i < n;) {
const prop = props[i];
if (this.utils.stringify(v1[prop]) !== this.utils.stringify(v2[prop])) {
propsFailures.push(`${prop}: ${format(v1[prop], v2[prop], ' !== ')}`);
}
}
for (let i = -1, n = v1.length; ++i < n;) {
let x1 = v1.get(i), x2 = v2.get(i);
if (this.utils.stringify(x1) !== this.utils.stringify(x2)) {
getFailures.push(`${i}: ${format(x1, x2, ' !== ')}`);
}
}
let i = -1;
for (let [x1, x2] of zip(v1, v2)) {
++i;
if (this.utils.stringify(x1) !== this.utils.stringify(x2)) {
iteratorFailures.push(`${i}: ${format(x1, x2, ' !== ')}`);
}
}
return {
pass: allFailures.every(({ failures }) => failures.length === 0),
message: () => [
`${v1.name}: (${format('json', 'arrow', ' !== ')})\n`,
...allFailures.map(({ failures, title }) =>
!failures.length ? `` : [`${title}:`, ...failures].join(`\n`))
].join('\n')
};
}