context 2.0.7 → 2.0.8-dev-c786f7
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.
|
@@ -2,38 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
function isFunction(value) {
|
|
8
|
-
return typeof value === 'function';
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function optionalFunctionValue(value) {
|
|
12
|
-
var args = [];
|
|
13
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
14
|
-
args[_i - 1] = arguments[_i];
|
|
15
|
-
}
|
|
16
|
-
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function defaultTo(value, defaultValue) {
|
|
20
|
-
var _a;
|
|
21
|
-
return (_a = optionalFunctionValue(value)) !== null && _a !== void 0 ? _a : optionalFunctionValue(defaultValue);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function invariant(condition,
|
|
25
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
26
|
-
message) {
|
|
27
|
-
if (condition) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
// If message is a string object (rather than string literal)
|
|
31
|
-
// Throw the value directly as a string
|
|
32
|
-
// Alternatively, throw an error with the message
|
|
33
|
-
throw message instanceof String
|
|
34
|
-
? message.valueOf()
|
|
35
|
-
: new Error(message ? optionalFunctionValue(message) : message);
|
|
36
|
-
}
|
|
5
|
+
var vestUtils = require('vest-utils');
|
|
37
6
|
|
|
38
7
|
// eslint-disable-next-line max-lines-per-function
|
|
39
8
|
function createContext(init) {
|
|
@@ -46,13 +15,13 @@ function createContext(init) {
|
|
|
46
15
|
};
|
|
47
16
|
function useX(errorMessage) {
|
|
48
17
|
var ctx = use();
|
|
49
|
-
invariant(ctx, defaultTo(errorMessage, 'Context was used after it was closed'));
|
|
18
|
+
vestUtils.invariant(ctx, vestUtils.defaultTo(errorMessage, 'Context was used after it was closed'));
|
|
50
19
|
return ctx;
|
|
51
20
|
}
|
|
52
21
|
function run(ctxRef, fn) {
|
|
53
22
|
var _a;
|
|
54
23
|
var parentContext = use();
|
|
55
|
-
var out = assign({}, parentContext ? parentContext : {}, (_a = optionalFunctionValue(init, ctxRef, parentContext)) !== null && _a !== void 0 ? _a : ctxRef);
|
|
24
|
+
var out = vestUtils.assign({}, parentContext ? parentContext : {}, (_a = vestUtils.optionalFunctionValue(init, ctxRef, parentContext)) !== null && _a !== void 0 ? _a : ctxRef);
|
|
56
25
|
var ctx = set(Object.freeze(out));
|
|
57
26
|
storage.ancestry.unshift(ctx);
|
|
58
27
|
var res = fn(ctx);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("vest-utils");exports.createContext=function(n){function e(e,i){var o,a,s=r();return e=t.assign({},s||{},null!==(o=t.optionalFunctionValue(n,e,s))&&void 0!==o?o:e),o=u.ctx=Object.freeze(e),u.ancestry.unshift(o),i=i(o),u.ancestry.shift(),u.ctx=null!==(a=u.ancestry[0])&&void 0!==a?a:null,i}function r(){return u.ctx}var u={ancestry:[]};return{bind:function(t,n){return function(){for(var r=[],u=0;u<arguments.length;u++)r[u]=arguments[u];return e(t,(function(){return n.apply(void 0,r)}))}},run:e,use:r,useX:function(n){var e=r();return t.invariant(e,t.defaultTo(n,"Context was used after it was closed")),e}}};
|
|
@@ -1,35 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
function isFunction(value) {
|
|
4
|
-
return typeof value === 'function';
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
function optionalFunctionValue(value) {
|
|
8
|
-
var args = [];
|
|
9
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
10
|
-
args[_i - 1] = arguments[_i];
|
|
11
|
-
}
|
|
12
|
-
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function defaultTo(value, defaultValue) {
|
|
16
|
-
var _a;
|
|
17
|
-
return (_a = optionalFunctionValue(value)) !== null && _a !== void 0 ? _a : optionalFunctionValue(defaultValue);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function invariant(condition,
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
22
|
-
message) {
|
|
23
|
-
if (condition) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
// If message is a string object (rather than string literal)
|
|
27
|
-
// Throw the value directly as a string
|
|
28
|
-
// Alternatively, throw an error with the message
|
|
29
|
-
throw message instanceof String
|
|
30
|
-
? message.valueOf()
|
|
31
|
-
: new Error(message ? optionalFunctionValue(message) : message);
|
|
32
|
-
}
|
|
1
|
+
import { invariant, defaultTo, assign, optionalFunctionValue } from 'vest-utils';
|
|
33
2
|
|
|
34
3
|
// eslint-disable-next-line max-lines-per-function
|
|
35
4
|
function createContext(init) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{invariant as t,defaultTo as n,assign as r,optionalFunctionValue as e}from"vest-utils";export function createContext(u){function c(t,n){var c,s,a=o();return t=r({},a||{},null!==(c=e(u,t,a))&&void 0!==c?c:t),c=i.ctx=Object.freeze(t),i.ancestry.unshift(c),n=n(c),i.ancestry.shift(),i.ctx=null!==(s=i.ancestry[0])&&void 0!==s?s:null,n}function o(){return i.ctx}var i={ancestry:[]};return{bind:function(t,n){return function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return c(t,(function(){return n.apply(void 0,r)}))}},run:c,use:o,useX:function(r){var e=o();return t(e,n(r,"Context was used after it was closed")),e}}}
|
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.context = {}));
|
|
5
5
|
}(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
var assign = Object.assign;
|
|
8
|
-
|
|
9
7
|
function isFunction(value) {
|
|
10
8
|
return typeof value === 'function';
|
|
11
9
|
}
|
|
@@ -23,6 +21,8 @@
|
|
|
23
21
|
return (_a = optionalFunctionValue(value)) !== null && _a !== void 0 ? _a : optionalFunctionValue(defaultValue);
|
|
24
22
|
}
|
|
25
23
|
|
|
24
|
+
var assign = Object.assign;
|
|
25
|
+
|
|
26
26
|
function invariant(condition,
|
|
27
27
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
28
28
|
message) {
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.0.
|
|
2
|
+
"version": "2.0.8-dev-c786f7",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "./dist/cjs/context.js",
|
|
5
5
|
"types": "./types/context.d.ts",
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
"build": "vx build",
|
|
11
11
|
"release": "vx release"
|
|
12
12
|
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"vest-utils": "^0.0.4-dev-c786f7"
|
|
15
|
+
},
|
|
13
16
|
"module": "./dist/es/context.production.js",
|
|
14
17
|
"exports": {
|
|
15
18
|
".": {
|