UNPKG

@nodescript/stdlib

Version:
34 lines (33 loc) 727 B
export const module = { version: '1.1.4', moduleName: 'Array / Length', description: ` Returns the length of an array. `, keywords: ['size', 'count'], params: { array: { schema: { type: 'any' }, }, }, result: { schema: { type: 'number', } }, }; export const compute = params => { const { array } = params; if (array) { if (typeof array.length === 'number') { return array.length; } if (typeof array.byteLength === 'number') { return array.byteLength; } if (typeof array.size === 'number') { return array.size; } } return 0; };