Skip to content

Commit 3a2ab7a

Browse files
committed
chore: upgrade aegir
1 parent 6f431d2 commit 3a2ab7a

File tree

9 files changed

+4091
-6556
lines changed

9 files changed

+4091
-6556
lines changed

compare.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* @param {Uint8Array} a
77
* @param {Uint8Array} b
8-
* @returns {Number}
8+
* @returns {number}
99
*/
1010
function compare (a, b) {
1111
for (let i = 0; i < a.byteLength; i++) {

concat.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Returns a new Uint8Array created by concatenating the passed ArrayLikes
55
*
66
* @param {Array<ArrayLike<number>>} arrays
7-
* @param {Number} [length]
7+
* @param {number} [length]
88
* @returns {Uint8Array}
99
*/
1010
function concat (arrays, length) {

from-string.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
'use strict'
22

3-
const { names } = require('multibase/src/constants')
3+
const { encoding: getCodec } = require('multibase')
44
const { TextEncoder } = require('web-encoding')
55
const utf8Encoder = new TextEncoder()
66

77
/**
8-
* Interperets each character in a string as a byte and
8+
* @typedef {import('multibase/src/types').BaseName} BaseName
9+
*/
10+
11+
/**
12+
* Interprets each character in a string as a byte and
913
* returns a Uint8Array of those bytes.
1014
*
11-
* @param {String} string The string to turn into an array
15+
* @param {string} string - The string to turn into an array
1216
* @returns {Uint8Array}
1317
*/
1418
function asciiStringToUint8Array (string) {
@@ -28,10 +32,9 @@ function asciiStringToUint8Array (string) {
2832
*
2933
* Also `ascii` which is similar to node's 'binary' encoding.
3034
*
31-
* @param {String} string
32-
* @param {String} [encoding=utf8] utf8, base16, base64, base64urlpad, etc
35+
* @param {string} string
36+
* @param {BaseName | 'utf8' | 'utf-8' | 'ascii'} [encoding=utf8] - utf8, base16, base64, base64urlpad, etc
3337
* @returns {Uint8Array}
34-
* @see {@link https://www.npmjs.com/package/multibase|multibase} for supported encodings other than `utf8`
3538
*/
3639
function fromString (string, encoding = 'utf8') {
3740
if (encoding === 'utf8' || encoding === 'utf-8') {
@@ -42,13 +45,7 @@ function fromString (string, encoding = 'utf8') {
4245
return asciiStringToUint8Array(string)
4346
}
4447

45-
const codec = names[encoding]
46-
47-
if (!codec) {
48-
throw new Error('Unknown base')
49-
}
50-
51-
return codec.decode(string)
48+
return getCodec(encoding).decode(string)
5249
}
5350

5451
module.exports = fromString

0 commit comments

Comments
 (0)