本文整理汇总了TypeScript中json-bignum.parse函数的典型用法代码示例。如果您正苦于以下问题:TypeScript parse函数的具体用法?TypeScript parse怎么用?TypeScript parse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: AsyncByteQueue
async function *recordBatchReaders(createSourceStream: () => NodeJS.ReadableStream) {
let json = new AsyncByteQueue();
let stream = new AsyncByteQueue();
let source = createSourceStream();
let reader: RecordBatchReader | null = null;
let readers: AsyncIterable<RecordBatchReader> | null = null;
// tee the input source, just in case it's JSON
source.on('end', () => [stream, json].forEach((y) => y.close()))
.on('data', (x) => [stream, json].forEach((y) => y.write(x)))
.on('error', (e) => [stream, json].forEach((y) => y.abort(e)));
try {
for await (reader of RecordBatchReader.readAll(stream)) {
reader && (yield reader);
}
if (reader) return;
} catch (e) { readers = null; }
if (!readers) {
await json.closed;
if (source instanceof fs.ReadStream) { source.close(); }
// If the data in the `json` ByteQueue parses to JSON, then assume it's Arrow JSON from a file or stdin
try {
for await (reader of RecordBatchReader.readAll(bignumJSONParse(await json.toString()))) {
reader && (yield reader);
}
} catch (e) { readers = null; }
}
}
开发者ID:emkornfield,项目名称:arrow,代码行数:30,代码来源:arrow2csv.ts
示例2: catch
files.forEach((source) => {
let table: Arrow.Table, input = fs.readFileSync(source);
try {
table = Arrow.Table.from(input);
} catch (e) {
table = Arrow.Table.from(parse(input + ''));
}
if (argv.schema && argv.schema.length) {
table = table.select(...argv.schema);
}
table.rowsToString().pipe(process.stdout);
});
开发者ID:sunchao,项目名称:arrow,代码行数:12,代码来源:arrow2csv.ts
示例3: printTable
function printTable(input: any) {
let table: Table;
try {
table = Table.from(input);
} catch (e) {
table = Table.from(parse(input + ''));
}
if (argv.schema && argv.schema.length) {
table = table.select(...argv.schema);
}
table.rowsToString().pipe(process.stdout);
}
开发者ID:CodingCat,项目名称:arrow,代码行数:12,代码来源:arrow2csv.ts
示例4: catch
files.forEach((source) => {
let table: any, input = fs.readFileSync(source);
try {
table = Arrow.Table.from([input]);
} catch (e) {
table = Arrow.Table.from(parse(input + ''));
}
if (argv.schema && argv.schema.length) {
table = table.select(...argv.schema);
}
printTable(table);
});
开发者ID:giantwhale,项目名称:arrow,代码行数:12,代码来源:arrow2csv.ts
示例5: Error
if (!process.env.JSON_PATH || !process.env.ARROW_PATH) {
throw new Error('Integration tests need paths to both json and arrow files');
}
const jsonPath = path.resolve(process.env.JSON_PATH + '');
const arrowPath = path.resolve(process.env.ARROW_PATH + '');
if (!fs.existsSync(jsonPath) || !fs.existsSync(arrowPath)) {
throw new Error('Integration tests need both json and arrow files to exist');
}
/* tslint:disable */
const { parse } = require('json-bignum');
const jsonData = parse(fs.readFileSync(jsonPath, 'utf8'));
const arrowBuffers: Uint8Array[] = [fs.readFileSync(arrowPath)];
import Arrow from '../Arrow';
import { zip } from 'ix/iterable/zip';
import { toArray } from 'ix/iterable/toArray';
const { Table, read } = Arrow;
expect.extend({
toEqualVector(v1: any, v2: any) {
const format = (x: any, y: any, msg= ' ') => `${
this.utils.printExpected(x)}${
msg}${
this.utils.printReceived(y)
开发者ID:giantwhale,项目名称:arrow,代码行数:30,代码来源:validate-tests.ts
注:本文中的json-bignum.parse函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论