@kizmann/pico-js 0.5.3 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/pico-js.js +1 -1
- package/dist/pico-js.js.map +1 -1
- package/package.json +1 -1
- package/src/utility/array.js +4 -0
- package/src/utility/object.js +10 -2
package/package.json
CHANGED
package/src/utility/array.js
CHANGED
package/src/utility/object.js
CHANGED
@@ -281,15 +281,23 @@ export class Obj
|
|
281
281
|
|
282
282
|
static filter(obj, filter)
|
283
283
|
{
|
284
|
-
|
285
|
-
|
284
|
+
let result = {};
|
285
|
+
|
286
|
+
Obj.each(Obj.filterIndex(obj, filter), (key) => {
|
287
|
+
result[key] = obj[key];
|
286
288
|
});
|
289
|
+
|
290
|
+
return result;
|
287
291
|
}
|
288
292
|
|
289
293
|
static filterIndex(obj, filter)
|
290
294
|
{
|
291
295
|
return Any.keys(obj).filter((key) => {
|
292
296
|
|
297
|
+
if ( typeof filter === "undefined" ) {
|
298
|
+
return Any.isEmpty(obj[key]);
|
299
|
+
}
|
300
|
+
|
293
301
|
if ( Any.isFunction(filter) ) {
|
294
302
|
return filter.call({}, obj[key], key);
|
295
303
|
}
|