@vandeurenglenn/base-x 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/base-x.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ declare interface baseX {
2
+ encode(source: Uint8Array | ArrayBuffer):string
3
+ decode(source: string):Uint8Array
4
+ decodeUnsafe(source: string):Uint8Array | undefined
5
+ }
6
+
7
+ declare module '@vandeurenglenn/base-x' {
8
+ export default function (ALPHABET: string):baseX
9
+ }
File without changes
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@vandeurenglenn/base-x",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "",
5
- "main": "dist/base-x.js",
5
+ "exports": {
6
+ ".": "./base-x.js"
7
+ },
6
8
  "type": "module",
9
+ "types": "./base-x.d.ts",
7
10
  "scripts": {
8
11
  "build": "rollup -c",
9
12
  "test": "echo \"Error: no test specified\" && exit 1"
package/src/base-x.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  // Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
4
4
  // Distributed under the MIT software license, see the accompanying
5
5
  // file LICENSE or http://www.opensource.org/licenses/mit-license.php.
6
- const base = (ALPHABET: string): baseX => {
6
+ const base = (ALPHABET: string):baseX => {
7
7
  if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
8
8
  const BASE_MAP = new Uint8Array(256)
9
9
  for (let j = 0; j < BASE_MAP.length; j++) {
@@ -66,7 +66,7 @@ const base = (ALPHABET: string): baseX => {
66
66
  return str
67
67
  }
68
68
 
69
- const decodeUnsafe = (source: string): Uint8Array | undefined => {
69
+ const decodeUnsafe = (source: string):Uint8Array | undefined => {
70
70
  if (typeof source !== 'string') { throw new TypeError('Expected String') }
71
71
  if (source.length === 0) { return new Uint8Array() }
72
72
  let psz = 0
@@ -109,7 +109,7 @@ const base = (ALPHABET: string): baseX => {
109
109
  return vch
110
110
  }
111
111
 
112
- const decode = (string: string): Uint8Array => {
112
+ const decode = (string: string):Uint8Array => {
113
113
  const buffer = decodeUnsafe(string)
114
114
  if (buffer) { return buffer }
115
115
  throw new Error('Non-base' + BASE + ' character')
package/src/baseX.ts DELETED
@@ -1,5 +0,0 @@
1
- interface baseX {
2
- encode: (source: Uint8Array | ArrayBuffer) => string;
3
- decode: (source: string) => Uint8Array;
4
- decodeUnsafe: (source: string) => Uint8Array | undefined;
5
- }