UNPKG

@nodescript/stdlib

Version:
25 lines (24 loc) 558 B
export const module = { version: '1.0.4', moduleName: 'Math / Clamp', description: ` Returns a value clamped to inclusive range of min and max. `, params: { value: { schema: { type: 'number' }, }, min: { schema: { type: 'number' }, }, max: { schema: { type: 'number' }, }, }, result: { schema: { type: 'number' }, } }; export const compute = params => { return Math.min(Math.max(params.value, params.min), params.max); };