Skip to content

Commit 4b971ec

Browse files
authored
feat: export supported string encodings (#18)
To make consuming the types of this module easier, export the list of supported to/from string encodings
1 parent 18f8cb1 commit 4b971ec

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

from-string.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const { encoding: getCodec } = require('multibase')
44
const utf8Encoder = new TextEncoder()
55

66
/**
7-
* @typedef {import('multibase/src/types').BaseName} BaseName
7+
* @typedef {import('multibase/src/types').BaseName | 'utf8' | 'utf-8' | 'ascii' | undefined} SupportedEncodings
88
*/
99

1010
/**
@@ -31,7 +31,7 @@ function asciiStringToUint8Array (string) {
3131
* Also `ascii` which is similar to node's 'binary' encoding.
3232
*
3333
* @param {string} string
34-
* @param {BaseName | 'utf8' | 'utf-8' | 'ascii'} [encoding=utf8] - utf8, base16, base64, base64urlpad, etc
34+
* @param {SupportedEncodings} [encoding=utf8] - utf8, base16, base64, base64urlpad, etc
3535
* @returns {Uint8Array}
3636
*/
3737
function fromString (string, encoding = 'utf8') {

to-string.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const { encoding: getCodec } = require('multibase')
44
const utf8Decoder = new TextDecoder('utf8')
55

66
/**
7-
* @typedef {import('multibase/src/types').BaseName} BaseName
7+
* @typedef {import('multibase/src/types').BaseName | 'utf8' | 'utf-8' | 'ascii' | undefined} SupportedEncodings
88
*/
99

1010
/**
@@ -30,7 +30,7 @@ function uint8ArrayToAsciiString (array) {
3030
* Also `ascii` which is similar to node's 'binary' encoding.
3131
*
3232
* @param {Uint8Array} array - The array to turn into a string
33-
* @param {BaseName | 'utf8' | 'utf-8' | 'ascii'} [encoding=utf8] - The encoding to use
33+
* @param {SupportedEncodings} [encoding=utf8] - The encoding to use
3434
* @returns {string}
3535
*/
3636
function toString (array, encoding = 'utf8') {

0 commit comments

Comments
 (0)