my-idlers/node_modules/collect.js/dist/methods/whenEmpty.js
cp6 fd22b0bf58 V2 (Laravel re-make)
V2 (Laravel re-make)
2022-03-06 02:02:12 +11:00

19 lines
436 B
JavaScript
Vendored

'use strict';
module.exports = function whenEmpty(fn, defaultFn) {
if (Array.isArray(this.items) && !this.items.length) {
return fn(this);
}if (!Object.keys(this.items).length) {
return fn(this);
}
if (defaultFn !== undefined) {
if (Array.isArray(this.items) && this.items.length) {
return defaultFn(this);
}if (Object.keys(this.items).length) {
return defaultFn(this);
}
}
return this;
};