context 2.0.4 → 2.0.7
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.
|
@@ -16,9 +16,9 @@ function optionalFunctionValue(value) {
|
|
|
16
16
|
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
function defaultTo(
|
|
19
|
+
function defaultTo(value, defaultValue) {
|
|
20
20
|
var _a;
|
|
21
|
-
return (_a = optionalFunctionValue(
|
|
21
|
+
return (_a = optionalFunctionValue(value)) !== null && _a !== void 0 ? _a : optionalFunctionValue(defaultValue);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
function invariant(condition,
|
|
@@ -45,8 +45,9 @@ function createContext(init) {
|
|
|
45
45
|
useX: useX
|
|
46
46
|
};
|
|
47
47
|
function useX(errorMessage) {
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
var ctx = use();
|
|
49
|
+
invariant(ctx, defaultTo(errorMessage, 'Context was used after it was closed'));
|
|
50
|
+
return ctx;
|
|
50
51
|
}
|
|
51
52
|
function run(ctxRef, fn) {
|
|
52
53
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=Object.assign;function t(n){return"function"==typeof n}function r(n){for(var r=[],e=1;e<arguments.length;e++)r[e-1]=arguments[e];return t(n)?n.apply(void 0,r):n}exports.createContext=function(t){function e(e,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=Object.assign;function t(n){return"function"==typeof n}function r(n){for(var r=[],e=1;e<arguments.length;e++)r[e-1]=arguments[e];return t(n)?n.apply(void 0,r):n}exports.createContext=function(t){function e(e,i){var c,f,a=u();return e=n({},a||{},null!==(c=r(t,e,a))&&void 0!==c?c:e),c=o.ctx=Object.freeze(e),o.ancestry.unshift(c),i=i(c),o.ancestry.shift(),o.ctx=null!==(f=o.ancestry[0])&&void 0!==f?f:null,i}function u(){return o.ctx}var o={ancestry:[]};return{bind:function(n,t){return function(){for(var r=[],u=0;u<arguments.length;u++)r[u]=arguments[u];return e(n,(function(){return t.apply(void 0,r)}))}},run:e,use:u,useX:function(n){var t=u();return function(n,t){if(!n)throw t instanceof String?t.valueOf():Error(t?r(t):t)}(t,function(n,t){var e;return null!==(e=r(n))&&void 0!==e?e:r(t)}(n,"Context was used after it was closed")),t}}};
|
|
@@ -12,9 +12,9 @@ function optionalFunctionValue(value) {
|
|
|
12
12
|
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
function defaultTo(
|
|
15
|
+
function defaultTo(value, defaultValue) {
|
|
16
16
|
var _a;
|
|
17
|
-
return (_a = optionalFunctionValue(
|
|
17
|
+
return (_a = optionalFunctionValue(value)) !== null && _a !== void 0 ? _a : optionalFunctionValue(defaultValue);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
function invariant(condition,
|
|
@@ -41,8 +41,9 @@ function createContext(init) {
|
|
|
41
41
|
useX: useX
|
|
42
42
|
};
|
|
43
43
|
function useX(errorMessage) {
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
var ctx = use();
|
|
45
|
+
invariant(ctx, defaultTo(errorMessage, 'Context was used after it was closed'));
|
|
46
|
+
return ctx;
|
|
46
47
|
}
|
|
47
48
|
function run(ctxRef, fn) {
|
|
48
49
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var n=Object.assign;function t(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return"function"==typeof n?n.apply(void 0,t):n}export function createContext(r){function e(e,
|
|
1
|
+
var n=Object.assign;function t(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return"function"==typeof n?n.apply(void 0,t):n}export function createContext(r){function e(e,i){var c,a,f=u();return e=n({},f||{},null!==(c=t(r,e,f))&&void 0!==c?c:e),c=o.ctx=Object.freeze(e),o.ancestry.unshift(c),i=i(c),o.ancestry.shift(),o.ctx=null!==(a=o.ancestry[0])&&void 0!==a?a:null,i}function u(){return o.ctx}var o={ancestry:[]};return{bind:function(n,t){return function(){for(var r=[],u=0;u<arguments.length;u++)r[u]=arguments[u];return e(n,(function(){return t.apply(void 0,r)}))}},run:e,use:u,useX:function(n){var r,e=u();if(n=null!==(r=t(n))&&void 0!==r?r:t("Context was used after it was closed"),!e)throw n instanceof String?n.valueOf():Error(n?t(n):n);return e}}}
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
function defaultTo(
|
|
21
|
+
function defaultTo(value, defaultValue) {
|
|
22
22
|
var _a;
|
|
23
|
-
return (_a = optionalFunctionValue(
|
|
23
|
+
return (_a = optionalFunctionValue(value)) !== null && _a !== void 0 ? _a : optionalFunctionValue(defaultValue);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
function invariant(condition,
|
|
@@ -47,8 +47,9 @@
|
|
|
47
47
|
useX: useX
|
|
48
48
|
};
|
|
49
49
|
function useX(errorMessage) {
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
var ctx = use();
|
|
51
|
+
invariant(ctx, defaultTo(errorMessage, 'Context was used after it was closed'));
|
|
52
|
+
return ctx;
|
|
52
53
|
}
|
|
53
54
|
function run(ctxRef, fn) {
|
|
54
55
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";!function(
|
|
1
|
+
"use strict";!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).context={})}(this,(function(e){function n(e){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];return"function"==typeof e?e.apply(void 0,n):e}var t=Object.assign;e.createContext=function(e){function r(r,i){var f,c,s=o();return r=t({},s||{},null!==(f=n(e,r,s))&&void 0!==f?f:r),f=u.ctx=Object.freeze(r),u.ancestry.unshift(f),i=i(f),u.ancestry.shift(),u.ctx=null!==(c=u.ancestry[0])&&void 0!==c?c:null,i}function o(){return u.ctx}var u={ancestry:[]};return{bind:function(e,n){return function(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];return r(e,(function(){return n.apply(void 0,t)}))}},run:r,use:o,useX:function(e){var t,r=o();if(e=null!==(t=n(e))&&void 0!==t?t:n("Context was used after it was closed"),!r)throw e instanceof String?e.valueOf():Error(e?n(e):e);return r}}},Object.defineProperty(e,"__esModule",{value:!0})}));
|
package/package.json
CHANGED