context 3.0.7 → 3.0.8-dev-9c596e

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.
@@ -4,17 +4,17 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var vestUtils = require('vest-utils');
6
6
 
7
- var USEX_DEFAULT_ERROR_MESSAGE = 'Not inside of a running context.';
8
- var EMPTY_CONTEXT = Symbol();
7
+ const USEX_DEFAULT_ERROR_MESSAGE = 'Not inside of a running context.';
8
+ const EMPTY_CONTEXT = Symbol();
9
9
  /**
10
10
  * Base context interface.
11
11
  */
12
12
  function createContext(defaultContextValue) {
13
- var contextValue = EMPTY_CONTEXT;
13
+ let contextValue = EMPTY_CONTEXT;
14
14
  return {
15
- run: run,
16
- use: use,
17
- useX: useX
15
+ run,
16
+ use,
17
+ useX,
18
18
  };
19
19
  function use() {
20
20
  return (isInsideContext() ? contextValue : defaultContextValue);
@@ -24,9 +24,9 @@ function createContext(defaultContextValue) {
24
24
  return contextValue;
25
25
  }
26
26
  function run(value, cb) {
27
- var parentContext = isInsideContext() ? use() : EMPTY_CONTEXT;
27
+ const parentContext = isInsideContext() ? use() : EMPTY_CONTEXT;
28
28
  contextValue = value;
29
- var res = cb();
29
+ const res = cb();
30
30
  contextValue = parentContext;
31
31
  return res;
32
32
  }
@@ -39,27 +39,23 @@ function createContext(defaultContextValue) {
39
39
  * When nesting context runs, the the values of the current layer merges with the layers above it.
40
40
  */
41
41
  function createCascade(init) {
42
- var ctx = createContext();
42
+ const ctx = createContext();
43
43
  return {
44
- bind: bind,
45
- run: run,
44
+ bind,
45
+ run,
46
46
  use: ctx.use,
47
- useX: ctx.useX
47
+ useX: ctx.useX,
48
48
  };
49
49
  function run(value, fn) {
50
50
  var _a;
51
- var parentContext = ctx.use();
52
- var out = vestUtils.assign({}, parentContext ? parentContext : {}, (_a = vestUtils.optionalFunctionValue(init, value, parentContext)) !== null && _a !== void 0 ? _a : value);
51
+ const parentContext = ctx.use();
52
+ const out = vestUtils.assign({}, parentContext ? parentContext : {}, (_a = vestUtils.optionalFunctionValue(init, value, parentContext)) !== null && _a !== void 0 ? _a : value);
53
53
  return ctx.run(Object.freeze(out), fn);
54
54
  }
55
55
  function bind(value, fn) {
56
- return function () {
57
- var runTimeArgs = [];
58
- for (var _i = 0; _i < arguments.length; _i++) {
59
- runTimeArgs[_i] = arguments[_i];
60
- }
56
+ return function (...runTimeArgs) {
61
57
  return run(value, function () {
62
- return fn.apply(void 0, runTimeArgs);
58
+ return fn(...runTimeArgs);
63
59
  });
64
60
  };
65
61
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("vest-utils"),e=Symbol();function r(r){var t=e;return{run:function(n,r){var i=o()?u():e;t=n;var a=r();return t=i,a},use:u,useX:function(e){return n.invariant(o(),n.defaultTo(e,"Not inside of a running context.")),t}};function u(){return o()?t:r}function o(){return t!==e}}exports.createCascade=function(e){var t=r();return{bind:function(n,e){return function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return u(n,(function(){return e.apply(void 0,r)}))}},run:u,use:t.use,useX:t.useX};function u(r,u){var o,i=t.use(),a=n.assign({},i||{},null!==(o=n.optionalFunctionValue(e,r,i))&&void 0!==o?o:r);return t.run(Object.freeze(a),u)}},exports.createContext=r;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("vest-utils");const t="Not inside of a running context.",e=Symbol();function u(u){let r=e;return{run:function(n,t){const u=i()?o():e;r=n;const s=t();return r=u,s},use:o,useX:function(e){return n.invariant(i(),n.defaultTo(e,t)),r}};function o(){return i()?r:u}function i(){return r!==e}}exports.createCascade=function(t){const e=u();return{bind:function(n,t){return function(...e){return r(n,(function(){return t(...e)}))}},run:r,use:e.use,useX:e.useX};function r(u,r){var o;const i=e.use(),s=n.assign({},i||{},null!==(o=n.optionalFunctionValue(t,u,i))&&void 0!==o?o:u);return e.run(Object.freeze(s),r)}},exports.createContext=u;
@@ -1,16 +1,16 @@
1
1
  import { invariant, defaultTo, assign, optionalFunctionValue } from 'vest-utils';
2
2
 
3
- var USEX_DEFAULT_ERROR_MESSAGE = 'Not inside of a running context.';
4
- var EMPTY_CONTEXT = Symbol();
3
+ const USEX_DEFAULT_ERROR_MESSAGE = 'Not inside of a running context.';
4
+ const EMPTY_CONTEXT = Symbol();
5
5
  /**
6
6
  * Base context interface.
7
7
  */
8
8
  function createContext(defaultContextValue) {
9
- var contextValue = EMPTY_CONTEXT;
9
+ let contextValue = EMPTY_CONTEXT;
10
10
  return {
11
- run: run,
12
- use: use,
13
- useX: useX
11
+ run,
12
+ use,
13
+ useX,
14
14
  };
15
15
  function use() {
16
16
  return (isInsideContext() ? contextValue : defaultContextValue);
@@ -20,9 +20,9 @@ function createContext(defaultContextValue) {
20
20
  return contextValue;
21
21
  }
22
22
  function run(value, cb) {
23
- var parentContext = isInsideContext() ? use() : EMPTY_CONTEXT;
23
+ const parentContext = isInsideContext() ? use() : EMPTY_CONTEXT;
24
24
  contextValue = value;
25
- var res = cb();
25
+ const res = cb();
26
26
  contextValue = parentContext;
27
27
  return res;
28
28
  }
@@ -35,27 +35,23 @@ function createContext(defaultContextValue) {
35
35
  * When nesting context runs, the the values of the current layer merges with the layers above it.
36
36
  */
37
37
  function createCascade(init) {
38
- var ctx = createContext();
38
+ const ctx = createContext();
39
39
  return {
40
- bind: bind,
41
- run: run,
40
+ bind,
41
+ run,
42
42
  use: ctx.use,
43
- useX: ctx.useX
43
+ useX: ctx.useX,
44
44
  };
45
45
  function run(value, fn) {
46
46
  var _a;
47
- var parentContext = ctx.use();
48
- var out = assign({}, parentContext ? parentContext : {}, (_a = optionalFunctionValue(init, value, parentContext)) !== null && _a !== void 0 ? _a : value);
47
+ const parentContext = ctx.use();
48
+ const out = assign({}, parentContext ? parentContext : {}, (_a = optionalFunctionValue(init, value, parentContext)) !== null && _a !== void 0 ? _a : value);
49
49
  return ctx.run(Object.freeze(out), fn);
50
50
  }
51
51
  function bind(value, fn) {
52
- return function () {
53
- var runTimeArgs = [];
54
- for (var _i = 0; _i < arguments.length; _i++) {
55
- runTimeArgs[_i] = arguments[_i];
56
- }
52
+ return function (...runTimeArgs) {
57
53
  return run(value, function () {
58
- return fn.apply(void 0, runTimeArgs);
54
+ return fn(...runTimeArgs);
59
55
  });
60
56
  };
61
57
  }
@@ -1 +1 @@
1
- import{invariant as n,defaultTo as r,assign as u,optionalFunctionValue as t}from"vest-utils";var e=Symbol();function o(u){var t=e;return{run:function(n,r){var u=i()?o():e;t=n;var f=r();return t=u,f},use:o,useX:function(u){return n(i(),r(u,"Not inside of a running context.")),t}};function o(){return i()?t:u}function i(){return t!==e}}function i(n){var r=o();return{bind:function(n,r){return function(){for(var u=[],t=0;t<arguments.length;t++)u[t]=arguments[t];return e(n,(function(){return r.apply(void 0,u)}))}},run:e,use:r.use,useX:r.useX};function e(e,o){var i,f=r.use(),c=u({},f||{},null!==(i=t(n,e,f))&&void 0!==i?i:e);return r.run(Object.freeze(c),o)}}export{i as createCascade,o as createContext};
1
+ import{invariant as n,defaultTo as t,assign as u,optionalFunctionValue as r}from"vest-utils";const e="Not inside of a running context.",o=Symbol();function c(u){let r=o;return{run:function(n,t){const u=i()?c():o;r=n;const e=t();return r=u,e},use:c,useX:function(u){return n(i(),t(u,e)),r}};function c(){return i()?r:u}function i(){return r!==o}}function i(n){const t=c();return{bind:function(n,t){return function(...u){return e(n,(function(){return t(...u)}))}},run:e,use:t.use,useX:t.useX};function e(e,o){var c;const i=t.use(),s=u({},i||{},null!==(c=r(n,e,i))&&void 0!==c?c:e);return t.run(Object.freeze(s),o)}}export{i as createCascade,c as createContext};
@@ -4,17 +4,17 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.context = {}, global["vest-utils"]));
5
5
  })(this, (function (exports, vestUtils) { 'use strict';
6
6
 
7
- var USEX_DEFAULT_ERROR_MESSAGE = 'Not inside of a running context.';
8
- var EMPTY_CONTEXT = Symbol();
7
+ const USEX_DEFAULT_ERROR_MESSAGE = 'Not inside of a running context.';
8
+ const EMPTY_CONTEXT = Symbol();
9
9
  /**
10
10
  * Base context interface.
11
11
  */
12
12
  function createContext(defaultContextValue) {
13
- var contextValue = EMPTY_CONTEXT;
13
+ let contextValue = EMPTY_CONTEXT;
14
14
  return {
15
- run: run,
16
- use: use,
17
- useX: useX
15
+ run,
16
+ use,
17
+ useX,
18
18
  };
19
19
  function use() {
20
20
  return (isInsideContext() ? contextValue : defaultContextValue);
@@ -24,9 +24,9 @@
24
24
  return contextValue;
25
25
  }
26
26
  function run(value, cb) {
27
- var parentContext = isInsideContext() ? use() : EMPTY_CONTEXT;
27
+ const parentContext = isInsideContext() ? use() : EMPTY_CONTEXT;
28
28
  contextValue = value;
29
- var res = cb();
29
+ const res = cb();
30
30
  contextValue = parentContext;
31
31
  return res;
32
32
  }
@@ -39,27 +39,23 @@
39
39
  * When nesting context runs, the the values of the current layer merges with the layers above it.
40
40
  */
41
41
  function createCascade(init) {
42
- var ctx = createContext();
42
+ const ctx = createContext();
43
43
  return {
44
- bind: bind,
45
- run: run,
44
+ bind,
45
+ run,
46
46
  use: ctx.use,
47
- useX: ctx.useX
47
+ useX: ctx.useX,
48
48
  };
49
49
  function run(value, fn) {
50
50
  var _a;
51
- var parentContext = ctx.use();
52
- var out = vestUtils.assign({}, parentContext ? parentContext : {}, (_a = vestUtils.optionalFunctionValue(init, value, parentContext)) !== null && _a !== void 0 ? _a : value);
51
+ const parentContext = ctx.use();
52
+ const out = vestUtils.assign({}, parentContext ? parentContext : {}, (_a = vestUtils.optionalFunctionValue(init, value, parentContext)) !== null && _a !== void 0 ? _a : value);
53
53
  return ctx.run(Object.freeze(out), fn);
54
54
  }
55
55
  function bind(value, fn) {
56
- return function () {
57
- var runTimeArgs = [];
58
- for (var _i = 0; _i < arguments.length; _i++) {
59
- runTimeArgs[_i] = arguments[_i];
60
- }
56
+ return function (...runTimeArgs) {
61
57
  return run(value, function () {
62
- return fn.apply(void 0, runTimeArgs);
58
+ return fn(...runTimeArgs);
63
59
  });
64
60
  };
65
61
  }
@@ -1 +1 @@
1
- !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("vest-utils")):"function"==typeof define&&define.amd?define(["exports","vest-utils"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).context={},e["vest-utils"])}(this,(function(e,n){"use strict";var t=Symbol();function u(e){var u=t;return{run:function(e,n){var i=o()?r():t;u=e;var f=n();return u=i,f},use:r,useX:function(e){return n.invariant(o(),n.defaultTo(e,"Not inside of a running context.")),u}};function r(){return o()?u:e}function o(){return u!==t}}e.createCascade=function(e){var t=u();return{bind:function(e,n){return function(){for(var t=[],u=0;u<arguments.length;u++)t[u]=arguments[u];return r(e,(function(){return n.apply(void 0,t)}))}},run:r,use:t.use,useX:t.useX};function r(u,r){var o,i=t.use(),f=n.assign({},i||{},null!==(o=n.optionalFunctionValue(e,u,i))&&void 0!==o?o:u);return t.run(Object.freeze(f),r)}},e.createContext=u,Object.defineProperty(e,"__esModule",{value:!0})}));
1
+ !function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vest-utils")):"function"==typeof define&&define.amd?define(["exports","vest-utils"],e):e((n="undefined"!=typeof globalThis?globalThis:n||self).context={},n["vest-utils"])}(this,(function(n,e){"use strict";const t="Not inside of a running context.",u=Symbol();function o(n){let o=u;return{run:function(n,e){const t=r()?i():u;o=n;const s=e();return o=t,s},use:i,useX:function(n){return e.invariant(r(),e.defaultTo(n,t)),o}};function i(){return r()?o:n}function r(){return o!==u}}n.createCascade=function(n){const t=o();return{bind:function(n,e){return function(...t){return u(n,(function(){return e(...t)}))}},run:u,use:t.use,useX:t.useX};function u(u,o){var i;const r=t.use(),s=e.assign({},r||{},null!==(i=e.optionalFunctionValue(n,u,r))&&void 0!==i?i:u);return t.run(Object.freeze(s),o)}},n.createContext=o,Object.defineProperty(n,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.0.7",
2
+ "version": "3.0.8-dev-9c596e",
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": "^0.1.1"
14
+ "vest-utils": "1.0.0-dev-9c596e"
15
15
  },
16
16
  "module": "./dist/es/context.production.js",
17
17
  "exports": {
@@ -2,7 +2,7 @@ import { CB } from 'vest-utils';
2
2
  /**
3
3
  * Base context interface.
4
4
  */
5
- declare function createContext<T extends unknown>(defaultContextValue?: T): CtxApi<T>;
5
+ declare function createContext<T>(defaultContextValue?: T): CtxApi<T>;
6
6
  /**
7
7
  * Cascading context - another implementation of context, that assumes the context value is an object.
8
8
  * When nesting context runs, the the values of the current layer merges with the layers above it.
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,MAAW,MAAM,YAAY,CAAC;AAWrC;;GAEG;AACH,iBAAgB,aAAa,CAAC,CAAC,SAAS,OAAO,EAC7C,mBAAmB,CAAC,EAAE,CAAC,GACtB,MAAM,CAAC,CAAC,CAAC,CAmCX;AAED;;;GAGG;AACH,iBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7D,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,IAAI,GAC9D,aAAa,CAAC,CAAC,CAAC,CA6BlB;AAED,KAAK,qBAAqB,CAAC,CAAC,IAAI;IAC9B,GAAG,EAAE,MAAM,CAAC,CAAC;IACb,IAAI,EAAE,CAAC,YAAY,CAAC,EAAE,MAAM,KAAK,CAAC,CAAC;CACpC,CAAC;AAEF,KAAY,MAAM,CAAC,CAAC,IAAI,qBAAqB,CAAC,CAAC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