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>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
export declare function encode(chunks: Array<Buffer>, encoding: string): string;
|
export declare function encode(chunks: Array<Buffer>, encoding: AllowedBufferEncoding): string;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
|
@ -17,7 +17,7 @@ export declare function encode(chunks: Array<Buffer>, encoding: string): string;
|
||||||
| Parameter | Type | Description |
|
| Parameter | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| chunks | Array<Buffer> | |
|
| chunks | Array<Buffer> | |
|
||||||
| encoding | string | |
|
| encoding | AllowedBufferEncoding | |
|
||||||
|
|
||||||
<b>Returns:</b>
|
<b>Returns:</b>
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
export type AllowedBufferEncoding = 'ascii' | 'utf-8';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Concatenate a list of buffers.
|
* Concatenate a list of buffers.
|
||||||
*
|
*
|
||||||
|
@ -13,7 +15,7 @@ export function concat(chunks: Array<Buffer>): Buffer {
|
||||||
*
|
*
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export function encode(chunks: Array<Buffer>, encoding: string): string {
|
export function encode(chunks: Array<Buffer>, encoding: AllowedBufferEncoding): string {
|
||||||
if (chunks.length === 0) {
|
if (chunks.length === 0) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue