| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -96,6 +96,7 @@ const { | |||
| 96 | 96 | ERR_INVALID_ARG_VALUE, | |
| 97 | 97 | ERR_INVALID_BUFFER_SIZE, | |
| 98 | 98 | ERR_OUT_OF_RANGE, | |
| 99 | + ERR_MISSING_ARGS, | ||
| 99 | 100 | ERR_UNKNOWN_ENCODING | |
| 100 | 101 | }, | |
| 101 | 102 | hideStackFrames | |
@@ -1218,6 +1219,9 @@ function btoa(input) { | |||
| 1218 | 1219 | // The implementation here has not been performance optimized in any way and | |
| 1219 | 1220 | // should not be. | |
| 1220 | 1221 | // Refs: https://github.com/nodejs/node/pull/38433#issuecomment-828426932 | |
| 1222 | + if (arguments.length === 0) { | ||
| 1223 | + throw new ERR_MISSING_ARGS('input'); | ||
| 1224 | + } | ||
| 1221 | 1225 | input = `${input}`; | |
| 1222 | 1226 | for (let n = 0; n < input.length; n++) { | |
| 1223 | 1227 | if (input[n].charCodeAt(0) > 0xff) | |
@@ -1234,6 +1238,9 @@ function atob(input) { | |||
| 1234 | 1238 | // The implementation here has not been performance optimized in any way and | |
| 1235 | 1239 | // should not be. | |
| 1236 | 1240 | // Refs: https://github.com/nodejs/node/pull/38433#issuecomment-828426932 | |
| 1241 | + if (arguments.length === 0) { | ||
| 1242 | + throw new ERR_MISSING_ARGS('input'); | ||
| 1243 | + } | ||
| 1237 | 1244 | input = `${input}`; | |
| 1238 | 1245 | for (let n = 0; n < input.length; n++) { | |
| 1239 | 1246 | if (!kBase64Digits.includes(input[n])) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,14 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + require('../common'); | ||
| 4 | + | ||
| 5 | + const { strictEqual, throws } = require('assert'); | ||
| 6 | + const buffer = require('buffer'); | ||
| 7 | + | ||
| 8 | + // Exported on the global object | ||
| 9 | + strictEqual(globalThis.atob, buffer.atob); | ||
| 10 | + strictEqual(globalThis.btoa, buffer.btoa); | ||
| 11 | + | ||
| 12 | + // Throws type error on no argument passed | ||
| 13 | + throws(() => buffer.atob(), /TypeError/); | ||
| 14 | + throws(() => buffer.btoa(), /TypeError/); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments