LendAndRegret/node_modules/es-toolkit/dist/compat/util/toSafeInteger.js
2026-05-02 17:27:43 +08:00

17 lines
494 B
JavaScript

'use strict';
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const toInteger = require('./toInteger.js');
const MAX_SAFE_INTEGER = require('../_internal/MAX_SAFE_INTEGER.js');
const clamp = require('../math/clamp.js');
function toSafeInteger(value) {
if (value == null) {
return 0;
}
return clamp.clamp(toInteger.toInteger(value), -MAX_SAFE_INTEGER.MAX_SAFE_INTEGER, MAX_SAFE_INTEGER.MAX_SAFE_INTEGER);
}
exports.toSafeInteger = toSafeInteger;