@nodescript/stdlib
Version:
Standard Node Definitions
44 lines (43 loc) • 985 B
JavaScript
export const module = {
version: '1.4.2',
moduleName: 'Object / Key Value',
description: 'Creates an object with computed key and value. If raw is specified, the key is interpreted as-is.',
keywords: ['entries', 'wrap'],
params: {
key: {
schema: {
type: 'string',
},
},
value: {
schema: {
type: 'any',
},
},
raw: {
schema: {
type: 'boolean',
default: false,
},
advanced: true,
},
},
result: {
schema: {
type: 'object',
properties: {},
additionalProperties: { type: 'any' },
},
}
};
export const compute = (params, ctx) => {
const { key, value, raw } = params;
const res = {};
if (raw) {
res[key] = value;
}
else {
ctx.lib.set(res, key, value);
}
return res;
};