context 3.0.13 → 3.0.15
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 +6 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -24,24 +24,24 @@ The context package exports these two functions:
|
|
|
24
24
|
|
|
25
25
|
Create context is the minimal implementation of context. It allows propagation of values down in your function call.
|
|
26
26
|
|
|
27
|
-
createContext takes a single argument - defaultContextValue. This value is used when not
|
|
27
|
+
createContext takes a single argument - defaultContextValue. This value is used when not within a running context.
|
|
28
28
|
|
|
29
29
|
### Arguments
|
|
30
30
|
|
|
31
|
-
| Argument | Type | Optional? | Description
|
|
32
|
-
| ------------------- | ----- | --------- |
|
|
33
|
-
| defaultContextValue | `any` | Yes | The default value to use when not
|
|
31
|
+
| Argument | Type | Optional? | Description |
|
|
32
|
+
| ------------------- | ----- | --------- | ----------------------------------------------------------- |
|
|
33
|
+
| defaultContextValue | `any` | Yes | The default value to use when not within a running context. |
|
|
34
34
|
|
|
35
35
|
### Returned object
|
|
36
36
|
|
|
37
37
|
`createContext` returns an object containing the following functions:
|
|
38
38
|
|
|
39
|
-
- `use`: Returns the current context value, or the default value when not
|
|
39
|
+
- `use`: Returns the current context value, or the default value when not within a running context.
|
|
40
40
|
- `useX`: Returns the current context, throws an error if not within a running context or the context is undefined. `useX` will throw even if a default value is provided.
|
|
41
41
|
- `run`: Runs the context, passing the given value into the context.
|
|
42
42
|
|
|
43
43
|
**Note About Typescript Usage**
|
|
44
|
-
For convenience, `use` assumes we're
|
|
44
|
+
For convenience, `use` assumes we're always inside a context. If you want to have runtime safety, you can use `useX` instead to make sure you're explicitly using a defined context.
|
|
45
45
|
|
|
46
46
|
### Usage Example
|
|
47
47
|
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.0.
|
|
2
|
+
"version": "3.0.15",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "./dist/cjs/context.js",
|
|
5
5
|
"types": "./types/context.d.ts",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"release": "vx release"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"vest-utils": "^1.1.
|
|
14
|
+
"vest-utils": "^1.1.2"
|
|
15
15
|
},
|
|
16
16
|
"module": "./dist/es/context.production.js",
|
|
17
17
|
"exports": {
|