@scure/base
Advanced tools
Comparing version 1.1.8 to 1.1.9
19
index.ts
@@ -483,3 +483,3 @@ /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */ | ||
words: number[] | Uint8Array, | ||
limit: number | false | ||
limit?: number | false | ||
): `${Lowercase<Prefix>}1${string}`; | ||
@@ -490,2 +490,3 @@ decode<Prefix extends string>( | ||
): Bech32Decoded<Prefix>; | ||
encodeFromBytes(prefix: string, bytes: Uint8Array): string; | ||
decodeToBytes(str: string): Bech32DecodedWithArray; | ||
@@ -514,2 +515,3 @@ decodeUnsafe(str: string, limit?: number | false): void | Bech32Decoded<string>; | ||
throw new Error(`bech32.encode prefix should be string, not ${typeof prefix}`); | ||
if (words instanceof Uint8Array) words = Array.from(words); | ||
if (!Array.isArray(words) || (words.length && typeof words[0] !== 'number')) | ||
@@ -559,3 +561,16 @@ throw new Error(`bech32.encode words should be array of numbers, not ${typeof words}`); | ||
return { encode, decode, decodeToBytes, decodeUnsafe, fromWords, fromWordsUnsafe, toWords }; | ||
function encodeFromBytes(prefix: string, bytes: Uint8Array) { | ||
return encode(prefix, toWords(bytes)); | ||
} | ||
return { | ||
encode, | ||
decode, | ||
encodeFromBytes, | ||
decodeToBytes, | ||
decodeUnsafe, | ||
fromWords, | ||
fromWordsUnsafe, | ||
toWords, | ||
}; | ||
} | ||
@@ -562,0 +577,0 @@ |
@@ -103,4 +103,5 @@ /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */ | ||
export interface Bech32 { | ||
encode<Prefix extends string>(prefix: Prefix, words: number[] | Uint8Array, limit: number | false): `${Lowercase<Prefix>}1${string}`; | ||
encode<Prefix extends string>(prefix: Prefix, words: number[] | Uint8Array, limit?: number | false): `${Lowercase<Prefix>}1${string}`; | ||
decode<Prefix extends string>(str: `${Prefix}1${string}`, limit?: number | false): Bech32Decoded<Prefix>; | ||
encodeFromBytes(prefix: string, bytes: Uint8Array): string; | ||
decodeToBytes(str: string): Bech32DecodedWithArray; | ||
@@ -107,0 +108,0 @@ decodeUnsafe(str: string, limit?: number | false): void | Bech32Decoded<string>; |
@@ -403,2 +403,4 @@ /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */ | ||
throw new Error(`bech32.encode prefix should be string, not ${typeof prefix}`); | ||
if (words instanceof Uint8Array) | ||
words = Array.from(words); | ||
if (!Array.isArray(words) || (words.length && typeof words[0] !== 'number')) | ||
@@ -442,3 +444,15 @@ throw new Error(`bech32.encode words should be array of numbers, not ${typeof words}`); | ||
} | ||
return { encode, decode, decodeToBytes, decodeUnsafe, fromWords, fromWordsUnsafe, toWords }; | ||
function encodeFromBytes(prefix, bytes) { | ||
return encode(prefix, toWords(bytes)); | ||
} | ||
return { | ||
encode, | ||
decode, | ||
encodeFromBytes, | ||
decodeToBytes, | ||
decodeUnsafe, | ||
fromWords, | ||
fromWordsUnsafe, | ||
toWords, | ||
}; | ||
} | ||
@@ -445,0 +459,0 @@ export const bech32 = /* @__PURE__ */ genBech32('bech32'); |
@@ -103,4 +103,5 @@ /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */ | ||
export interface Bech32 { | ||
encode<Prefix extends string>(prefix: Prefix, words: number[] | Uint8Array, limit: number | false): `${Lowercase<Prefix>}1${string}`; | ||
encode<Prefix extends string>(prefix: Prefix, words: number[] | Uint8Array, limit?: number | false): `${Lowercase<Prefix>}1${string}`; | ||
decode<Prefix extends string>(str: `${Prefix}1${string}`, limit?: number | false): Bech32Decoded<Prefix>; | ||
encodeFromBytes(prefix: string, bytes: Uint8Array): string; | ||
decodeToBytes(str: string): Bech32DecodedWithArray; | ||
@@ -107,0 +108,0 @@ decodeUnsafe(str: string, limit?: number | false): void | Bech32Decoded<string>; |
@@ -408,2 +408,4 @@ "use strict"; | ||
throw new Error(`bech32.encode prefix should be string, not ${typeof prefix}`); | ||
if (words instanceof Uint8Array) | ||
words = Array.from(words); | ||
if (!Array.isArray(words) || (words.length && typeof words[0] !== 'number')) | ||
@@ -447,3 +449,15 @@ throw new Error(`bech32.encode words should be array of numbers, not ${typeof words}`); | ||
} | ||
return { encode, decode, decodeToBytes, decodeUnsafe, fromWords, fromWordsUnsafe, toWords }; | ||
function encodeFromBytes(prefix, bytes) { | ||
return encode(prefix, toWords(bytes)); | ||
} | ||
return { | ||
encode, | ||
decode, | ||
encodeFromBytes, | ||
decodeToBytes, | ||
decodeUnsafe, | ||
fromWords, | ||
fromWordsUnsafe, | ||
toWords, | ||
}; | ||
} | ||
@@ -450,0 +464,0 @@ exports.bech32 = genBech32('bech32'); |
{ | ||
"name": "@scure/base", | ||
"version": "1.1.8", | ||
"version": "1.1.9", | ||
"description": "Secure, audited & 0-dep implementation of base64, bech32, base58, base32 & base16", | ||
@@ -5,0 +5,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
132979
1820