1
0
Fork 0

fix(buffer): restrict encodings

This commit is contained in:
ssube 2020-09-05 18:43:51 -05:00
parent 2509745c00
commit 85d7e56d14
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
2 changed files with 5 additions and 3 deletions

View File

@ -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&lt;Buffer&gt; | | | chunks | Array&lt;Buffer&gt; | |
| encoding | string | | | encoding | AllowedBufferEncoding | |
<b>Returns:</b> <b>Returns:</b>

View File

@ -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 '';
} }