@selenite/commons
Version:
This typescript package provides a set of frequently used utilities, types and svelte actions for building projects with Typescript and Svelte.
19 lines (18 loc) • 577 B
JavaScript
export function getProperties(obj) {
const res = [];
for (const k of Object.keys(obj)) {
res.push(k);
}
for (const [k, v] of Object.entries(Object.getOwnPropertyDescriptors(Object.getPrototypeOf(obj)))) {
if (!v.get || !v.set)
continue;
res.push(k);
}
return res;
}
export function applyParams(target, constructor, params) {
if (Object.keys(params).length === 0)
return;
const ref = new constructor();
Object.assign(target, Object.fromEntries(Object.entries(params).filter(([k]) => k in ref)));
}