UNPKG

adonis-api-resources

Version:
12 lines (11 loc) 467 B
export const pick = (entity, keys) => { return Object.assign({}, ...keys.map((key) => ({ [key]: entity[key] }))); }; export const omit = (entity, keys) => { const exclude = new Set(keys); const o = 'serialize' in entity && typeof entity.serialize === 'function' ? entity.serialize() : entity; return Object.fromEntries(Object.entries(o).filter((e) => !exclude.has(e[0]))); }; export const remap = (data, defineMap) => { return defineMap(data); };