-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #498 from streamich/resp-command
RESP command decoding
- Loading branch information
Showing
5 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {bufferToUint8Array} from './bufferToUint8Array'; | ||
|
||
export const ascii = (txt: TemplateStringsArray | string | [string]): Uint8Array => { | ||
if (typeof txt === 'string') return ascii([txt]); | ||
[txt] = txt; | ||
const len = txt.length; | ||
const res = new Uint8Array(len); | ||
for (let i = 0; i < len; i++) res[i] = txt.charCodeAt(i); | ||
return res; | ||
}; | ||
|
||
export const utf8 = (txt: TemplateStringsArray | [string] | string): Uint8Array => { | ||
if (typeof txt === 'string') return utf8([txt]); | ||
[txt] = txt; | ||
return bufferToUint8Array(Buffer.from(txt, 'utf8')); | ||
}; |