本文整理匯總了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')
};
}