@bbn/bbn 1.0.418 → 1.0.419
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/bbn.js +1 -1
- package/dist/bbn.js.map +1 -1
- package/dist/env.d.ts +2 -0
- package/dist/env.js +4 -0
- package/dist/fn/object/filter.js +25 -26
- package/package.json +1 -1
package/dist/env.d.ts
CHANGED
package/dist/env.js
CHANGED
package/dist/fn/object/filter.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import isArray from '../type/isArray.js';
|
|
2
|
-
import each from '../loop/each.js';
|
|
3
2
|
import { filterToConditions } from './filterToConditions.js';
|
|
4
3
|
import compareConditions from './compareConditions.js';
|
|
5
4
|
/**
|
|
@@ -62,35 +61,35 @@ export default function filter(arr, prop, val, operator) {
|
|
|
62
61
|
if (!prop || !arr.length) {
|
|
63
62
|
return arr;
|
|
64
63
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
64
|
+
bbn.env._enumerated.push(true);
|
|
65
|
+
if (typeof prop === 'object') {
|
|
66
|
+
operator = val;
|
|
67
|
+
cfg = prop;
|
|
68
|
+
}
|
|
69
|
+
else if (typeof prop === 'string') {
|
|
70
|
+
cfg[prop] = val;
|
|
71
|
+
}
|
|
72
|
+
else if (!isFn) {
|
|
73
|
+
throw new Error('Search function error: The prop argument should be a string or an object');
|
|
74
|
+
}
|
|
75
|
+
if (typeof (prop) === 'function') {
|
|
76
|
+
for (var i = 0; i < arr.length; i++) {
|
|
77
|
+
if (prop(arr[i], i)) {
|
|
78
|
+
res.push(arr[i]);
|
|
79
|
+
}
|
|
75
80
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
cfg = filterToConditions(cfg, operator);
|
|
84
|
+
if (cfg.conditions && cfg.logic) {
|
|
85
|
+
for (var i = 0; i < arr.length; i++) {
|
|
86
|
+
if (compareConditions(arr[i], cfg)) {
|
|
87
|
+
res.push(arr[i]);
|
|
80
88
|
}
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
cfg = filterToConditions(cfg, operator);
|
|
85
|
-
if (cfg.conditions && cfg.logic) {
|
|
86
|
-
each(arr, function (a) {
|
|
87
|
-
if (compareConditions(a, cfg)) {
|
|
88
|
-
res.push(a);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
89
|
}
|
|
92
90
|
}
|
|
93
|
-
return res;
|
|
94
91
|
}
|
|
92
|
+
bbn.env._enumerated.pop();
|
|
93
|
+
return res;
|
|
95
94
|
}
|
|
96
95
|
;
|