Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stream-transform-from): create a new package (#68)
* chore(stream-transform-from): create directory for `@sounisi5011/stream-transform-from` package * test(stream-transform-from): add tests * test(stream-transform-from): remove the `createPipeline()` function from test code * feat(stream-transform-from): add a type definition for the public API * feat(stream-transform-from): add `transformFrom()` function and `TransformFromAsyncIterable` class * fix(stream-transform-from): change the complex `createSource()` method to a simple `createSource()` function * test(stream-transform-from): fix the tests + Re-create the `Transform` object every time testing. + Simplify tests that differ only in options with `describe.each()`. * refactor(stream-transform-from): use the `catch()` method instead of the `try ... catch` statement * fix(stream-transform-from): don't call the callback multiple times & call the callback passed to `_flush()` method after finish * test(stream-transform-from): use the `break` keyword while transforming a stream * fix(stream-transform-from): use the `break` keyword while transforming a stream * refactor(stream-transform-from): refactoring the `TransformFromAsyncIterable` class + Rename the `done` property to `transformCallback + Rename the `callDoneFn` method to `callTransformCallback` + Remove the `pushError` method and add `finish` method in its place * test(stream-transform-from): add tests + Added a test that returns multiple chunks + Added a test for the type of chunks contained in the source * fix(stream-transform-from): fix the type definition of return values If there is a possibility that either the `objectMode` or the `readableObjectMode` option is not `true`, the return value should not be `unknown`. * test(stream-transform-from): add a test to merge multiple chunks * fix(stream-transform-from): `transformCallback` should be called when the next chunk is needed, not after transforming a chunk * test(stream-transform-from): add type definition tests * fix(stream-transform-from): fix `InputChunkType` Index signatures and `boolean` types are now supported. * test(stream-transform-from): add type definition tests for output values * docs(stream-transform-from): add example code * test(stream-transform-from): add a test for the timing of data flowing in the stream * test(stream-transform-from): fix the timing test for data flowing in the stream I noticed that the timing of the flow changes when using the asynchronous API. * test(stream-transform-from): eliminate the PromiseRejectionHandledWarning Promise objects should only be created in tests. Creating it during test case generation could cause Promise errors to affect unrelated code. * test(stream-transform-from): fix the timing test for data flowing in the stream We have not found a way to control when data is read from the Readable stream. * fix(stream-transform-from): create a source iterator in the constructor * refactor(stream-transform-from): remove `src/utils.ts` * refactor(stream-transform-from): reduce Cognitive Complexity in the `TransformFromAsyncIterable#finish()` method Code Climate reported: + Function `finish` has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. * test(stream-transform-from): add tests that inherit from the `TransformFromAsyncIterable` class * revert: test(stream-transform-from): add tests that inherit from the `TransformFromAsyncIterable` class This reverts commit 28e9901. * test(stream-transform-from): add tests to convert strings of different encodings * feat(stream-transform-from): can use the encoding passed with the chunk * feat(stream-transform-from): export some types * test(stream-transform-from): can't get the error after processing all chunks see nodejs/node#34274 * test(stream-transform-from): the bug with not being able to get errors after processing all chunks has been fixed in Node v15 * test(stream-transform-from): fix the bug that no error occurs after getting all the chunks This bug has been fixed in Node.js v15. + https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V15.md#15.0.0 + nodejs/node#34314 However, we have found a workaround that works for anything less than Node.js v15, so we will attempt to fix this bug in this package. * fix(stream-transform-from): fix the bug that no error occurs after getting all the chunks * test(stream-transform-from): make the conditional branches of the test code readable and organized * test(stream-transform-from): refactoring test code * build(stream-transform-from): disable the inlineSources option in TypeScript The size of the package is now smaller if `src` directory contents are included. * docs(stream-transform-from): add `README.md` * ci(stream-transform-from): add custom publish scripts * docs(stream-transform-from): update `README.md` * test(stream-transform-from): add tests for options that should be ignored * fix(stream-transform-from): ignore some options * fix(stream-transform-from): add "construct" in the options to ignore * docs(stream-transform-from): update `README.md`: add fields that are disallowed in options * refactor(stream-transform-from): don't use the global object `process` * docs(stream-transform-from): fix the code for the example in `README.md` * refactor(stream-transform-from): move utility type functions to the top of file * style(stream-transform-from): update `src/index.ts`
- Loading branch information