@unional/async-context 8.0.2 → 8.0.3
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/README.md +7 -4
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -44,6 +44,8 @@ rush add -p @unional/async-context
|
|
|
44
44
|
|
|
45
45
|
## Usage
|
|
46
46
|
|
|
47
|
+
[Introduction Video][introduction_video]
|
|
48
|
+
|
|
47
49
|
You can provide the initial context when calling the constructor.
|
|
48
50
|
The context value must be an object (`Record`).
|
|
49
51
|
You can extend and augment the context with the [`extend()`](#extend) later.
|
|
@@ -122,8 +124,8 @@ If you want to use the `ctx` directly, you can use `get<T>()` to assert the cont
|
|
|
122
124
|
|
|
123
125
|
```ts
|
|
124
126
|
const ctx = new AsyncContext({ a: 1, b: 'b' })
|
|
127
|
+
.extend({ b: 2, c: 3 })
|
|
125
128
|
|
|
126
|
-
ctx.extend({ b: 2, c: 3 })
|
|
127
129
|
await ctx.get<{ a: number, b: number, c: number }>()
|
|
128
130
|
|
|
129
131
|
// it is really the same as this, but less verbose
|
|
@@ -137,7 +139,7 @@ As you can guess, the `initialize()` and `extend()` functions can be chained:
|
|
|
137
139
|
```ts
|
|
138
140
|
const ctx = new AsyncContext()
|
|
139
141
|
|
|
140
|
-
ctx.initialize({ a: 1 }).extend({ b: 2 }).extend({ c: 3 })
|
|
142
|
+
const newCtx = ctx.initialize({ a: 1 }).extend({ b: 2 }).extend({ c: 3 })
|
|
141
143
|
```
|
|
142
144
|
|
|
143
145
|
## Use Cases
|
|
@@ -169,8 +171,8 @@ You can use `extend()` to chain asynchronous dependency loading.
|
|
|
169
171
|
import { AsyncContext } from '@unional/async-context'
|
|
170
172
|
|
|
171
173
|
const ctx = new AsyncContext(() => ({ io: createIO() }))
|
|
172
|
-
|
|
173
|
-
|
|
174
|
+
.extend(loadConfig)
|
|
175
|
+
.extend(loadPlugins)
|
|
174
176
|
|
|
175
177
|
async function loadConfig(ctx: AsyncContext<{ io: IO }>) {
|
|
176
178
|
const { io } = await ctx.get()
|
|
@@ -212,5 +214,6 @@ configure({ ... })
|
|
|
212
214
|
[codecov-url]: https://codecov.io/gh/unional/async-fp
|
|
213
215
|
[downloads-image]: https://img.shields.io/npm/dm/@unional/async-context.svg?style=flat
|
|
214
216
|
[downloads-url]: https://npmjs.org/package/@unional/async-context
|
|
217
|
+
[introduction_video]: https://youtu.be/9EnrSJdvP48
|
|
215
218
|
[npm-image]: https://img.shields.io/npm/v/@unional/async-context.svg?style=flat
|
|
216
219
|
[npm-url]: https://npmjs.org/package/@unional/async-context
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unional/async-context",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.3",
|
|
4
4
|
"description": "Asynchronous context for functional style programming",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"async",
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
"!**/*.spec.*"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"iso-error": "^
|
|
38
|
-
"type-plus": "^
|
|
37
|
+
"iso-error": "^5.0.0",
|
|
38
|
+
"type-plus": "^5.0.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@size-limit/preset-small-lib": "^8.0.1",
|
|
42
|
-
"@types/node": "^
|
|
42
|
+
"@types/node": "^18.0.0",
|
|
43
43
|
"@typescript-eslint/eslint-plugin": "^5.33.0",
|
|
44
44
|
"@typescript-eslint/parser": "^5.33.0",
|
|
45
|
-
"assertron": "^
|
|
45
|
+
"assertron": "^11.0.0",
|
|
46
46
|
"cross-env": "^7.0.3",
|
|
47
47
|
"depcheck": "^1.4.3",
|
|
48
48
|
"eslint": "^8.22.0",
|