{"_id":"@americanize/british-american-spellings","_rev":"3-77f0298df1a55398ba19bcbbbbaa0341","name":"@americanize/british-american-spellings","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"@americanize/british-american-spellings","version":"0.1.0","_id":"@americanize/british-american-spellings@0.1.0","maintainers":[{"name":"ianc","email":"iclanton@outlook.com"}],"dist":{"shasum":"46f34e0ff369f9aa5e6e7db27a3209edd3547ca3","tarball":"https://registry.npmjs.org/@americanize/british-american-spellings/-/british-american-spellings-0.1.0.tgz","fileCount":87,"integrity":"sha512-7ZkIG94QoFnFSpv14KQtrgWNePcPiL0IHc/dsKK505+9a2oom0wRiPtCEXyXUNzJqDTZ28WUbfPwTl01i3eHIQ==","signatures":[{"sig":"MEYCIQDrYODm0z2ZVCeOba6wXMhXe2QWnBDR5LgKqlGeFiJSXAIhAMdb28t/yx9wqGkqGXM1TSIzAzlFWTwN+CdUY/9oxDKv","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":471244},"main":"./lib/index.js","_from":"file:americanize-british-american-spellings-0.1.0.tgz","types":"./lib/index.d.ts","gitHead":"1f7e0e4191aa6aaa42c6e4d37d0ac758fc83cb92","scripts":{"test":"heft test --clean","build":"heft build --clean","_phase:test":"heft run --only test -- --clean","_phase:build":"heft run --only build -- --clean"},"_npmUser":{"name":"ianc","email":"iclanton@outlook.com"},"_resolved":"/tmp/e97e9ec27d2c7b467042f1f2afd91cb4/americanize-british-american-spellings-0.1.0.tgz","_integrity":"sha512-7ZkIG94QoFnFSpv14KQtrgWNePcPiL0IHc/dsKK505+9a2oom0wRiPtCEXyXUNzJqDTZ28WUbfPwTl01i3eHIQ==","_npmVersion":"11.16.0","description":"A reviewable table of British -> American word spellings, with case-preserving lookup helpers.","directories":{},"_nodeVersion":"24.18.0","dependencies":{"tslib":"~2.8.1"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"~9.37.0","@rushstack/heft":"1.2.23","@americanize/eslint-config":"1.0.0","@americanize/local-build-rig":"1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/british-american-spellings_0.1.0_1787905199198_0.045188699975079905","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@americanize/british-american-spellings","version":"0.1.1","author":{"name":"Ian Clanton-Thuon"},"license":"MIT","_id":"@americanize/british-american-spellings@0.1.1","maintainers":[{"name":"ianc","email":"iclanton@outlook.com"}],"homepage":"https://github.com/iclanton/americanize/tree/main/libraries/british-american-spellings#readme","bugs":{"url":"https://github.com/iclanton/americanize/issues"},"dist":{"shasum":"80c4c43b165586ccf4fc9c6fd7b2d59bca24a26c","tarball":"https://registry.npmjs.org/@americanize/british-american-spellings/-/british-american-spellings-0.1.1.tgz","fileCount":100,"integrity":"sha512-AYHHwyqxR9Mmv8A4itMBZKGUPNNSqwJ2WzlotEQrrkMF5jhrGCLoMP/xUVg14cFLoHnwTsSca4FNVTbajxEN+Q==","signatures":[{"sig":"MEQCIERuFGb4KcNvDBPLgBlYyw/tVQBMQq+fyQ02JGdNMKbbAiB5s0RQl8Vu0imEOIEGWRy9ELlArYTw2TFoBVrZ/DhCJQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":483924},"main":"./lib/index.js","_from":"file:americanize-british-american-spellings-0.1.1.tgz","types":"./lib/index.d.ts","gitHead":"f4f4d55804b9106ebf0cf94c22f2c15dbfc5946d","scripts":{"test":"heft test --clean","build":"heft build --clean","_phase:test":"heft run --only test -- --clean","_phase:build":"heft run --only build -- --clean"},"_npmUser":{"name":"ianc","email":"iclanton@outlook.com"},"_resolved":"/tmp/05f5b164873bdf2facaed74093b1c6c4/americanize-british-american-spellings-0.1.1.tgz","_integrity":"sha512-AYHHwyqxR9Mmv8A4itMBZKGUPNNSqwJ2WzlotEQrrkMF5jhrGCLoMP/xUVg14cFLoHnwTsSca4FNVTbajxEN+Q==","repository":{"url":"git+https://github.com/iclanton/americanize.git","type":"git","directory":"libraries/british-american-spellings"},"_npmVersion":"11.16.0","description":"A reviewable table of British -> American word spellings, with case-preserving lookup helpers.","directories":{},"_nodeVersion":"24.18.0","dependencies":{"tslib":"~2.8.1"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"~9.37.0","@rushstack/heft":"1.2.25","@americanize/eslint-config":"1.0.0","@americanize/local-build-rig":"1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/british-american-spellings_0.1.1_1787912954507_0.3206105327368094","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@americanize/british-american-spellings","version":"0.2.0","description":"A reviewable table of British -> American word spellings, with case-preserving lookup helpers.","repository":{"type":"git","url":"git+https://github.com/iclanton/americanize.git","directory":"libraries/british-american-spellings"},"homepage":"https://github.com/iclanton/americanize/tree/main/libraries/british-american-spellings#readme","bugs":{"url":"https://github.com/iclanton/americanize/issues"},"license":"MIT","author":{"name":"Ian Clanton-Thuon"},"main":"./lib-commonjs/index.js","module":"./lib-esm/index.js","types":"./dist/british-american-spellings.d.ts","sideEffects":false,"exports":{".":{"types":"./dist/british-american-spellings.d.ts","import":"./lib-esm/index.js","require":"./lib-commonjs/index.js"},"./lib/*":{"types":"./lib-dts/*.d.ts","import":"./lib-esm/*.js","require":"./lib-commonjs/*.js"},"./package.json":"./package.json"},"dependencies":{"tslib":"~2.8.1"},"devDependencies":{"@rushstack/heft":"1.2.25","eslint":"~9.37.0","@americanize/local-build-rig":"1.0.0","@americanize/eslint-config":"1.0.0","@americanize/spelling-data-generator-heft-plugin":"1.0.0"},"scripts":{"build":"heft build --clean","test":"heft test --clean","benchmark":"node ./lib-commonjs/scripts/throughput.js","_phase:build":"heft run --only build -- --clean","_phase:test":"heft run --only test -- --clean"},"gitHead":"7c7aac571fa6770959be4ab7548d71423c5568ef","_id":"@americanize/british-american-spellings@0.2.0","_integrity":"sha512-AdiyA2IYaHb8fnH20NwlN+GiL0tYjhff2VRVrt6uVXu/FD3OBhkjb+YEZZ9zqVswp/g10+/IzesJ/sQ/d9afbQ==","_resolved":"/tmp/5d4c7fefbe21aa0422fe473fe571effe/americanize-british-american-spellings-0.2.0.tgz","_from":"file:americanize-british-american-spellings-0.2.0.tgz","_nodeVersion":"24.18.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-AdiyA2IYaHb8fnH20NwlN+GiL0tYjhff2VRVrt6uVXu/FD3OBhkjb+YEZZ9zqVswp/g10+/IzesJ/sQ/d9afbQ==","shasum":"8b965be988160e2941ca0b9e8713f177137cef3b","tarball":"https://registry.npmjs.org/@americanize/british-american-spellings/-/british-american-spellings-0.2.0.tgz","fileCount":25,"unpackedSize":467637,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIBdzbk5FyiBV4VVNPsmb7vv38vuhRoyzwxjtzISFIbDeAiEA8D5wTiQvD+NPE7twog/IVl3R2jRRv7Xg2bqP2y/6c9M="}]},"_npmUser":{"name":"ianc","email":"iclanton@outlook.com"},"directories":{},"maintainers":[{"name":"ianc","email":"iclanton@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/british-american-spellings_0.2.0_1788072837062_0.5687372797452974"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-28T08:19:59.007Z","modified":"2026-08-30T06:53:57.414Z","0.1.0":"2026-08-28T08:19:59.338Z","0.1.1":"2026-08-28T10:29:14.661Z","0.2.0":"2026-08-30T06:53:57.241Z"},"bugs":{"url":"https://github.com/iclanton/americanize/issues"},"author":{"name":"Ian Clanton-Thuon"},"license":"MIT","homepage":"https://github.com/iclanton/americanize/tree/main/libraries/british-american-spellings#readme","repository":{"type":"git","url":"git+https://github.com/iclanton/americanize.git","directory":"libraries/british-american-spellings"},"description":"A reviewable table of British -> American word spellings, with case-preserving lookup helpers.","maintainers":[{"name":"ianc","email":"iclanton@outlook.com"}],"readme":"# @americanize/british-american-spellings\n\n[![npm version](https://badge.fury.io/js/%40americanize%2Fbritish-american-spellings.svg)](https://badge.fury.io/js/%40americanize%2Fbritish-american-spellings)\n\nA reviewable table of British → American word spellings (and its inverse), with small case-preserving lookup helpers that work in either direction.\n\nIt is the data layer behind [`eslint-plugin-dialect`](https://www.npmjs.com/package/eslint-plugin-dialect), but it has no ESLint dependency and is useful on its own.\n\n## Install\n\n```sh\nnpm install @americanize/british-american-spellings\n```\n\nThe package has **no runtime dependencies** and ships both CommonJS and ES module builds, so it works in Node (CommonJS or ESM) and in the browser.\n\n### Browser / ESM usage\n\nThe `import` condition resolves to an ES module (`lib-esm/`), so any bundler (Vite, webpack, esbuild, Rollup, Parcel) can tree-shake and bundle it for the browser:\n\n```ts\nimport { getAmericanSpelling, findBritishSpellings } from '@americanize/british-american-spellings';\n```\n\nThe spelling table is loaded via a JSON import, which every major bundler handles natively. A **bundler is required** for browser use: the raw ESM files are not meant to be loaded directly over the network via `<script type=\"module\">` (a native, un-bundled JSON import would need import attributes). In Node, `require(...)` and `import` both work out of the box.\n\n### Package layout\n\nThe build is split by output kind - `lib-commonjs/` (CommonJS), `lib-esm/` (ES modules) and `lib-dts/` (type declarations) - wired together through the `exports` map, so the right one is picked automatically for `require`, `import` and type resolution. Individual modules can be deep-imported under a stable `lib/*` path, which routes to the correct variant folder:\n\n```ts\nimport { AMERICAN_TO_BRITISH } from '@americanize/british-american-spellings/lib/britishAmericanSpellings';\n```\n\n## The tables\n\n- **`BRITISH_TO_AMERICAN`** - `ReadonlyMap<string, string>` from a lower-cased British spelling to its American form. Inflected forms (`colour`/`colours`/`coloured`, `organise`/`organised`/`organisation`, …) are listed explicitly, so a lookup is a single map read and the whole table is reviewable. The `-ise` words that stay `-ise` in American English (`advertise`, `exercise`, `surprise`, `compromise`, …) are deliberately absent.\n- **`AMERICAN_TO_BRITISH`** - the 1:1 inverse, for going the other way.\n- **`AMBIGUOUS_AMERICAN_SPELLINGS`** - `ReadonlySet<string>` of American spellings that are also accepted in British English (`program`, `disk`, `analog`, `dialog` and their plurals - a *computer program*, a *hard disk* and a UI *dialog* are spelled that way on both sides).\n\n### Where the data comes from\n\nThe table is generated from the **VarCon** dataset (Kevin Atkinson's SCOWL / English Speller Database) by the `@americanize/spelling-data-generator-heft-plugin` Heft plugin, which pins the source by content hash and keeps only the common, verified entries. See [`NOTICE.md`](./NOTICE.md) for attribution. The plugin contributes a `generate-dictionary` task to this project; run it to regenerate after the generator or the pinned dataset changes:\n\n```sh\ncd libraries/british-american-spellings && heft generate-dictionary\n```\n\nPass `--varcon-file <path>` to generate from a local copy of the dataset instead of fetching it.\n\n## Lookups\n\nEvery lookup ignores case and re-applies the input word's casing to the result.\n\n```ts\nimport {\n  getAmericanSpelling,\n  getBritishSpelling,\n  isBritishSpelling,\n  isAmericanSpelling\n} from '@americanize/british-american-spellings';\n\ngetAmericanSpelling('Colour'); // 'Color'  (casing preserved)\ngetAmericanSpelling('color'); //  undefined (already American)\ngetBritishSpelling('Color'); //   'Colour'\n\nisBritishSpelling('colour'); //  true\nisAmericanSpelling('color'); //  true\n```\n\nOr go through the direction-agnostic core with an explicit target dialect:\n\n```ts\nimport { getPreferredSpelling, isNonPreferredSpelling } from '@americanize/british-american-spellings';\n\ngetPreferredSpelling('colour', 'american'); // 'color'\ngetPreferredSpelling('color', 'british'); //  'colour'\nisNonPreferredSpelling('colour', 'american'); // true\n```\n\n## Finding spellings in text\n\n`findBritishSpellings` / `findAmericanSpellings` (and the direction-agnostic `findNonPreferredSpellings`) split a run of text into words - handling `camelCase`, `snake_case`, `kebab-case`, `SCREAMING_CASE`, acronym boundaries and plain prose - and return one `ISpellingMatch` per offending word, in order.\n\n```ts\nimport { findBritishSpellings } from '@americanize/british-american-spellings';\n\nfindBritishSpellings('favouriteColour');\n// [{ from: 'favourite', to: 'favorite', word: 'favourite', index: 0 },\n//  { from: 'colour',    to: 'Color',    word: 'Colour',    index: 9 }]\n```\n\nEach match carries the offending spelling lower-cased (`from`), the preferred spelling cased to match the input (`to`), the exact matched substring (`word`) and its `index` in the text.\n\n### Ambiguous spellings\n\nWhen enforcing British, the `AMBIGUOUS_AMERICAN_SPELLINGS` are left alone by default. Pass `{ includeAmbiguous: true }` to steer them to their British forms too:\n\n```ts\nimport { getBritishSpelling, findAmericanSpellings } from '@americanize/british-american-spellings';\n\ngetBritishSpelling('program'); //                          undefined (accepted in British too)\ngetBritishSpelling('program', { includeAmbiguous: true }); // 'programme'\n\nfindAmericanSpellings('the program on disk'); //                          []\nfindAmericanSpellings('the program on disk', { includeAmbiguous: true }); // program → programme, disk → disc\n```\n\n`includeAmbiguous` has no effect on the American direction.\n\n## API\n\n| Export | Description |\n| --- | --- |\n| `BRITISH_TO_AMERICAN`, `AMERICAN_TO_BRITISH` | The spelling tables (`ReadonlyMap<string, string>`). |\n| `AMBIGUOUS_AMERICAN_SPELLINGS` | American spellings accepted in British English (`ReadonlySet<string>`). |\n| `getPreferredSpelling(word, target, options?)` | Preferred spelling for `word`, or `undefined`. |\n| `isNonPreferredSpelling(word, target, options?)` | Whether `word` has a distinct preferred form. |\n| `findNonPreferredSpellings(text, target, options?)` | All offending words in `text`. |\n| `getAmericanSpelling` / `getBritishSpelling` | Shorthands for the two directions. |\n| `isBritishSpelling` / `isAmericanSpelling` | Shorthands for the two directions. |\n| `findBritishSpellings` / `findAmericanSpellings` | Shorthands for the two directions. |\n| `matchCase(source, replacement)` | Re-applies `source`'s casing onto `replacement`. |\n\n`target` is `'american' | 'british'` (`SpellingDialect`); `options` is `{ includeAmbiguous?: boolean }` (`ISpellingLookupOptions`).\n","readmeFilename":"README.md"}