Skip to content

Commit

Permalink
Merge pull request #203 from hildjj/fix-176
Browse files Browse the repository at this point in the history
Allow any ArrayBufferView in decode.  Fixes #176
  • Loading branch information
hildjj authored Oct 25, 2024
2 parents 7868c19 + 4a9d507 commit 3f27076
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/cbor-web/types/lib/decoder.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ declare const NOT_FOUND: unique symbol;
/**
* Things that can act as inputs, from which a NoFilter can be created.
*/
type BufferLike = string | Buffer | ArrayBuffer | Uint8Array | Uint8ClampedArray | DataView | import("stream").Readable;
type BufferLike = string | Buffer | ArrayBuffer | ArrayBufferView | DataView | import("stream").Readable;
type ExtendedResults = {
/**
* The value that was found.
Expand Down
2 changes: 1 addition & 1 deletion packages/cbor/lib/decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class UnexpectedDataError extends Error {
/**
* Things that can act as inputs, from which a NoFilter can be created.
*
* @typedef {string|Buffer|ArrayBuffer|Uint8Array|Uint8ClampedArray
* @typedef {string|Buffer|ArrayBuffer|ArrayBufferView
* |DataView|import('stream').Readable} BufferLike
*/
/**
Expand Down
1 change: 1 addition & 0 deletions packages/cbor/test/decoder.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ test('typed arrays', t => {
t.is(cbor.decode(ab), 9007199254740992n);
t.is(cbor.decode(new Uint8Array(ab)), 9007199254740992n);
t.is(cbor.decode(new Uint8ClampedArray(ab)), 9007199254740992n);
t.is(cbor.decode(new Int8Array(ab)), 9007199254740992n);

// Beware endian-ness
const u8b = new Uint8ClampedArray([0x61, 0x62]);
Expand Down
2 changes: 1 addition & 1 deletion packages/cbor/types/lib/decoder.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ declare const NOT_FOUND: unique symbol;
/**
* Things that can act as inputs, from which a NoFilter can be created.
*/
type BufferLike = string | Buffer | ArrayBuffer | Uint8Array | Uint8ClampedArray | DataView | import("stream").Readable;
type BufferLike = string | Buffer | ArrayBuffer | ArrayBufferView | DataView | import("stream").Readable;
type ExtendedResults = {
/**
* The value that was found.
Expand Down

0 comments on commit 3f27076

Please sign in to comment.