grid filter

This commit is contained in:
2023-04-24 17:38:48 +08:00
parent 4096068a62
commit 811467bc7a
3 changed files with 146 additions and 33 deletions

View File

@ -39,18 +39,6 @@ function truncate(v) {
return (v > 0 ? Math.floor : Math.ceil)(v);
}
function distinct(array, key, filter) {
const dict = Object.create(null);
for (let item of array) {
const v = typeof filter === 'function' ? filter(item) : item[key];
const val = v?.value ?? v;
if (!Object.prototype.hasOwnProperty.call(dict, val)) {
dict[val] = v;
}
}
return Object.values(dict);
}
function isEmail(text) {
return /^\w[-\w.+]*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(text);
}
@ -87,7 +75,6 @@ export {
throttle,
debounce,
truncate,
distinct,
isEmail,
isPhone
}