diff --git a/dist/cjs/test/index.cjs b/dist/cjs/test/index.cjs index 9c2dcd5..087f6fc 100644 --- a/dist/cjs/test/index.cjs +++ b/dist/cjs/test/index.cjs @@ -1,19 +1,19 @@ -'use strict'; +"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); // @ts-ignore const bech32Lib = require("../index.cjs"); const tape = require("tape"); -const fixtures = require('../../../src/test/fixtures'); +const fixtures = require("../../../src/test/fixtures"); function testValidFixture(f, bech32) { if (f.hex) { tape(`fromWords/toWords ${f.hex}`, (t) => { t.plan(3); - const words = bech32.toWords(Buffer.from(f.hex, 'hex')); + const words = bech32.toWords(Buffer.from(f.hex, "hex")); const bytes = Buffer.from(bech32.fromWords(f.words)); const bytes2 = Buffer.from(bech32.fromWordsUnsafe(f.words)); t.same(words, f.words); - t.same(bytes.toString('hex'), f.hex); - t.same(bytes2.toString('hex'), f.hex); + t.same(bytes.toString("hex"), f.hex); + t.same(bytes2.toString("hex"), f.hex); }); } tape(`encode ${f.prefix} ${f.hex || f.words}`, (t) => { @@ -31,13 +31,13 @@ function testValidFixture(f, bech32) { }); tape(`fails for ${f.string} with 1 bit flipped`, (t) => { t.plan(2); - const buffer = Buffer.from(f.string, 'utf8'); - buffer[f.string.lastIndexOf('1') + 1] ^= 0x1; // flip a bit, after the prefix - const str = buffer.toString('utf8'); + const buffer = Buffer.from(f.string, "utf8"); + buffer[f.string.lastIndexOf("1") + 1] ^= 0x1; // flip a bit, after the prefix + const str = buffer.toString("utf8"); t.equal(bech32.decodeUnsafe(str, f.limit), undefined); t.throws(() => { bech32.decode(str, f.limit); - }, new RegExp('Invalid checksum|Unknown character')); + }, new RegExp("Invalid checksum|Unknown character")); }); // === compare of objects compares reference in memory, so this works const wrongBech32 = bech32 === bech32Lib.bech32 ? bech32Lib.bech32m : bech32Lib.bech32; @@ -46,7 +46,7 @@ function testValidFixture(f, bech32) { t.equal(wrongBech32.decodeUnsafe(f.string, f.limit), undefined); t.throws(() => { wrongBech32.decode(f.string, f.limit); - }, new RegExp('Invalid checksum')); + }, new RegExp("Invalid checksum")); }); } function testInvalidFixture(f, bech32) { @@ -59,7 +59,7 @@ function testInvalidFixture(f, bech32) { }); } if (f.string !== undefined || f.stringHex) { - const str = f.string || Buffer.from(f.stringHex, 'hex').toString('binary'); + const str = f.string || Buffer.from(f.stringHex, "hex").toString("binary"); tape(`decode fails for ${str} (${f.exception})`, (t) => { t.plan(2); t.equal(bech32.decodeUnsafe(str), undefined); @@ -90,7 +90,7 @@ fixtures.fromWords.invalid.forEach((f) => { }, new RegExp(f.exception)); }); }); -tape('toWords/toWordsUnsafe accept bytes as ArrayLike', (t) => { +tape("toWords/toWordsUnsafe accept bytes as ArrayLike", (t) => { // Ensures that only the two operations from // interface ArrayLike { // readonly length: number; diff --git a/package.json b/package.json index 748f921..4b3e18b 100644 --- a/package.json +++ b/package.json @@ -1,64 +1,64 @@ { - "name": "bech32", - "version": "2.0.0", - "description": "Bech32 encoding / decoding", - "type": "module", - "keywords": [ - "base32", - "bech32", - "bech32m", - "bitcoin", - "crypto", - "crytography", - "decode", - "decoding", - "encode", - "encoding" - ], - "main": "dist/cjs/index.js", - "module": "dist/esm/index.js", - "types": "dist/index.d.ts", - "files": [ - "dist/cjs/index.js", - "dist/cjs/index.d.ts", - "dist/esm/index.js" - ], - "exports": { - ".": { - "require": "./dist/cjs/index.js", - "import": "./dist/esm/index.js", - "types": "./dist/cjs/index.d.ts" - } - }, - "license": "MIT", - "devDependencies": { - "@types/node": "^14.0.14", - "@types/tape": "^4.13.4", - "nyc": "^15.0.0", - "prettier": "^2.0.5", - "rimraf": "^3.0.2", - "tap-dot": "*", - "tape": "^5.3.0", - "ts-node": "^10.9.2", - "tslint": "^6.1.3", - "tsx": "^4.7.2", - "typescript": "^3.9.5" - }, - "repository": { - "url": "http://github.com/bitcoinjs/bech32", - "type": "git" - }, - "scripts": { - "build": "npm run clean && tsc -p tsconfig.json && tsc -p tsconfig.cjs.json", - "postbuild": "find dist/cjs -type f -name \"*.js\" -exec bash -c 'mv \"$0\" \"${0%.js}.cjs\"' {} \\;", - "clean": "rimraf dist", - "coverage": "nyc -x [src/test/*.ts] --check-coverage --branches 90 --functions 90 npm test", - "format": "npm run prettier -- --write", - "format:ci": "npm run prettier -- --check", - "gitdiff:ci": "npm run build && git diff --exit-code", - "lint:fix": "npm run lint -- --fix", - "lint": "tslint -p tsconfig.cjs.json -c tslint.json", - "prettier": "prettier --print-width 100 --single-quote --trailing-comma=all \"**/!(*.d).ts\"", - "test": "tape dist/cjs/test/*.cjs | tap-dot" + "name": "bech32", + "version": "2.0.0", + "description": "Bech32 encoding / decoding", + "type": "module", + "keywords": [ + "base32", + "bech32", + "bech32m", + "bitcoin", + "crypto", + "crytography", + "decode", + "decoding", + "encode", + "encoding" + ], + "main": "dist/cjs/index.cjs", + "module": "dist/esm/index.js", + "types": "dist/index.d.ts", + "files": [ + "dist/cjs/index.cjs", + "dist/cjs/index.d.ts", + "dist/esm/index.js" + ], + "exports": { + ".": { + "require": "./dist/cjs/index.cjs", + "import": "./dist/esm/index.js", + "types": "./dist/cjs/index.d.ts" } + }, + "license": "MIT", + "devDependencies": { + "@types/node": "^14.0.14", + "@types/tape": "^4.13.4", + "nyc": "^15.0.0", + "prettier": "^2.0.5", + "rimraf": "^3.0.2", + "tap-dot": "*", + "tape": "^5.3.0", + "ts-node": "^10.9.2", + "tslint": "^6.1.3", + "tsx": "^4.7.2", + "typescript": "^3.9.5" + }, + "repository": { + "url": "http://github.com/bitcoinjs/bech32", + "type": "git" + }, + "scripts": { + "build": "npm run clean && tsc -p tsconfig.json && tsc -p tsconfig.cjs.json", + "postbuild": "find dist/cjs -type f -name \"*.js\" -exec bash -c 'mv \"$0\" \"${0%.js}.cjs\"' {} \\;", + "clean": "rimraf dist", + "coverage": "nyc -x [dist/cjs/test/*.ts] --check-coverage --branches 90 --functions 90 npm test", + "format": "npm run prettier -- --write", + "format:ci": "npm run prettier -- --check", + "gitdiff:ci": "npm run build && git diff --exit-code", + "lint:fix": "npm run lint -- --fix", + "lint": "tslint -p tsconfig.cjs.json -c tslint.json", + "prettier": "prettier --print-width 100 --single-quote --trailing-comma=all \"**/!(*.d).ts\"", + "test": "tape dist/cjs/test/*.cjs | tap-dot" + } } diff --git a/tsconfig.base.json b/tsconfig.base.json index 0d939e5..045411c 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1,11 +1,12 @@ { - "compilerOptions": { - "strict": true, - "resolveJsonModule": true, - "target": "es2015", - "moduleResolution": "node", - "noImplicitAny": true, - "preserveConstEnums": true - }, - "include": ["src"] + "compilerOptions": { + "strict": true, + "resolveJsonModule": true, + "target": "es2015", + "moduleResolution": "node", + "noImplicitAny": true, + "preserveConstEnums": true + }, + "include": ["src"], + "exclude": ["node_modules"] } diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json index 1f967c3..c2e3ddd 100644 --- a/tsconfig.cjs.json +++ b/tsconfig.cjs.json @@ -1,10 +1,9 @@ { - "extends": "./tsconfig.base.json", - "compilerOptions": { - "declaration": true, - "emitDeclarationOnly": false, - "outDir": "dist/cjs", - "module": "commonjs" - }, - "exclude": ["node_modules"] + "extends": "./tsconfig.base.json", + "compilerOptions": { + "declaration": true, + "emitDeclarationOnly": false, + "outDir": "dist/cjs", + "module": "commonjs" + } } diff --git a/tsconfig.json b/tsconfig.json index d697636..46edf16 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,5 +6,5 @@ "resolveJsonModule": true, "module": "ESNext" }, - "exclude": ["node_modules", "src/test/**/*"] + "exclude": ["src/test/**/*"] } diff --git a/tslint.json b/tslint.json index c5fa3c2..b542cf1 100644 --- a/tslint.json +++ b/tslint.json @@ -4,11 +4,7 @@ "rules": { "arrow-parens": [true, "ban-single-arg-parens"], "curly": false, - "indent": [ - true, - "spaces", - 2 - ], + "indent": [true, "spaces", 2], "interface-name": [false], "match-default-export-name": true, "max-classes-per-file": [false],