context 3.0.5-dev-f3ecc9 → 3.0.5

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
- const USEX_DEFAULT_ERROR_MESSAGE = 'Not inside of a running context.';
8
- const EMPTY_CONTEXT = Symbol();
7
+ var USEX_DEFAULT_ERROR_MESSAGE = 'Not inside of a running context.';
8
+ var EMPTY_CONTEXT = Symbol();
9
9
  /**
10
10
  * Base context interface.
11
11
  */
12
12
  function createContext(defaultContextValue) {
13
- let contextValue = EMPTY_CONTEXT;
13
+ var contextValue = EMPTY_CONTEXT;
14
14
  return {
15
- run,
16
- use,
17
- useX,
15
+ run: run,
16
+ use: use,
17
+ useX: 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
- const parentContext = isInsideContext() ? use() : EMPTY_CONTEXT;
27
+ var parentContext = isInsideContext() ? use() : EMPTY_CONTEXT;
28
28
  contextValue = value;
29
- const res = cb();
29
+ var res = cb();
30
30
  contextValue = parentContext;
31
31
  return res;
32
32
  }
@@ -39,23 +39,27 @@ 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
- const ctx = createContext();
42
+ var ctx = createContext();
43
43
  return {
44
- bind,
45
- run,
44
+ bind: bind,
45
+ run: 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
- const parentContext = ctx.use();
52
- const out = vestUtils.assign({}, parentContext ? parentContext : {}, (_a = vestUtils.optionalFunctionValue(init, value, parentContext)) !== null && _a !== void 0 ? _a : value);
51
+ var parentContext = ctx.use();
52
+ var 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 (...runTimeArgs) {
56
+ return function () {
57
+ var runTimeArgs = [];
58
+ for (var _i = 0; _i < arguments.length; _i++) {
59
+ runTimeArgs[_i] = arguments[_i];
60
+ }
57
61
  return run(value, function () {
58
- return fn(...runTimeArgs);
62
+ return fn.apply(void 0, runTimeArgs);
59
63
  });
60
64
  };
61
65
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("vest-utils");const t=Symbol();function e(e){let u=t;return{run:function(n,e){const i=o()?r():t;u=n;const s=e();return u=i,s},use:r,useX:function(t){return n.invariant(o(),n.defaultTo(t,"Not inside of a running context.")),u}};function r(){return o()?u:e}function o(){return u!==t}}exports.createCascade=function(t){const u=e();return{bind:function(n,t){return function(...e){return r(n,(function(){return t(...e)}))}},run:r,use:u.use,useX:u.useX};function r(e,r){var o;const i=u.use(),s=n.assign({},i||{},null!==(o=n.optionalFunctionValue(t,e,i))&&void 0!==o?o:e);return u.run(Object.freeze(s),r)}},exports.createContext=e;
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,16 +1,16 @@
1
1
  import { invariant, defaultTo, assign, optionalFunctionValue } from 'vest-utils';
2
2
 
3
- const USEX_DEFAULT_ERROR_MESSAGE = 'Not inside of a running context.';
4
- const EMPTY_CONTEXT = Symbol();
3
+ var USEX_DEFAULT_ERROR_MESSAGE = 'Not inside of a running context.';
4
+ var EMPTY_CONTEXT = Symbol();
5
5
  /**
6
6
  * Base context interface.
7
7
  */
8
8
  function createContext(defaultContextValue) {
9
- let contextValue = EMPTY_CONTEXT;
9
+ var contextValue = EMPTY_CONTEXT;
10
10
  return {
11
- run,
12
- use,
13
- useX,
11
+ run: run,
12
+ use: use,
13
+ useX: 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
- const parentContext = isInsideContext() ? use() : EMPTY_CONTEXT;
23
+ var parentContext = isInsideContext() ? use() : EMPTY_CONTEXT;
24
24
  contextValue = value;
25
- const res = cb();
25
+ var res = cb();
26
26
  contextValue = parentContext;
27
27
  return res;
28
28
  }
@@ -35,23 +35,27 @@ 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
- const ctx = createContext();
38
+ var ctx = createContext();
39
39
  return {
40
- bind,
41
- run,
40
+ bind: bind,
41
+ run: 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
- const parentContext = ctx.use();
48
- const out = assign({}, parentContext ? parentContext : {}, (_a = optionalFunctionValue(init, value, parentContext)) !== null && _a !== void 0 ? _a : value);
47
+ var parentContext = ctx.use();
48
+ var 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 (...runTimeArgs) {
52
+ return function () {
53
+ var runTimeArgs = [];
54
+ for (var _i = 0; _i < arguments.length; _i++) {
55
+ runTimeArgs[_i] = arguments[_i];
56
+ }
53
57
  return run(value, function () {
54
- return fn(...runTimeArgs);
58
+ return fn.apply(void 0, runTimeArgs);
55
59
  });
56
60
  };
57
61
  }
@@ -1 +1 @@
1
- import{invariant as n,defaultTo as t,assign as u,optionalFunctionValue as r}from"vest-utils";const e=Symbol();function o(u){let r=e;return{run:function(n,t){const u=c()?o():e;r=n;const i=t();return r=u,i},use:o,useX:function(u){return n(c(),t(u,"Not inside of a running context.")),r}};function o(){return c()?r:u}function c(){return r!==e}}function c(n){const t=o();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{c as createCascade,o as createContext};
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};
@@ -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
- const USEX_DEFAULT_ERROR_MESSAGE = 'Not inside of a running context.';
8
- const EMPTY_CONTEXT = Symbol();
7
+ var USEX_DEFAULT_ERROR_MESSAGE = 'Not inside of a running context.';
8
+ var EMPTY_CONTEXT = Symbol();
9
9
  /**
10
10
  * Base context interface.
11
11
  */
12
12
  function createContext(defaultContextValue) {
13
- let contextValue = EMPTY_CONTEXT;
13
+ var contextValue = EMPTY_CONTEXT;
14
14
  return {
15
- run,
16
- use,
17
- useX,
15
+ run: run,
16
+ use: use,
17
+ useX: 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
- const parentContext = isInsideContext() ? use() : EMPTY_CONTEXT;
27
+ var parentContext = isInsideContext() ? use() : EMPTY_CONTEXT;
28
28
  contextValue = value;
29
- const res = cb();
29
+ var res = cb();
30
30
  contextValue = parentContext;
31
31
  return res;
32
32
  }
@@ -39,23 +39,27 @@
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
- const ctx = createContext();
42
+ var ctx = createContext();
43
43
  return {
44
- bind,
45
- run,
44
+ bind: bind,
45
+ run: 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
- const parentContext = ctx.use();
52
- const out = vestUtils.assign({}, parentContext ? parentContext : {}, (_a = vestUtils.optionalFunctionValue(init, value, parentContext)) !== null && _a !== void 0 ? _a : value);
51
+ var parentContext = ctx.use();
52
+ var 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 (...runTimeArgs) {
56
+ return function () {
57
+ var runTimeArgs = [];
58
+ for (var _i = 0; _i < arguments.length; _i++) {
59
+ runTimeArgs[_i] = arguments[_i];
60
+ }
57
61
  return run(value, function () {
58
- return fn(...runTimeArgs);
62
+ return fn.apply(void 0, runTimeArgs);
59
63
  });
60
64
  };
61
65
  }
@@ -1 +1 @@
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=Symbol();function u(n){let u=t;return{run:function(n,e){const r=i()?o():t;u=n;const s=e();return u=r,s},use:o,useX:function(n){return e.invariant(i(),e.defaultTo(n,"Not inside of a running context.")),u}};function o(){return i()?u:n}function i(){return u!==t}}n.createCascade=function(n){const t=u();return{bind:function(n,e){return function(...t){return o(n,(function(){return e(...t)}))}},run:o,use:t.use,useX:t.useX};function o(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=u,Object.defineProperty(n,"__esModule",{value:!0})}));
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})}));
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.0.5-dev-f3ecc9",
2
+ "version": "3.0.5",
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.0-dev-f3ecc9"
14
+ "vest-utils": "^0.1.0"
15
15
  },
16
16
  "module": "./dist/es/context.production.js",
17
17
  "exports": {