mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
buffer: add isAscii method
PR-URL: https://github.com/nodejs/node/pull/46046 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
parent
49413ad8ae
commit
babe6d7c84
4 changed files with 83 additions and 0 deletions
|
@ -56,6 +56,7 @@ const {
|
|||
compareOffset,
|
||||
createFromString,
|
||||
fill: bindingFill,
|
||||
isAscii: bindingIsAscii,
|
||||
isUtf8: bindingIsUtf8,
|
||||
indexOfBuffer,
|
||||
indexOfNumber,
|
||||
|
@ -1320,11 +1321,20 @@ function isUtf8(input) {
|
|||
throw new ERR_INVALID_ARG_TYPE('input', ['TypedArray', 'Buffer'], input);
|
||||
}
|
||||
|
||||
function isAscii(input) {
|
||||
if (isTypedArray(input) || isAnyArrayBuffer(input)) {
|
||||
return bindingIsAscii(input);
|
||||
}
|
||||
|
||||
throw new ERR_INVALID_ARG_TYPE('input', ['ArrayBuffer', 'Buffer', 'TypedArray'], input);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
Buffer,
|
||||
SlowBuffer,
|
||||
transcode,
|
||||
isUtf8,
|
||||
isAscii,
|
||||
|
||||
// Legacy
|
||||
kMaxLength,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue