Decorators #43
Closed
johngeorgewright
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
It could be an idea to create method decorators that become stream pulls/writers etc. For example:
In the above example the
barmethod would be wrapped in aReadableStreamthat will continuously callbaruntil thedesiredSizehas been fulfilled. This would turn the function signature from:... to ...
So we could use it like so:
We could take it a step further by adding a
writerdecorator to simplify the piping:This would turn the function signature from:
... to ...
Meaning we could use it like:
NOTE: This proposal cannot be achieved in TypeScript as decorators that modify function signatures are considered an anti-pattern. However, this is still under consideration, and if they were to choose to accept it the above could be implemented.
Beta Was this translation helpful? Give feedback.
All reactions