vast 1.0.16 → 1.0.18-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.
@@ -6,13 +6,13 @@ var vestUtils = require('vest-utils');
6
6
 
7
7
  // eslint-disable-next-line max-lines-per-function
8
8
  function createState(onStateChange) {
9
- var state = {
10
- references: []
9
+ const state = {
10
+ references: [],
11
11
  };
12
- var registrations = [];
12
+ const registrations = [];
13
13
  return {
14
- registerStateKey: registerStateKey,
15
- reset: reset
14
+ registerStateKey,
15
+ reset,
16
16
  };
17
17
  /**
18
18
  * Registers a new key in the state, takes the initial value (may be a function that returns the initial value), returns a function.
@@ -28,17 +28,14 @@ function createState(onStateChange) {
28
28
  * useColor()[0]; -> "green"
29
29
  */
30
30
  function registerStateKey(initialState, onUpdate) {
31
- var key = registrations.length;
31
+ const key = registrations.length;
32
32
  registrations.push([initialState, onUpdate]);
33
33
  return initKey(key, initialState);
34
34
  }
35
35
  function reset() {
36
- var prev = current();
36
+ const prev = current();
37
37
  state.references = [];
38
- registrations.forEach(function (_a, index) {
39
- var initialValue = _a[0];
40
- return initKey(index, initialValue, prev[index]);
41
- });
38
+ registrations.forEach(([initialValue], index) => initKey(index, initialValue, prev[index]));
42
39
  }
43
40
  function initKey(key, initialState, prevState) {
44
41
  current().push();
@@ -46,9 +43,7 @@ function createState(onStateChange) {
46
43
  return function useStateKey() {
47
44
  return [
48
45
  current()[key],
49
- function (nextState) {
50
- return set(key, vestUtils.optionalFunctionValue(nextState, current()[key]));
51
- },
46
+ (nextState) => set(key, vestUtils.optionalFunctionValue(nextState, current()[key])),
52
47
  ];
53
48
  };
54
49
  }
@@ -56,9 +51,9 @@ function createState(onStateChange) {
56
51
  return state.references;
57
52
  }
58
53
  function set(index, value) {
59
- var prevValue = state.references[index];
54
+ const prevValue = state.references[index];
60
55
  state.references[index] = value;
61
- var _a = registrations[index], onUpdate = _a[1];
56
+ const [, onUpdate] = registrations[index];
62
57
  if (vestUtils.isFunction(onUpdate)) {
63
58
  onUpdate(value, prevValue);
64
59
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vest-utils");exports.createState=function(n){var r={references:[]},t=[];return{registerStateKey:function(e,n){var r=t.length;return t.push([e,n]),u(r,e)},reset:function(){var e=c();r.references=[],t.forEach((function(n,r){return u(r,n[0],e[r])}))}};function u(n,r,t){return c().push(),i(n,e.optionalFunctionValue(r,t)),function(){return[c()[n],function(r){return i(n,e.optionalFunctionValue(r,c()[n]))}]}}function c(){return r.references}function i(u,c){var i=r.references[u];r.references[u]=c;var o=t[u][1];e.isFunction(o)&&o(c,i),e.isFunction(n)&&n()}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vest-utils");exports.createState=function(n){const t={references:[]},r=[];return{registerStateKey:function(e,n){const t=r.length;return r.push([e,n]),c(t,e)},reset:function(){const e=o();t.references=[],r.forEach((([n],t)=>c(t,n,e[t])))}};function c(n,t,r){return o().push(),u(n,e.optionalFunctionValue(t,r)),function(){return[o()[n],t=>u(n,e.optionalFunctionValue(t,o()[n]))]}}function o(){return t.references}function u(c,o){const u=t.references[c];t.references[c]=o;const[,s]=r[c];e.isFunction(s)&&s(o,u),e.isFunction(n)&&n()}};
@@ -2,13 +2,13 @@ import { optionalFunctionValue, isFunction } from 'vest-utils';
2
2
 
3
3
  // eslint-disable-next-line max-lines-per-function
4
4
  function createState(onStateChange) {
5
- var state = {
6
- references: []
5
+ const state = {
6
+ references: [],
7
7
  };
8
- var registrations = [];
8
+ const registrations = [];
9
9
  return {
10
- registerStateKey: registerStateKey,
11
- reset: reset
10
+ registerStateKey,
11
+ reset,
12
12
  };
13
13
  /**
14
14
  * Registers a new key in the state, takes the initial value (may be a function that returns the initial value), returns a function.
@@ -24,17 +24,14 @@ function createState(onStateChange) {
24
24
  * useColor()[0]; -> "green"
25
25
  */
26
26
  function registerStateKey(initialState, onUpdate) {
27
- var key = registrations.length;
27
+ const key = registrations.length;
28
28
  registrations.push([initialState, onUpdate]);
29
29
  return initKey(key, initialState);
30
30
  }
31
31
  function reset() {
32
- var prev = current();
32
+ const prev = current();
33
33
  state.references = [];
34
- registrations.forEach(function (_a, index) {
35
- var initialValue = _a[0];
36
- return initKey(index, initialValue, prev[index]);
37
- });
34
+ registrations.forEach(([initialValue], index) => initKey(index, initialValue, prev[index]));
38
35
  }
39
36
  function initKey(key, initialState, prevState) {
40
37
  current().push();
@@ -42,9 +39,7 @@ function createState(onStateChange) {
42
39
  return function useStateKey() {
43
40
  return [
44
41
  current()[key],
45
- function (nextState) {
46
- return set(key, optionalFunctionValue(nextState, current()[key]));
47
- },
42
+ (nextState) => set(key, optionalFunctionValue(nextState, current()[key])),
48
43
  ];
49
44
  };
50
45
  }
@@ -52,9 +47,9 @@ function createState(onStateChange) {
52
47
  return state.references;
53
48
  }
54
49
  function set(index, value) {
55
- var prevValue = state.references[index];
50
+ const prevValue = state.references[index];
56
51
  state.references[index] = value;
57
- var _a = registrations[index], onUpdate = _a[1];
52
+ const [, onUpdate] = registrations[index];
58
53
  if (isFunction(onUpdate)) {
59
54
  onUpdate(value, prevValue);
60
55
  }
@@ -1 +1 @@
1
- import{optionalFunctionValue as e,isFunction as r}from"vest-utils";function n(n){var t={references:[]},u=[];return{registerStateKey:function(e,r){var n=u.length;return u.push([e,r]),f(n,e)},reset:function(){var e=c();t.references=[],u.forEach((function(r,n){return f(n,r[0],e[n])}))}};function f(r,n,t){return c().push(),o(r,e(n,t)),function(){return[c()[r],function(n){return o(r,e(n,c()[r]))}]}}function c(){return t.references}function o(e,f){var c=t.references[e];t.references[e]=f;var o=u[e][1];r(o)&&o(f,c),r(n)&&n()}}export{n as createState};
1
+ import{optionalFunctionValue as e,isFunction as n}from"vest-utils";function r(r){const t={references:[]},c=[];return{registerStateKey:function(e,n){const r=c.length;return c.push([e,n]),o(r,e)},reset:function(){const e=s();t.references=[],c.forEach((([n],r)=>o(r,n,e[r])))}};function o(n,r,t){return s().push(),u(n,e(r,t)),function(){return[s()[n],r=>u(n,e(r,s()[n]))]}}function s(){return t.references}function u(e,o){const s=t.references[e];t.references[e]=o;const[,u]=c[e];n(u)&&u(o,s),n(r)&&r()}}export{r as createState};
@@ -6,13 +6,13 @@
6
6
 
7
7
  // eslint-disable-next-line max-lines-per-function
8
8
  function createState(onStateChange) {
9
- var state = {
10
- references: []
9
+ const state = {
10
+ references: [],
11
11
  };
12
- var registrations = [];
12
+ const registrations = [];
13
13
  return {
14
- registerStateKey: registerStateKey,
15
- reset: reset
14
+ registerStateKey,
15
+ reset,
16
16
  };
17
17
  /**
18
18
  * Registers a new key in the state, takes the initial value (may be a function that returns the initial value), returns a function.
@@ -28,17 +28,14 @@
28
28
  * useColor()[0]; -> "green"
29
29
  */
30
30
  function registerStateKey(initialState, onUpdate) {
31
- var key = registrations.length;
31
+ const key = registrations.length;
32
32
  registrations.push([initialState, onUpdate]);
33
33
  return initKey(key, initialState);
34
34
  }
35
35
  function reset() {
36
- var prev = current();
36
+ const prev = current();
37
37
  state.references = [];
38
- registrations.forEach(function (_a, index) {
39
- var initialValue = _a[0];
40
- return initKey(index, initialValue, prev[index]);
41
- });
38
+ registrations.forEach(([initialValue], index) => initKey(index, initialValue, prev[index]));
42
39
  }
43
40
  function initKey(key, initialState, prevState) {
44
41
  current().push();
@@ -46,9 +43,7 @@
46
43
  return function useStateKey() {
47
44
  return [
48
45
  current()[key],
49
- function (nextState) {
50
- return set(key, vestUtils.optionalFunctionValue(nextState, current()[key]));
51
- },
46
+ (nextState) => set(key, vestUtils.optionalFunctionValue(nextState, current()[key])),
52
47
  ];
53
48
  };
54
49
  }
@@ -56,9 +51,9 @@
56
51
  return state.references;
57
52
  }
58
53
  function set(index, value) {
59
- var prevValue = state.references[index];
54
+ const prevValue = state.references[index];
60
55
  state.references[index] = value;
61
- var _a = registrations[index], onUpdate = _a[1];
56
+ const [, onUpdate] = registrations[index];
62
57
  if (vestUtils.isFunction(onUpdate)) {
63
58
  onUpdate(value, prevValue);
64
59
  }
@@ -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).vast={},e["vest-utils"])}(this,(function(e,n){"use strict";e.createState=function(e){var t={references:[]},r=[];return{registerStateKey:function(e,n){var t=r.length;return r.push([e,n]),u(t,e)},reset:function(){var e=i();t.references=[],r.forEach((function(n,t){return u(t,n[0],e[t])}))}};function u(e,t,r){return i().push(),o(e,n.optionalFunctionValue(t,r)),function(){return[i()[e],function(t){return o(e,n.optionalFunctionValue(t,i()[e]))}]}}function i(){return t.references}function o(u,i){var o=t.references[u];t.references[u]=i;var f=r[u][1];n.isFunction(f)&&f(i,o),n.isFunction(e)&&e()}},Object.defineProperty(e,"__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).vast={},e["vest-utils"])}(this,(function(e,n){"use strict";e.createState=function(e){const t={references:[]},o=[];return{registerStateKey:function(e,n){const t=o.length;return o.push([e,n]),i(t,e)},reset:function(){const e=r();t.references=[],o.forEach((([n],t)=>i(t,n,e[t])))}};function i(e,t,o){return r().push(),s(e,n.optionalFunctionValue(t,o)),function(){return[r()[e],t=>s(e,n.optionalFunctionValue(t,r()[e]))]}}function r(){return t.references}function s(i,r){const s=t.references[i];t.references[i]=r;const[,u]=o[i];n.isFunction(u)&&u(r,s),n.isFunction(e)&&e()}},Object.defineProperty(e,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.16",
2
+ "version": "1.0.18-dev-9c596e",
3
3
  "license": "MIT",
4
4
  "main": "./dist/cjs/vast.js",
5
5
  "types": "./types/vast.d.ts",
@@ -19,7 +19,7 @@
19
19
  "url": "https://github.com/ealush/vest.git/issues"
20
20
  },
21
21
  "dependencies": {
22
- "vest-utils": "^0.1.1"
22
+ "vest-utils": "1.0.0-dev-9c596e"
23
23
  },
24
24
  "exports": {
25
25
  ".": {
package/tsconfig.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "rootDir": ".",
4
- "compilerOptions": {
5
- "baseUrl": ".",
6
- "declarationDir": "./types",
7
- "declarationMap": true,
8
- "outDir": "./dist",
9
- "paths": {
10
- "vast": ["src/vast.ts"]
11
- }
12
- }
13
- }