mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
feat(zen-push): adding types for zen-push (#20476)
This commit is contained in:
parent
28e995bbff
commit
5b6f5ef807
16
types/zen-push/index.d.ts
vendored
Normal file
16
types/zen-push/index.d.ts
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
// Type definitions for zen-push 0.1
|
||||
// Project: https://github.com/zenparsing/zen-push
|
||||
// Definitions by: daprahamian <https://github.com/daprahamian>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import * as Observable from 'zen-observable';
|
||||
|
||||
declare class PushStream<T> {
|
||||
readonly observable: Observable<T>;
|
||||
readonly observed: number;
|
||||
next(x: T): void;
|
||||
error(e: Error): void;
|
||||
complete(x?: any): void;
|
||||
}
|
||||
|
||||
export default PushStream;
|
||||
23
types/zen-push/tsconfig.json
Normal file
23
types/zen-push/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"zen-push-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/zen-push/tslint.json
Normal file
1
types/zen-push/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
21
types/zen-push/zen-push-tests.ts
Normal file
21
types/zen-push/zen-push-tests.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import PushStream from 'zen-push';
|
||||
import * as Observable from 'zen-observable';
|
||||
|
||||
function assert(val: boolean) {
|
||||
if (!val) {
|
||||
throw new Error('Assertion Failure');
|
||||
}
|
||||
}
|
||||
|
||||
const stream1 = new PushStream<number>();
|
||||
|
||||
assert(stream1.observable instanceof Observable);
|
||||
assert(typeof stream1.observed === 'number');
|
||||
|
||||
stream1.next(15);
|
||||
|
||||
stream1.next(23);
|
||||
|
||||
stream1.error(new Error('test 123'));
|
||||
|
||||
stream1.complete();
|
||||
Loading…
Reference in New Issue
Block a user