@@ -959,30 +959,39 @@ function writeFloatBackwards(val, offset = 0) { |
959 | 959 |
|
960 | 960 | class FastBuffer extends Uint8Array {} |
961 | 961 |
|
962 | | -function asciiWrite(buf, string, offset = 0, length = buf.byteLength - offset) { |
| 962 | +function asciiWrite(buf, string, offset = 0, length) { |
| 963 | + offset = Number(offset); |
963 | 964 | if (offset < 0 || offset > buf.byteLength) { |
964 | 965 | throw new ERR_BUFFER_OUT_OF_BOUNDS('offset'); |
965 | 966 | } |
| 967 | + if (length === undefined) length = buf.byteLength - offset; |
| 968 | + else length = Number(length); |
966 | 969 | if (length < 0 || length > buf.byteLength - offset) { |
967 | 970 | throw new ERR_BUFFER_OUT_OF_BOUNDS('length'); |
968 | 971 | } |
969 | 972 | return asciiWriteStatic(buf, string, offset, length); |
970 | 973 | } |
971 | 974 |
|
972 | | -function latin1Write(buf, string, offset = 0, length = buf.byteLength - offset) { |
| 975 | +function latin1Write(buf, string, offset = 0, length) { |
| 976 | + offset = Number(offset); |
973 | 977 | if (offset < 0 || offset > buf.byteLength) { |
974 | 978 | throw new ERR_BUFFER_OUT_OF_BOUNDS('offset'); |
975 | 979 | } |
| 980 | + if (length === undefined) length = buf.byteLength - offset; |
| 981 | + else length = Number(length); |
976 | 982 | if (length < 0 || length > buf.byteLength - offset) { |
977 | 983 | throw new ERR_BUFFER_OUT_OF_BOUNDS('length'); |
978 | 984 | } |
979 | 985 | return latin1WriteStatic(buf, string, offset, length); |
980 | 986 | } |
981 | 987 |
|
982 | | -function utf8Write(buf, string, offset = 0, length = buf.byteLength - offset) { |
| 988 | +function utf8Write(buf, string, offset = 0, length) { |
| 989 | + offset = Number(offset); |
983 | 990 | if (offset < 0 || offset > buf.byteLength) { |
984 | 991 | throw new ERR_BUFFER_OUT_OF_BOUNDS('offset'); |
985 | 992 | } |
| 993 | + if (length === undefined) length = buf.byteLength - offset; |
| 994 | + else length = Number(length); |
986 | 995 | if (length < 0 || length > buf.byteLength - offset) { |
987 | 996 | throw new ERR_BUFFER_OUT_OF_BOUNDS('length'); |
988 | 997 | } |
|