Skip to content

Commit 10ebde5

Browse files
authored
Merge pull request #4 from Borewit/generic-array
Ability to override Uint8Array with a inherited type e.g. Buffer
2 parents e921399 + 4850338 commit 10ebde5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

index.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Read-only token
33
* See https://github.com/Borewit/strtok3 for more information
44
*/
5-
export interface IGetToken<T> {
5+
export interface IGetToken<Value, Array extends Uint8Array = Uint8Array> {
66

77
/**
88
* Length of encoded token in bytes
@@ -15,16 +15,16 @@ export interface IGetToken<T> {
1515
* @param offset - Decode offset
1616
* @return decoded value
1717
*/
18-
get(array: Uint8Array, offset: number): T;
18+
get(array: Array, offset: number): Value;
1919
}
2020

21-
export interface IToken<T> extends IGetToken<T> {
21+
export interface IToken<Value, Array extends Uint8Array = Uint8Array> extends IGetToken<Value, Array> {
2222
/**
2323
* Encode value to buffer
2424
* @param array - Uint8Array to write the encoded value to
2525
* @param offset - Buffer write offset
2626
* @param value - Value to decode of type T
2727
* @return offset plus number of bytes written
2828
*/
29-
put(array: Uint8Array, offset: number, value: T): number
29+
put(array: Array, offset: number, value: Value): number
3030
}

0 commit comments

Comments
 (0)