From a5c7efafd65d796b205871e4e5a3852cc8b50d6c Mon Sep 17 00:00:00 2001 From: biejia Date: Wed, 29 Jul 2020 16:16:43 +0800 Subject: [PATCH] feat: add encoder types --- lib/common/utils/encoder.ts | 6 ++++-- lib/types/experimental.ts | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 lib/types/experimental.ts diff --git a/lib/common/utils/encoder.ts b/lib/common/utils/encoder.ts index c05373a13..7476afb09 100644 --- a/lib/common/utils/encoder.ts +++ b/lib/common/utils/encoder.ts @@ -1,4 +1,6 @@ -export function encoder(str: string, encoding = 'utf-8') { +import { THeaderEncoding } from '../../types/experimental'; + +export function encoder(str: string, encoding: THeaderEncoding = 'utf-8') { if (encoding === 'utf-8') return str; return Buffer.from(str).toString('latin1'); -} \ No newline at end of file +} diff --git a/lib/types/experimental.ts b/lib/types/experimental.ts new file mode 100644 index 000000000..9c4a96cca --- /dev/null +++ b/lib/types/experimental.ts @@ -0,0 +1 @@ +export type THeaderEncoding = 'utf-8' | 'latin1';