@opentiny/vue-renderless
Version:
An enterprise-class UI component library, support both Vue.js 2 and Vue.js 3, as well as PC and mobile.
45 lines (44 loc) • 1.19 kB
JavaScript
import "../../../chunk-G2ADBYYC.js";
import helperDeleteProperty from "./helperDeleteProperty";
import isFunction from "./isFunction";
import each from "./each";
import arrayEach from "../array/arrayEach";
import lastEach from "./lastEach";
import clear from "./clear";
import eqNull from "./eqNull";
const pluckProperty = (name) => (obj, key) => key === name;
const remove = (obj, iterate, context) => {
if (obj) {
if (!eqNull(iterate)) {
let removeIndexs = [];
let rest = [];
if (!isFunction(iterate)) {
iterate = pluckProperty(iterate);
}
each(obj, (item, index, rest2) => {
if (iterate.call(context, item, index, rest2)) {
removeIndexs.push(index);
}
});
if (Array.isArray(obj)) {
lastEach(removeIndexs, (item) => {
rest.push(obj[item]);
obj.splice(item, 1);
});
} else {
rest = {};
arrayEach(removeIndexs, (key) => {
rest[key] = obj[key];
helperDeleteProperty(obj, key);
});
}
return rest;
}
return clear(obj);
}
return obj;
};
var remove_default = remove;
export {
remove_default as default
};