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