UNPKG

is-integer-in-range

Version:
1 lines 1.47 kB
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,wCAAyC;AAEzC;;;;GAIG;AACH,SAAwB,gBAAgB,CAAC,KAAa,EAAE,KAAa,EAAE,GAAW;IAC9E,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QACtD,MAAM,IAAI,SAAS,CAAC,sCAAsC,CAAC,CAAC;KAC/D;IAED,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,GAAG,CAAC;AAC9D,CAAC;AAND,mCAMC;AAED;;;;;;;GAOG;AACH,SAAgB,kBAAkB,CAAC,KAAa,EAAE,GAAW;IACzD,OAAO,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;AACxD,CAAC;AAFD,gDAEC","sourcesContent":["import isInteger = require(\"is-integer\");\n\n/**\n * Tests if the specified value is an integer in the specified range.\n *\n * The range is inclusive of the start and end values.\n */\nexport default function isIntegerInRange(value: number, start: number, end: number): boolean {\n if (typeof start !== \"number\" || typeof end !== \"number\") {\n throw new TypeError(\"Expected start and end to be numbers\");\n }\n\n return isInteger(value) && value >= start && value <= end;\n}\n\n/**\n * Curried variant of isIntegerInRange.\n *\n * Takes a range specified as a start and end value, and returns a function\n * that tests if a specified value is an integer within the range.\n *\n * The range is inclusive of the start and end values.\n */\nexport function isIntegerInRangeFn(start: number, end: number): (value: number) => boolean {\n return value => isIntegerInRange(value, start, end);\n}\n"]}