vast 1.0.17 → 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
|
-
|
|
10
|
-
references: []
|
|
9
|
+
const state = {
|
|
10
|
+
references: [],
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
const registrations = [];
|
|
13
13
|
return {
|
|
14
|
-
registerStateKey
|
|
15
|
-
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
|
-
|
|
31
|
+
const key = registrations.length;
|
|
32
32
|
registrations.push([initialState, onUpdate]);
|
|
33
33
|
return initKey(key, initialState);
|
|
34
34
|
}
|
|
35
35
|
function reset() {
|
|
36
|
-
|
|
36
|
+
const prev = current();
|
|
37
37
|
state.references = [];
|
|
38
|
-
registrations.forEach(
|
|
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
|
-
|
|
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
|
-
|
|
54
|
+
const prevValue = state.references[index];
|
|
60
55
|
state.references[index] = value;
|
|
61
|
-
|
|
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){
|
|
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
|
-
|
|
6
|
-
references: []
|
|
5
|
+
const state = {
|
|
6
|
+
references: [],
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
const registrations = [];
|
|
9
9
|
return {
|
|
10
|
-
registerStateKey
|
|
11
|
-
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
|
-
|
|
27
|
+
const key = registrations.length;
|
|
28
28
|
registrations.push([initialState, onUpdate]);
|
|
29
29
|
return initKey(key, initialState);
|
|
30
30
|
}
|
|
31
31
|
function reset() {
|
|
32
|
-
|
|
32
|
+
const prev = current();
|
|
33
33
|
state.references = [];
|
|
34
|
-
registrations.forEach(
|
|
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
|
-
|
|
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
|
-
|
|
50
|
+
const prevValue = state.references[index];
|
|
56
51
|
state.references[index] = value;
|
|
57
|
-
|
|
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
|
|
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
|
-
|
|
10
|
-
references: []
|
|
9
|
+
const state = {
|
|
10
|
+
references: [],
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
const registrations = [];
|
|
13
13
|
return {
|
|
14
|
-
registerStateKey
|
|
15
|
-
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
|
-
|
|
31
|
+
const key = registrations.length;
|
|
32
32
|
registrations.push([initialState, onUpdate]);
|
|
33
33
|
return initKey(key, initialState);
|
|
34
34
|
}
|
|
35
35
|
function reset() {
|
|
36
|
-
|
|
36
|
+
const prev = current();
|
|
37
37
|
state.references = [];
|
|
38
|
-
registrations.forEach(
|
|
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
|
-
|
|
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
|
-
|
|
54
|
+
const prevValue = state.references[index];
|
|
60
55
|
state.references[index] = value;
|
|
61
|
-
|
|
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){
|
|
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.
|
|
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": "
|
|
22
|
+
"vest-utils": "1.0.0-dev-9c596e"
|
|
23
23
|
},
|
|
24
24
|
"exports": {
|
|
25
25
|
".": {
|