Skip to content

Commit

Permalink
feat: add encoder types
Browse files Browse the repository at this point in the history
  • Loading branch information
biejia committed Jul 29, 2020
1 parent 4758a2a commit ace9313
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/common/utils/encoder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export function encoder(str: string, encoding = 'utf-8') {
type Encoding = 'utf-8' | 'latin1';

export function encoder(str: string, encoding: Encoding = 'utf-8') {
if (encoding === 'utf-8') return str;
return Buffer.from(str).toString('latin1');
}
}

0 comments on commit ace9313

Please sign in to comment.