MCPcopy Index your code
hub / github.com/nodejs/node / checkInt

Function checkInt

lib/internal/buffer.js:64–81  ·  view source on GitHub ↗
(value, min, max, buf, offset, byteLength)

Source from the content-addressed store, hash-verified

62}
63
64function checkInt(value, min, max, buf, offset, byteLength) {
65 if (value > max || value < min) {
66 const n = typeof min === 'bigint' ? 'n' : '';
67 let range;
68 if (byteLength > 3) {
69 if (min === 0 || min === 0n) {
70 range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`;
71 } else {
72 range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and ` +
73 `< 2${n} ** ${(byteLength + 1) * 8 - 1}${n}`;
74 }
75 } else {
76 range = `>= ${min}${n} and <= ${max}${n}`;
77 }
78 throw new ERR_OUT_OF_RANGE('value', range, value);
79 }
80 checkBounds(buf, offset, byteLength);
81}
82
83function boundsError(value, length, type) {
84 if (MathFloor(value) !== value) {

Callers 12

writeBigU_Int64LEFunction · 0.85
writeBigU_Int64BEFunction · 0.85
writeU_Int48LEFunction · 0.85
writeU_Int40LEFunction · 0.85
writeU_Int32LEFunction · 0.85
writeU_Int24LEFunction · 0.85
writeU_Int16LEFunction · 0.85
writeU_Int48BEFunction · 0.85
writeU_Int40BEFunction · 0.85
writeU_Int32BEFunction · 0.85
writeU_Int24BEFunction · 0.85
writeU_Int16BEFunction · 0.85

Calls 1

checkBoundsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…