fix(buffer): restrict encodings
This commit is contained in:
parent
2509745c00
commit
85d7e56d14
|
@ -9,7 +9,7 @@ Concatenate then encode a list of buffers.
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare function encode(chunks: Array<Buffer>, encoding: string): string;
|
||||
export declare function encode(chunks: Array<Buffer>, encoding: AllowedBufferEncoding): string;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
@ -17,7 +17,7 @@ export declare function encode(chunks: Array<Buffer>, encoding: string): string;
|
|||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| chunks | Array<Buffer> | |
|
||||
| encoding | string | |
|
||||
| encoding | AllowedBufferEncoding | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
export type AllowedBufferEncoding = 'ascii' | 'utf-8';
|
||||
|
||||
/**
|
||||
* Concatenate a list of buffers.
|
||||
*
|
||||
|
@ -13,7 +15,7 @@ export function concat(chunks: Array<Buffer>): Buffer {
|
|||
*
|
||||
* @public
|
||||
*/
|
||||
export function encode(chunks: Array<Buffer>, encoding: string): string {
|
||||
export function encode(chunks: Array<Buffer>, encoding: AllowedBufferEncoding): string {
|
||||
if (chunks.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue