mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
ndjson: initial definition (#43073)
This commit is contained in:
parent
043b939aa2
commit
0fbd4beb75
19
types/ndjson/index.d.ts
vendored
Normal file
19
types/ndjson/index.d.ts
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
// Type definitions for ndjson 1.5
|
||||
// Project: https://github.com/maxogden/ndjson
|
||||
// Definitions by: Junxiao Shi <https://github.com/yoursunny>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import { ThroughStream } from "through";
|
||||
import { DuplexOptions, Transform } from "stream";
|
||||
|
||||
export interface ParseOptions {
|
||||
strict?: boolean;
|
||||
}
|
||||
|
||||
export function parse(opts?: ParseOptions): ThroughStream;
|
||||
|
||||
export function serialize(opts?: DuplexOptions): Transform;
|
||||
|
||||
export function stringify(opts?: DuplexOptions): Transform;
|
||||
15
types/ndjson/ndjson-tests.ts
Normal file
15
types/ndjson/ndjson-tests.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import * as ndjson from "ndjson";
|
||||
import * as fs from "fs";
|
||||
|
||||
let parser = ndjson.parse();
|
||||
parser = ndjson.parse({ strict: true });
|
||||
|
||||
fs.createReadStream("data.txt")
|
||||
.pipe(parser)
|
||||
.on("data", (obj) => undefined);
|
||||
|
||||
let serialize = ndjson.serialize();
|
||||
serialize = ndjson.stringify({ encoding: "ascii" });
|
||||
serialize.on("data", (line) => undefined);
|
||||
serialize.write({ foo: "bar" });
|
||||
serialize.end();
|
||||
23
types/ndjson/tsconfig.json
Normal file
23
types/ndjson/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"ndjson-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/ndjson/tslint.json
Normal file
1
types/ndjson/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user