@undici-plus/streamer 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/WEADME.md +15 -0
- package/index.mts +21 -0
- package/package.json +14 -0
package/WEADME.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @undici-plus/streamer
|
|
2
|
+
Transforms anything into a stream
|
|
3
|
+
## USE
|
|
4
|
+
You can use it like so:
|
|
5
|
+
```ts
|
|
6
|
+
import Streamer from "@undici-plus/streamer"
|
|
7
|
+
|
|
8
|
+
const stream = Streamer<string>("Hello, World!")
|
|
9
|
+
|
|
10
|
+
stream.pipe((value)=>...)
|
|
11
|
+
|
|
12
|
+
stream.log() // Hello, World!
|
|
13
|
+
|
|
14
|
+
stream.throw() // ERROR: Hello, World!
|
|
15
|
+
```
|
package/index.mts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
type Stream<T> = {
|
|
2
|
+
pipe: (callback: (value: T) => void) => void;
|
|
3
|
+
throw: () => never;
|
|
4
|
+
log: () => void;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function newStream<A>(o: A): Stream<A> {
|
|
8
|
+
return {
|
|
9
|
+
pipe: function (callback) {
|
|
10
|
+
callback(o)
|
|
11
|
+
},
|
|
12
|
+
throw: function () {
|
|
13
|
+
throw o
|
|
14
|
+
},
|
|
15
|
+
log: function () {
|
|
16
|
+
console.log(o)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default newStream
|
package/package.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@undici-plus/streamer",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Transforms anything into a stream",
|
|
5
|
+
"main": "index.mts",
|
|
6
|
+
"keywords": [],
|
|
7
|
+
"author": "",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"readme": "WEADME.md",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
13
|
+
}
|
|
14
|
+
}
|