@flowerforce/flower-core 3.0.1-beta.6 → 3.0.1-beta.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.
- package/dist/index.cjs.js +160 -104
- package/dist/index.esm.js +161 -104
- package/dist/src/index.d.ts +0 -1
- package/package.json +1 -1
- package/dist/src/Flat.d.ts +0 -5
package/dist/index.cjs.js
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
var _get = require('lodash/get');
|
4
|
-
var isBuffer = require('lodash/isBuffer');
|
5
3
|
var tinyEmitter = require('tiny-emitter');
|
6
4
|
var _set = require('lodash/set');
|
7
5
|
var _unset = require('lodash/unset');
|
6
|
+
var _get = require('lodash/get');
|
8
7
|
var _last = require('lodash/last');
|
9
8
|
var _slice = require('lodash/slice');
|
10
9
|
var _cloneDeep = require('lodash/cloneDeep');
|
@@ -20,106 +19,6 @@ var mapValues = require('lodash/mapValues');
|
|
20
19
|
var _trimStart = require('lodash/trimStart');
|
21
20
|
var _intersection = require('lodash/intersection');
|
22
21
|
|
23
|
-
const keyIdentity = key => key;
|
24
|
-
const flatten = (target, opts) => {
|
25
|
-
const options = opts ?? {};
|
26
|
-
const safe = _get(options, 'safe', false);
|
27
|
-
const maxDepth = _get(options, 'maxDepth', 0);
|
28
|
-
const delimiter = _get(options, 'delimiter', '.');
|
29
|
-
const transformKey = _get(options, 'transformKey', keyIdentity);
|
30
|
-
const output = {};
|
31
|
-
const step = (object, prev, currentDepth) => {
|
32
|
-
const depth = currentDepth || 1;
|
33
|
-
Object.keys(object).forEach(key => {
|
34
|
-
const value = object[key];
|
35
|
-
const isarray = safe && Array.isArray(value);
|
36
|
-
const type = Object.prototype.toString.call(value);
|
37
|
-
const isbuffer = isBuffer(value);
|
38
|
-
const isobject = type === '[object Object]' || type === '[object Array]';
|
39
|
-
const newKey = prev ? prev + delimiter + transformKey(key) : transformKey(key);
|
40
|
-
if (!isarray && !isbuffer && isobject && Object.keys(value).length && (!maxDepth || depth < maxDepth)) {
|
41
|
-
return step(value, newKey, depth + 1);
|
42
|
-
}
|
43
|
-
output[newKey] = value;
|
44
|
-
});
|
45
|
-
};
|
46
|
-
step(target);
|
47
|
-
return output;
|
48
|
-
};
|
49
|
-
const unflatten = (target, opts) => {
|
50
|
-
const options = opts ?? {};
|
51
|
-
const object = _get(options, 'object', false);
|
52
|
-
const overwrite = _get(options, 'overwrite', false);
|
53
|
-
const delimiter = _get(options, 'delimiter', '.');
|
54
|
-
const transformKey = _get(options, 'transformKey', keyIdentity);
|
55
|
-
const result = {};
|
56
|
-
const isbuffer = isBuffer(target);
|
57
|
-
if (isbuffer || Object.prototype.toString.call(target) !== '[object Object]') {
|
58
|
-
return target;
|
59
|
-
}
|
60
|
-
const getkey = key => {
|
61
|
-
const parsedKey = Number(key);
|
62
|
-
return isNaN(parsedKey) || key?.indexOf('.') !== -1 || object ? key : parsedKey;
|
63
|
-
};
|
64
|
-
function addKeys(keyPrefix, recipient, target) {
|
65
|
-
return Object.keys(target).reduce((result, key) => {
|
66
|
-
result[keyPrefix + delimiter + key] = target[key];
|
67
|
-
return result;
|
68
|
-
}, recipient);
|
69
|
-
}
|
70
|
-
function isEmpty(val) {
|
71
|
-
const type = Object.prototype.toString.call(val);
|
72
|
-
const isArray = type === '[object Array]';
|
73
|
-
const isObject = type === '[object Object]';
|
74
|
-
if (!val) {
|
75
|
-
return true;
|
76
|
-
}
|
77
|
-
if (isArray) {
|
78
|
-
return !val.length;
|
79
|
-
}
|
80
|
-
if (isObject) {
|
81
|
-
return !Object.keys(val).length;
|
82
|
-
}
|
83
|
-
}
|
84
|
-
target = Object.keys(target).reduce((result, key) => {
|
85
|
-
const type = Object.prototype.toString.call(target[key]);
|
86
|
-
const isObject = type === '[object Object]' || type === '[object Array]';
|
87
|
-
if (!isObject || isEmpty(target[key])) {
|
88
|
-
result[key] = target[key];
|
89
|
-
return result;
|
90
|
-
}
|
91
|
-
return addKeys(key, result, flatten(target[key], opts));
|
92
|
-
}, {});
|
93
|
-
Object.keys(target).forEach(key => {
|
94
|
-
const split = key.split(delimiter).map(transformKey);
|
95
|
-
let key1 = getkey(split.shift());
|
96
|
-
let key2 = getkey(split[0]);
|
97
|
-
let recipient = result;
|
98
|
-
while (key2 !== undefined) {
|
99
|
-
const recipient_key_1 = key1 && _get(recipient, key1);
|
100
|
-
const type = Object.prototype.toString.call(recipient_key_1);
|
101
|
-
const isobject = type === '[object Object]' || type === '[object Array]';
|
102
|
-
if (!overwrite && !isobject && typeof recipient_key_1 !== 'undefined') {
|
103
|
-
return;
|
104
|
-
}
|
105
|
-
if (overwrite && !isobject || !overwrite && recipient_key_1 == null) {
|
106
|
-
recipient[key1] = typeof key2 === 'number' && !object ? [] : {};
|
107
|
-
}
|
108
|
-
recipient = key1 && _get(recipient, key1);
|
109
|
-
if (split.length > 0) {
|
110
|
-
key1 = getkey(split.shift());
|
111
|
-
key2 = getkey(split[0]);
|
112
|
-
}
|
113
|
-
}
|
114
|
-
recipient[key1] = unflatten(target[key], opts);
|
115
|
-
});
|
116
|
-
return result;
|
117
|
-
};
|
118
|
-
const flat = {
|
119
|
-
flatten,
|
120
|
-
unflatten
|
121
|
-
};
|
122
|
-
|
123
22
|
const Emitter = new tinyEmitter.TinyEmitter();
|
124
23
|
|
125
24
|
const EMPTY_STRING_REGEXP = /^\s*$/;
|
@@ -851,6 +750,164 @@ const FlowerCoreReducers = {
|
|
851
750
|
}
|
852
751
|
};
|
853
752
|
|
753
|
+
function isBuffer (obj) {
|
754
|
+
return obj &&
|
755
|
+
obj.constructor &&
|
756
|
+
(typeof obj.constructor.isBuffer === 'function') &&
|
757
|
+
obj.constructor.isBuffer(obj)
|
758
|
+
}
|
759
|
+
|
760
|
+
function keyIdentity (key) {
|
761
|
+
return key
|
762
|
+
}
|
763
|
+
|
764
|
+
function flatten (target, opts) {
|
765
|
+
opts = opts || {};
|
766
|
+
|
767
|
+
const delimiter = opts.delimiter || '.';
|
768
|
+
const maxDepth = opts.maxDepth;
|
769
|
+
const transformKey = opts.transformKey || keyIdentity;
|
770
|
+
const output = {};
|
771
|
+
|
772
|
+
function step (object, prev, currentDepth) {
|
773
|
+
currentDepth = currentDepth || 1;
|
774
|
+
Object.keys(object).forEach(function (key) {
|
775
|
+
const value = object[key];
|
776
|
+
const isarray = opts.safe && Array.isArray(value);
|
777
|
+
const type = Object.prototype.toString.call(value);
|
778
|
+
const isbuffer = isBuffer(value);
|
779
|
+
const isobject = (
|
780
|
+
type === '[object Object]' ||
|
781
|
+
type === '[object Array]'
|
782
|
+
);
|
783
|
+
|
784
|
+
const newKey = prev
|
785
|
+
? prev + delimiter + transformKey(key)
|
786
|
+
: transformKey(key);
|
787
|
+
|
788
|
+
if (!isarray && !isbuffer && isobject && Object.keys(value).length &&
|
789
|
+
(!opts.maxDepth || currentDepth < maxDepth)) {
|
790
|
+
return step(value, newKey, currentDepth + 1)
|
791
|
+
}
|
792
|
+
|
793
|
+
output[newKey] = value;
|
794
|
+
});
|
795
|
+
}
|
796
|
+
|
797
|
+
step(target);
|
798
|
+
|
799
|
+
return output
|
800
|
+
}
|
801
|
+
|
802
|
+
function unflatten (target, opts) {
|
803
|
+
opts = opts || {};
|
804
|
+
|
805
|
+
const delimiter = opts.delimiter || '.';
|
806
|
+
const overwrite = opts.overwrite || false;
|
807
|
+
const transformKey = opts.transformKey || keyIdentity;
|
808
|
+
const result = {};
|
809
|
+
|
810
|
+
const isbuffer = isBuffer(target);
|
811
|
+
if (isbuffer || Object.prototype.toString.call(target) !== '[object Object]') {
|
812
|
+
return target
|
813
|
+
}
|
814
|
+
|
815
|
+
// safely ensure that the key is
|
816
|
+
// an integer.
|
817
|
+
function getkey (key) {
|
818
|
+
const parsedKey = Number(key);
|
819
|
+
|
820
|
+
return (
|
821
|
+
isNaN(parsedKey) ||
|
822
|
+
key.indexOf('.') !== -1 ||
|
823
|
+
opts.object
|
824
|
+
)
|
825
|
+
? key
|
826
|
+
: parsedKey
|
827
|
+
}
|
828
|
+
|
829
|
+
function addKeys (keyPrefix, recipient, target) {
|
830
|
+
return Object.keys(target).reduce(function (result, key) {
|
831
|
+
result[keyPrefix + delimiter + key] = target[key];
|
832
|
+
|
833
|
+
return result
|
834
|
+
}, recipient)
|
835
|
+
}
|
836
|
+
|
837
|
+
function isEmpty (val) {
|
838
|
+
const type = Object.prototype.toString.call(val);
|
839
|
+
const isArray = type === '[object Array]';
|
840
|
+
const isObject = type === '[object Object]';
|
841
|
+
|
842
|
+
if (!val) {
|
843
|
+
return true
|
844
|
+
} else if (isArray) {
|
845
|
+
return !val.length
|
846
|
+
} else if (isObject) {
|
847
|
+
return !Object.keys(val).length
|
848
|
+
}
|
849
|
+
}
|
850
|
+
|
851
|
+
target = Object.keys(target).reduce(function (result, key) {
|
852
|
+
const type = Object.prototype.toString.call(target[key]);
|
853
|
+
const isObject = (type === '[object Object]' || type === '[object Array]');
|
854
|
+
if (!isObject || isEmpty(target[key])) {
|
855
|
+
result[key] = target[key];
|
856
|
+
return result
|
857
|
+
} else {
|
858
|
+
return addKeys(
|
859
|
+
key,
|
860
|
+
result,
|
861
|
+
flatten(target[key], opts)
|
862
|
+
)
|
863
|
+
}
|
864
|
+
}, {});
|
865
|
+
|
866
|
+
Object.keys(target).forEach(function (key) {
|
867
|
+
const split = key.split(delimiter).map(transformKey);
|
868
|
+
let key1 = getkey(split.shift());
|
869
|
+
let key2 = getkey(split[0]);
|
870
|
+
let recipient = result;
|
871
|
+
|
872
|
+
while (key2 !== undefined) {
|
873
|
+
if (key1 === '__proto__') {
|
874
|
+
return
|
875
|
+
}
|
876
|
+
|
877
|
+
const type = Object.prototype.toString.call(recipient[key1]);
|
878
|
+
const isobject = (
|
879
|
+
type === '[object Object]' ||
|
880
|
+
type === '[object Array]'
|
881
|
+
);
|
882
|
+
|
883
|
+
// do not write over falsey, non-undefined values if overwrite is false
|
884
|
+
if (!overwrite && !isobject && typeof recipient[key1] !== 'undefined') {
|
885
|
+
return
|
886
|
+
}
|
887
|
+
|
888
|
+
if ((overwrite && !isobject) || (!overwrite && recipient[key1] == null)) {
|
889
|
+
recipient[key1] = (
|
890
|
+
typeof key2 === 'number' &&
|
891
|
+
!opts.object
|
892
|
+
? []
|
893
|
+
: {}
|
894
|
+
);
|
895
|
+
}
|
896
|
+
|
897
|
+
recipient = recipient[key1];
|
898
|
+
if (split.length > 0) {
|
899
|
+
key1 = getkey(split.shift());
|
900
|
+
key2 = getkey(split[0]);
|
901
|
+
}
|
902
|
+
}
|
903
|
+
|
904
|
+
// unflatten again for 'messy objects'
|
905
|
+
recipient[key1] = unflatten(target[key], opts);
|
906
|
+
});
|
907
|
+
|
908
|
+
return result
|
909
|
+
}
|
910
|
+
|
854
911
|
const FlowerCoreStateSelectors = {
|
855
912
|
selectGlobal: state => state && state.flower,
|
856
913
|
selectFlower: name => state => _get(state, [name]),
|
@@ -917,7 +974,7 @@ const FlowerCoreStateSelectors = {
|
|
917
974
|
});
|
918
975
|
}, {});
|
919
976
|
const [disabled] = MatchRules.rulesMatcher(rules, {
|
920
|
-
...
|
977
|
+
...unflatten(res)
|
921
978
|
}, false, {
|
922
979
|
prefix: flowName
|
923
980
|
});
|
@@ -970,7 +1027,6 @@ exports.RulesOperators = void 0;
|
|
970
1027
|
|
971
1028
|
exports.CoreUtils = CoreUtils;
|
972
1029
|
exports.Emitter = Emitter;
|
973
|
-
exports.Flat = flat;
|
974
1030
|
exports.FlowerCoreReducers = FlowerCoreReducers;
|
975
1031
|
exports.FlowerStateUtils = FlowerStateUtils;
|
976
1032
|
exports.MatchRules = MatchRules;
|
package/dist/index.esm.js
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
import _get from 'lodash/get';
|
2
|
-
import isBuffer from 'lodash/isBuffer';
|
3
1
|
import { TinyEmitter } from 'tiny-emitter';
|
4
2
|
import _set from 'lodash/set';
|
5
3
|
import _unset from 'lodash/unset';
|
4
|
+
import _get from 'lodash/get';
|
6
5
|
import _last from 'lodash/last';
|
7
6
|
import _slice from 'lodash/slice';
|
8
7
|
import _cloneDeep from 'lodash/cloneDeep';
|
@@ -18,106 +17,6 @@ import mapValues from 'lodash/mapValues';
|
|
18
17
|
import _trimStart from 'lodash/trimStart';
|
19
18
|
import _intersection from 'lodash/intersection';
|
20
19
|
|
21
|
-
const keyIdentity = key => key;
|
22
|
-
const flatten = (target, opts) => {
|
23
|
-
const options = opts ?? {};
|
24
|
-
const safe = _get(options, 'safe', false);
|
25
|
-
const maxDepth = _get(options, 'maxDepth', 0);
|
26
|
-
const delimiter = _get(options, 'delimiter', '.');
|
27
|
-
const transformKey = _get(options, 'transformKey', keyIdentity);
|
28
|
-
const output = {};
|
29
|
-
const step = (object, prev, currentDepth) => {
|
30
|
-
const depth = currentDepth || 1;
|
31
|
-
Object.keys(object).forEach(key => {
|
32
|
-
const value = object[key];
|
33
|
-
const isarray = safe && Array.isArray(value);
|
34
|
-
const type = Object.prototype.toString.call(value);
|
35
|
-
const isbuffer = isBuffer(value);
|
36
|
-
const isobject = type === '[object Object]' || type === '[object Array]';
|
37
|
-
const newKey = prev ? prev + delimiter + transformKey(key) : transformKey(key);
|
38
|
-
if (!isarray && !isbuffer && isobject && Object.keys(value).length && (!maxDepth || depth < maxDepth)) {
|
39
|
-
return step(value, newKey, depth + 1);
|
40
|
-
}
|
41
|
-
output[newKey] = value;
|
42
|
-
});
|
43
|
-
};
|
44
|
-
step(target);
|
45
|
-
return output;
|
46
|
-
};
|
47
|
-
const unflatten = (target, opts) => {
|
48
|
-
const options = opts ?? {};
|
49
|
-
const object = _get(options, 'object', false);
|
50
|
-
const overwrite = _get(options, 'overwrite', false);
|
51
|
-
const delimiter = _get(options, 'delimiter', '.');
|
52
|
-
const transformKey = _get(options, 'transformKey', keyIdentity);
|
53
|
-
const result = {};
|
54
|
-
const isbuffer = isBuffer(target);
|
55
|
-
if (isbuffer || Object.prototype.toString.call(target) !== '[object Object]') {
|
56
|
-
return target;
|
57
|
-
}
|
58
|
-
const getkey = key => {
|
59
|
-
const parsedKey = Number(key);
|
60
|
-
return isNaN(parsedKey) || key?.indexOf('.') !== -1 || object ? key : parsedKey;
|
61
|
-
};
|
62
|
-
function addKeys(keyPrefix, recipient, target) {
|
63
|
-
return Object.keys(target).reduce((result, key) => {
|
64
|
-
result[keyPrefix + delimiter + key] = target[key];
|
65
|
-
return result;
|
66
|
-
}, recipient);
|
67
|
-
}
|
68
|
-
function isEmpty(val) {
|
69
|
-
const type = Object.prototype.toString.call(val);
|
70
|
-
const isArray = type === '[object Array]';
|
71
|
-
const isObject = type === '[object Object]';
|
72
|
-
if (!val) {
|
73
|
-
return true;
|
74
|
-
}
|
75
|
-
if (isArray) {
|
76
|
-
return !val.length;
|
77
|
-
}
|
78
|
-
if (isObject) {
|
79
|
-
return !Object.keys(val).length;
|
80
|
-
}
|
81
|
-
}
|
82
|
-
target = Object.keys(target).reduce((result, key) => {
|
83
|
-
const type = Object.prototype.toString.call(target[key]);
|
84
|
-
const isObject = type === '[object Object]' || type === '[object Array]';
|
85
|
-
if (!isObject || isEmpty(target[key])) {
|
86
|
-
result[key] = target[key];
|
87
|
-
return result;
|
88
|
-
}
|
89
|
-
return addKeys(key, result, flatten(target[key], opts));
|
90
|
-
}, {});
|
91
|
-
Object.keys(target).forEach(key => {
|
92
|
-
const split = key.split(delimiter).map(transformKey);
|
93
|
-
let key1 = getkey(split.shift());
|
94
|
-
let key2 = getkey(split[0]);
|
95
|
-
let recipient = result;
|
96
|
-
while (key2 !== undefined) {
|
97
|
-
const recipient_key_1 = key1 && _get(recipient, key1);
|
98
|
-
const type = Object.prototype.toString.call(recipient_key_1);
|
99
|
-
const isobject = type === '[object Object]' || type === '[object Array]';
|
100
|
-
if (!overwrite && !isobject && typeof recipient_key_1 !== 'undefined') {
|
101
|
-
return;
|
102
|
-
}
|
103
|
-
if (overwrite && !isobject || !overwrite && recipient_key_1 == null) {
|
104
|
-
recipient[key1] = typeof key2 === 'number' && !object ? [] : {};
|
105
|
-
}
|
106
|
-
recipient = key1 && _get(recipient, key1);
|
107
|
-
if (split.length > 0) {
|
108
|
-
key1 = getkey(split.shift());
|
109
|
-
key2 = getkey(split[0]);
|
110
|
-
}
|
111
|
-
}
|
112
|
-
recipient[key1] = unflatten(target[key], opts);
|
113
|
-
});
|
114
|
-
return result;
|
115
|
-
};
|
116
|
-
const flat = {
|
117
|
-
flatten,
|
118
|
-
unflatten
|
119
|
-
};
|
120
|
-
|
121
20
|
const Emitter = new TinyEmitter();
|
122
21
|
|
123
22
|
const EMPTY_STRING_REGEXP = /^\s*$/;
|
@@ -849,6 +748,164 @@ const FlowerCoreReducers = {
|
|
849
748
|
}
|
850
749
|
};
|
851
750
|
|
751
|
+
function isBuffer (obj) {
|
752
|
+
return obj &&
|
753
|
+
obj.constructor &&
|
754
|
+
(typeof obj.constructor.isBuffer === 'function') &&
|
755
|
+
obj.constructor.isBuffer(obj)
|
756
|
+
}
|
757
|
+
|
758
|
+
function keyIdentity (key) {
|
759
|
+
return key
|
760
|
+
}
|
761
|
+
|
762
|
+
function flatten (target, opts) {
|
763
|
+
opts = opts || {};
|
764
|
+
|
765
|
+
const delimiter = opts.delimiter || '.';
|
766
|
+
const maxDepth = opts.maxDepth;
|
767
|
+
const transformKey = opts.transformKey || keyIdentity;
|
768
|
+
const output = {};
|
769
|
+
|
770
|
+
function step (object, prev, currentDepth) {
|
771
|
+
currentDepth = currentDepth || 1;
|
772
|
+
Object.keys(object).forEach(function (key) {
|
773
|
+
const value = object[key];
|
774
|
+
const isarray = opts.safe && Array.isArray(value);
|
775
|
+
const type = Object.prototype.toString.call(value);
|
776
|
+
const isbuffer = isBuffer(value);
|
777
|
+
const isobject = (
|
778
|
+
type === '[object Object]' ||
|
779
|
+
type === '[object Array]'
|
780
|
+
);
|
781
|
+
|
782
|
+
const newKey = prev
|
783
|
+
? prev + delimiter + transformKey(key)
|
784
|
+
: transformKey(key);
|
785
|
+
|
786
|
+
if (!isarray && !isbuffer && isobject && Object.keys(value).length &&
|
787
|
+
(!opts.maxDepth || currentDepth < maxDepth)) {
|
788
|
+
return step(value, newKey, currentDepth + 1)
|
789
|
+
}
|
790
|
+
|
791
|
+
output[newKey] = value;
|
792
|
+
});
|
793
|
+
}
|
794
|
+
|
795
|
+
step(target);
|
796
|
+
|
797
|
+
return output
|
798
|
+
}
|
799
|
+
|
800
|
+
function unflatten (target, opts) {
|
801
|
+
opts = opts || {};
|
802
|
+
|
803
|
+
const delimiter = opts.delimiter || '.';
|
804
|
+
const overwrite = opts.overwrite || false;
|
805
|
+
const transformKey = opts.transformKey || keyIdentity;
|
806
|
+
const result = {};
|
807
|
+
|
808
|
+
const isbuffer = isBuffer(target);
|
809
|
+
if (isbuffer || Object.prototype.toString.call(target) !== '[object Object]') {
|
810
|
+
return target
|
811
|
+
}
|
812
|
+
|
813
|
+
// safely ensure that the key is
|
814
|
+
// an integer.
|
815
|
+
function getkey (key) {
|
816
|
+
const parsedKey = Number(key);
|
817
|
+
|
818
|
+
return (
|
819
|
+
isNaN(parsedKey) ||
|
820
|
+
key.indexOf('.') !== -1 ||
|
821
|
+
opts.object
|
822
|
+
)
|
823
|
+
? key
|
824
|
+
: parsedKey
|
825
|
+
}
|
826
|
+
|
827
|
+
function addKeys (keyPrefix, recipient, target) {
|
828
|
+
return Object.keys(target).reduce(function (result, key) {
|
829
|
+
result[keyPrefix + delimiter + key] = target[key];
|
830
|
+
|
831
|
+
return result
|
832
|
+
}, recipient)
|
833
|
+
}
|
834
|
+
|
835
|
+
function isEmpty (val) {
|
836
|
+
const type = Object.prototype.toString.call(val);
|
837
|
+
const isArray = type === '[object Array]';
|
838
|
+
const isObject = type === '[object Object]';
|
839
|
+
|
840
|
+
if (!val) {
|
841
|
+
return true
|
842
|
+
} else if (isArray) {
|
843
|
+
return !val.length
|
844
|
+
} else if (isObject) {
|
845
|
+
return !Object.keys(val).length
|
846
|
+
}
|
847
|
+
}
|
848
|
+
|
849
|
+
target = Object.keys(target).reduce(function (result, key) {
|
850
|
+
const type = Object.prototype.toString.call(target[key]);
|
851
|
+
const isObject = (type === '[object Object]' || type === '[object Array]');
|
852
|
+
if (!isObject || isEmpty(target[key])) {
|
853
|
+
result[key] = target[key];
|
854
|
+
return result
|
855
|
+
} else {
|
856
|
+
return addKeys(
|
857
|
+
key,
|
858
|
+
result,
|
859
|
+
flatten(target[key], opts)
|
860
|
+
)
|
861
|
+
}
|
862
|
+
}, {});
|
863
|
+
|
864
|
+
Object.keys(target).forEach(function (key) {
|
865
|
+
const split = key.split(delimiter).map(transformKey);
|
866
|
+
let key1 = getkey(split.shift());
|
867
|
+
let key2 = getkey(split[0]);
|
868
|
+
let recipient = result;
|
869
|
+
|
870
|
+
while (key2 !== undefined) {
|
871
|
+
if (key1 === '__proto__') {
|
872
|
+
return
|
873
|
+
}
|
874
|
+
|
875
|
+
const type = Object.prototype.toString.call(recipient[key1]);
|
876
|
+
const isobject = (
|
877
|
+
type === '[object Object]' ||
|
878
|
+
type === '[object Array]'
|
879
|
+
);
|
880
|
+
|
881
|
+
// do not write over falsey, non-undefined values if overwrite is false
|
882
|
+
if (!overwrite && !isobject && typeof recipient[key1] !== 'undefined') {
|
883
|
+
return
|
884
|
+
}
|
885
|
+
|
886
|
+
if ((overwrite && !isobject) || (!overwrite && recipient[key1] == null)) {
|
887
|
+
recipient[key1] = (
|
888
|
+
typeof key2 === 'number' &&
|
889
|
+
!opts.object
|
890
|
+
? []
|
891
|
+
: {}
|
892
|
+
);
|
893
|
+
}
|
894
|
+
|
895
|
+
recipient = recipient[key1];
|
896
|
+
if (split.length > 0) {
|
897
|
+
key1 = getkey(split.shift());
|
898
|
+
key2 = getkey(split[0]);
|
899
|
+
}
|
900
|
+
}
|
901
|
+
|
902
|
+
// unflatten again for 'messy objects'
|
903
|
+
recipient[key1] = unflatten(target[key], opts);
|
904
|
+
});
|
905
|
+
|
906
|
+
return result
|
907
|
+
}
|
908
|
+
|
852
909
|
const FlowerCoreStateSelectors = {
|
853
910
|
selectGlobal: state => state && state.flower,
|
854
911
|
selectFlower: name => state => _get(state, [name]),
|
@@ -915,7 +972,7 @@ const FlowerCoreStateSelectors = {
|
|
915
972
|
});
|
916
973
|
}, {});
|
917
974
|
const [disabled] = MatchRules.rulesMatcher(rules, {
|
918
|
-
...
|
975
|
+
...unflatten(res)
|
919
976
|
}, false, {
|
920
977
|
prefix: flowName
|
921
978
|
});
|
@@ -966,4 +1023,4 @@ var RulesOperators;
|
|
966
1023
|
RulesOperators["$regex"] = "$regex";
|
967
1024
|
})(RulesOperators || (RulesOperators = {}));
|
968
1025
|
|
969
|
-
export { CoreUtils, Emitter,
|
1026
|
+
export { CoreUtils, Emitter, FlowerCoreReducers, FlowerStateUtils, MatchRules, RulesModes, RulesOperators, FlowerCoreStateSelectors as Selectors };
|
package/dist/src/index.d.ts
CHANGED
package/package.json
CHANGED