New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add: typings #7
Add: typings #7
Conversation
index.d.ts
Outdated
|
||
export function stringifyInfo( | ||
value: any, | ||
replacer?: ((this: any, key: string, value: any) => any) | undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if a field is optional foo?:
then there is no need | undefined
here and below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I just only copy typing from JSON.stringify
. Fixed
index.d.ts
Outdated
|
||
export function parseChunked<T>(stream: Readable | Generator<any, void, unknown>): Promise<T>; | ||
|
||
export function stringifyStream(value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): Readable; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets move replacer function into a separate type to make code more clearer )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replacer accepts array of string and numbers either (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've used https://github.com/microsoft/TypeScript/blob/main/lib/lib.es5.d.ts#L1059 and Fixed
index.d.ts
Outdated
continueOnCircular?: boolean; | ||
} | ||
): { | ||
minLength: Number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
number
for consistency
index.d.ts
Outdated
declare module '@discoveryjs/json-ext' { | ||
import { Readable } from 'stream'; | ||
|
||
export function parseChunked<T>(stream: Readable | Generator<any, void, unknown>): Promise<T>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need any generic (T
) here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function should return Promise<any>
. It would be nice to add typings on generator w/o any/unknown if possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some notes above
cbfd163
to
1cf581f
Compare
index.d.ts
Outdated
declare module '@discoveryjs/json-ext' { | ||
import { Readable } from 'stream'; | ||
|
||
type TReplacer = (this: any, key: string, value: any) => AnalyserNode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why AnalyserNode
was used here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missprint(((
index.d.ts
Outdated
declare module '@discoveryjs/json-ext' { | ||
import { Readable } from 'stream'; | ||
|
||
type TReplacer = (this: any, key: string, value: any) => any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
index.d.ts
Outdated
|
||
type TReplacer = (this: any, key: string, value: any) => any; | ||
|
||
export function parseChunked(stream: Readable | (() => AsyncGenerator<any, any, any>)): Promise<any>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there should be something like:
export function parseChunked(input: Generator<string, never, void> | AsyncGenerator<string, never, void> | (() => (Iterable<string> | AsyncIterable<string>))): Promise<any>;
a5709e0
to
7d9db70
Compare
LGTM |
@lahmatiy Cool, can you bump npm version? |
@lexich Done. Published as 0.5.4 |
@lexich My bad, 0.5.4 didn't contain |
No description provided.