TextEncoder allows non-Uint8Array Buffers (#596)

* TextEncoder allows non-Uint8Array Buffers

* Add eslintrc to eslintignore
This commit is contained in:
Jaco Greeff
2020-05-11 09:57:00 +02:00
committed by GitHub
parent d3583dc432
commit d1de30907f
17 changed files with 1106 additions and 953 deletions
+4 -4
View File
@@ -8,25 +8,25 @@ describe('numberToU8a', (): void => {
it('converts 0 to empty', (): void => {
expect(
numberToU8a(0)
).toEqual(new Uint8Array([]));
).toEqual(new Uint8Array());
});
it('converts undefined to empty', (): void => {
expect(
numberToU8a()
).toEqual(new Uint8Array([]));
).toEqual(new Uint8Array());
});
it('converts null to empty', (): void => {
expect(
numberToU8a(null)
).toEqual(new Uint8Array([]));
).toEqual(new Uint8Array());
});
it('converts NaN to empty', (): void => {
expect(
numberToU8a(NaN)
).toEqual(new Uint8Array([]));
).toEqual(new Uint8Array());
});
it('converts values to the u8a', (): void => {
+1 -1
View File
@@ -21,7 +21,7 @@ import numberToHex from './toHex';
*/
export default function numberToU8a (value?: number | null, bitLength = -1): Uint8Array {
if (!value || isNaN(value)) {
return new Uint8Array([]);
return new Uint8Array();
}
return hexToU8a(