From c16a4d738f26c80cc5f854708deae72405f278a9 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Tue, 30 Apr 2024 19:53:24 +0700 Subject: [PATCH] Require Node.js 18 and move to ESM --- .github/workflows/main.yml | 10 ++++------ index.d.ts | 4 ++-- index.js | 6 +++--- index.test-d.ts | 6 ------ license | 2 +- words.json => mnemonic-words.json | 0 package.json | 23 +++++++++++++++-------- readme.md | 16 ++++------------ test.js | 2 +- words.json.d.ts | 3 --- 10 files changed, 30 insertions(+), 42 deletions(-) delete mode 100644 index.test-d.ts rename words.json => mnemonic-words.json (100%) delete mode 100644 words.json.d.ts diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 18531b3..346585c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,13 +10,11 @@ jobs: fail-fast: false matrix: node-version: - - 14 - - 12 - - 10 - - 8 + - 20 + - 18 steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - run: npm install diff --git a/index.d.ts b/index.d.ts index 6b84917..cd2ed0d 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3,7 +3,7 @@ List of words for making random mnemonic sentences. @example ``` -import mnemonicWords = require('mnemonic-words'); +import mnemonicWords from 'mnemonic-words'; console.log(mnemonicWords); //=> ['abandon', 'ability', …] @@ -11,4 +11,4 @@ console.log(mnemonicWords); */ declare const mnemonicWords: readonly string[]; -export = mnemonicWords; +export default mnemonicWords; diff --git a/index.js b/index.js index 713dcbd..6b87e6a 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,4 @@ -'use strict'; - // Original source: https://github.com/bitcoin/bips/blob/master/bip-0039/english.txt -module.exports = require('./words.json'); +import mnemonicWords from './mnemonic-words.json' with {type: 'json'}; + +export default mnemonicWords; diff --git a/index.test-d.ts b/index.test-d.ts deleted file mode 100644 index 2faa4a7..0000000 --- a/index.test-d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import {expectType} from 'tsd'; -import mnemonicWords = require('.'); -import mnemonicWordsJson = require('./words.json'); - -expectType(mnemonicWords); -expectType(mnemonicWordsJson); diff --git a/license b/license index e7af2f7..fa7ceba 100644 --- a/license +++ b/license @@ -1,6 +1,6 @@ MIT License -Copyright (c) Sindre Sorhus (sindresorhus.com) +Copyright (c) Sindre Sorhus (https://sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/words.json b/mnemonic-words.json similarity index 100% rename from words.json rename to mnemonic-words.json diff --git a/package.json b/package.json index 4b8dc60..f747f71 100644 --- a/package.json +++ b/package.json @@ -4,22 +4,29 @@ "description": "List of words for making random mnemonic sentences", "license": "MIT", "repository": "sindresorhus/mnemonic-words", + "funding": "https://github.com/sponsors/sindresorhus", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" + "url": "https://sindresorhus.com" }, + "type": "module", + "exports": { + "types": "./index.d.ts", + "default": "./index.js" + }, + "sideEffects": false, "engines": { - "node": ">=8" + "node": ">=18.20" }, "scripts": { - "test": "xo && ava && tsd" + "//test": "xo && ava && tsc --noEmit index.d.ts", + "test": "ava && tsc --noEmit index.d.ts" }, "files": [ "index.js", "index.d.ts", - "words.json", - "words.json.d.ts" + "mnemonic-words.json" ], "keywords": [ "mnemonic", @@ -33,8 +40,8 @@ "bitcoin" ], "devDependencies": { - "ava": "^1.4.1", - "tsd": "^0.7.2", - "xo": "^0.24.0" + "ava": "^6.1.2", + "typescript": "^5.4.5", + "xo": "^0.58.0" } } diff --git a/readme.md b/readme.md index 3ceaca4..7ed37b7 100644 --- a/readme.md +++ b/readme.md @@ -4,33 +4,25 @@ It could be used for [generating deterministic keys](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki). -The word list is just a [JSON file](words.json) and can be used anywhere. - +The word list is just a [JSON file](mnemonic-words.json) and can be used anywhere. ## Install -``` -$ npm install mnemonic-words +```sh +npm install mnemonic-words ``` - ## Usage ```js -const mnemonicWords = require('mnemonic-words'); +import mnemonicWords from 'mnemonic-words'; console.log(mnemonicWords); //=> ['abandon', 'ability', …] ``` - ## Related - [superb](https://github.com/sindresorhus/superb) - Get superb like words - [pokemon](https://github.com/sindresorhus/pokemon) - Get Pokémon names - [cat-names](https://github.com/sindresorhus/cat-names) - Get popular cat names - - -## License - -MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/test.js b/test.js index 857eff6..e4e9871 100644 --- a/test.js +++ b/test.js @@ -1,5 +1,5 @@ import test from 'ava'; -import mnemonicWords from '.'; +import mnemonicWords from './index.js'; test('main', t => { t.true(Array.isArray(mnemonicWords)); diff --git a/words.json.d.ts b/words.json.d.ts deleted file mode 100644 index 1e496f6..0000000 --- a/words.json.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -declare const mnemonicWordsJson: readonly string[]; - -export = mnemonicWordsJson;