@nodescript/stdlib
Version:
Standard Node Definitions
40 lines (39 loc) • 865 B
JavaScript
export const module = {
version: '1.4.4',
moduleName: 'Object / Pick',
description: `
Picks specified keys from an object.
`,
params: {
object: {
schema: { type: 'any' },
},
keys: {
schema: {
type: 'array',
items: { type: 'string' },
},
attributes: {
keyof: 'object',
},
}
},
result: {
schema: {
type: 'object',
properties: {},
additionalProperties: { type: 'any' },
},
},
};
export const compute = params => {
const { object, keys } = params;
const res = {};
for (const key of keys) {
const value = object[key];
if (value !== undefined) {
res[key] = value;
}
}
return res;
};