GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — buffer: use faster integer argument check · nodejs/node@3012d31

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • buffer.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/buffer.js‎

Copy file name to clipboardExpand all lines: lib/buffer.js
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const {
2828
MathFloor,
2929
MathMin,
3030
MathTrunc,
31+
NumberIsInteger,
3132
NumberIsNaN,
3233
NumberMAX_SAFE_INTEGER,
3334
NumberMIN_SAFE_INTEGER,
@@ -208,23 +209,23 @@ function _copy(source, target, targetStart, sourceStart, sourceEnd) {
208209
if (targetStart === undefined) {
209210
targetStart = 0;
210211
} else {
211-
targetStart = toInteger(targetStart, 0);
212+
targetStart = NumberIsInteger(targetStart) ? targetStart : toInteger(targetStart, 0);
212213
if (targetStart < 0)
213214
throw new ERR_OUT_OF_RANGE('targetStart', '>= 0', targetStart);
214215
}
215216

216217
if (sourceStart === undefined) {
217218
sourceStart = 0;
218219
} else {
219-
sourceStart = toInteger(sourceStart, 0);
220+
sourceStart = NumberIsInteger(sourceStart) ? sourceStart : toInteger(sourceStart, 0);
220221
if (sourceStart < 0 || sourceStart > source.length)
221222
throw new ERR_OUT_OF_RANGE('sourceStart', `>= 0 && <= ${source.length}`, sourceStart);
222223
}
223224

224225
if (sourceEnd === undefined) {
225226
sourceEnd = source.length;
226227
} else {
227-
sourceEnd = toInteger(sourceEnd, 0);
228+
sourceEnd = NumberIsInteger(sourceEnd) ? sourceEnd : toInteger(sourceEnd, 0);
228229
if (sourceEnd < 0)
229230
throw new ERR_OUT_OF_RANGE('sourceEnd', '>= 0', sourceEnd);
230231
}

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.