@akiflow/tlds-list
v2.0.0
Published
The list of IANA top-level domains as a typed, tree-shakeable named export.
Readme
@akiflow/tlds-list
The list of IANA top-level domains as a typed, tree-shakeable named export. Ships both ESM and CommonJS builds with TypeScript declarations.
Install
npm install @akiflow/tlds-listUsage
import { tldsList } from '@akiflow/tlds-list'
tldsList.includes('com') // trueCommonJS works too:
const { tldsList } = require('@akiflow/tlds-list')tldsList is typed as readonly string[].
Notes
All entries are lowercase, so lowercase the value you look up:
const tld = 'NET'
tldsList.includes(tld) // ❌ false
tldsList.includes(tld.toLowerCase()) // ✅ trueDevelopment
npm run update-tlds # refetch the IANA list and regenerate src/index.ts
npm run build # emit dist/esm + dist/cjs with type declarations
npm test # build, then run the test suitesrc/index.ts is auto-generated by npm run update-tlds — don't edit it by hand.
Migrating from v1
v1 exposed the array as the module's module.exports:
const tlds = require('@akiflow/tlds-list') // the array itselfv2 replaces that with a single typed named export and drops the untyped default:
import { tldsList } from '@akiflow/tlds-list'Other
For any issue feel free to open an issue.
