CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
toSafeInteger.js38 linesDownload Raw Back to lodash
1var baseClamp = require('./_baseClamp'),2    toInteger = require('./toInteger');3 4/** Used as references for various `Number` constants. */5var MAX_SAFE_INTEGER = 9007199254740991;6 7/**8 * Converts `value` to a safe integer. A safe integer can be compared and9 * represented correctly.10 *11 * @static12 * @memberOf _13 * @since 4.0.014 * @category Lang15 * @param {*} value The value to convert.16 * @returns {number} Returns the converted integer.17 * @example18 *19 * _.toSafeInteger(3.2);20 * // => 321 *22 * _.toSafeInteger(Number.MIN_VALUE);23 * // => 024 *25 * _.toSafeInteger(Infinity);26 * // => 900719925474099127 *28 * _.toSafeInteger('3.2');29 * // => 330 */31function toSafeInteger(value) {32  return value33    ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)34    : (value === 0 ? value : 0);35}36 37module.exports = toSafeInteger;38 
basant307/AI_Governance_Project · CoolFace