Files
HRM-System/node_modules/es-toolkit/dist/compat/util/toLength.mjs
2026-04-13 08:19:53 +08:00

13 lines
307 B
JavaScript

import { MAX_ARRAY_LENGTH } from '../_internal/MAX_ARRAY_LENGTH.mjs';
import { clamp } from '../math/clamp.mjs';
function toLength(value) {
if (value == null) {
return 0;
}
const length = Math.floor(Number(value));
return clamp(length, 0, MAX_ARRAY_LENGTH);
}
export { toLength };