TextEncoder allows non-Uint8Array Buffers (#596)
* TextEncoder allows non-Uint8Array Buffers * Add eslintrc to eslintignore
This commit is contained in:
@@ -8,7 +8,7 @@ describe('bufferToU8a', (): void => {
|
||||
it('returns an empty buffer when null provided', (): void => {
|
||||
expect(
|
||||
bufferToU8a(null)
|
||||
).toEqual(new Uint8Array([]));
|
||||
).toEqual(new Uint8Array());
|
||||
});
|
||||
|
||||
it('returns a Uint8Buffer with the correct values', (): void => {
|
||||
|
||||
@@ -17,9 +17,5 @@
|
||||
* ```
|
||||
*/
|
||||
export default function bufferToU8a (buffer?: Buffer | number[] | null): Uint8Array {
|
||||
if (!buffer) {
|
||||
return new Uint8Array([]);
|
||||
}
|
||||
|
||||
return new Uint8Array(buffer);
|
||||
return new Uint8Array(buffer || []);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user