1
0
mirror of https://github.com/garraflavatra/alphabets.git synced 2024-11-21 14:48:56 +01:00
alphabets/README.md

108 lines
4.0 KiB
Markdown
Raw Permalink Normal View History

2021-05-24 12:32:23 +02:00
# Alphabets
2024-08-06 14:37:07 +02:00
Alphabets contains many different alphabets for many different use cases.
2021-05-24 17:31:20 +02:00
[![npm](https://img.shields.io/npm/v/alphabets)](https://www.npmjs.com/package/alphabets)
2024-08-06 14:37:07 +02:00
- [Included alphabets](#included-alphabets)
- [How to use](#how-to-use)
- [JS module](#js-module)
- [JSON file](#json-file)
- [Motivation](#motivation)
- [Questions and bugs](#questions-and-bugs)
- [Copyright](#copyright)
2023-08-08 21:32:11 +02:00
## Included alphabets
2021-05-24 12:32:23 +02:00
2023-08-08 21:32:11 +02:00
See below for [usage instructions](#how-to-use).
2021-05-24 12:32:23 +02:00
2023-08-08 21:32:11 +02:00
| Export name | Alphabet |
|------------------|------------------|
| `danish` | [Danish](https://en.wikipedia.org/wiki/Danish_orthography), same as Norwegian |
| `faroese` | [Faroese](https://en.wikipedia.org/wiki/Faroese_orthography) |
| `greek` | [Greek](https://en.wikipedia.org/wiki/Greek_alphabet) |
| `icelandic` | [Icelandic](https://en.wikipedia.org/wiki/Icelandic_orthography) |
| `latin` | [Latin](https://en.wikipedia.org/wiki/Latin_alphabet) (abcdefg etc.) |
| `nato` | [NATO phonetic alphabet](https://en.wikipedia.org/wiki/NATO_phonetic_alphabet) |
| `norwegian` | [Norwegian](https://en.wikipedia.org/wiki/Danish_and_Norwegian_alphabet), same as Danish |
| `polish` | [Polish](https://en.wikipedia.org/wiki/Polish_alphabet) |
| `russian` | [Russian](https://en.wikipedia.org/wiki/Russian_alphabet) |
| `swedish` | [Swedish](https://en.wikipedia.org/wiki/Swedish_alphabet) |
| `ukrainian` | [Ukrainian](https://en.wikipedia.org/wiki/Ukrainian_alphabet) |
2021-05-24 12:32:23 +02:00
2024-08-06 14:37:07 +02:00
## How to use
### JS module
2021-05-24 12:32:23 +02:00
2023-08-07 18:54:13 +02:00
Install the [alphabets npm module](https://www.npmjs.com/package/alphabets) using your preferred package manager:
* npm: `npm install alphabets`
* Yarn: `yarn add alphabets`
* pnpm: `pnpm add alphabets`
2021-05-24 12:32:23 +02:00
2023-08-08 21:49:05 +02:00
You can also use it with [Deno](https://deno.land/) by importing `https://deno.land/x/alphabets/alphabets.mjs`.
2023-08-08 21:32:11 +02:00
Replace `<alphabetYouWantToUse>` with an [alphabet identifier](#included-alphabets) this package exports:
2021-05-24 12:32:23 +02:00
```js
import { <alphabetYouWantToUse> } from 'alphabets';
```
2023-08-08 21:49:05 +02:00
Deno:
```js
import { <alphabetYouWantToUse> } from 'https://deno.land/x/alphabets/alphabets.mjs';
```
2021-05-24 12:32:23 +02:00
or:
```js
const alphabets = require('alphabets');
console.log(alphabets.<alphabetYouWantToUse>);
```
2024-08-06 14:37:07 +02:00
### JSON file
Or load the JSON file with alphabets directly from a CDN:
* https://cdn.jsdelivr.net/npm/alphabets@2/alphabets.json
* https://unpkg.com/alphabets@2/alphabets.json
## Motivation
2021-05-24 12:32:23 +02:00
2023-08-08 21:32:11 +02:00
I have seen [code like this](https://github.com/search?q=%27abcdefghijklmnopqrstuvwxyz%27.split%28%27%27%29+language%3AJavaScript&type=code&l=JavaScript):
```js
const alphabet = 'abcdefghijklmnopqrstuvwxyz'.split('');
```
Or [even worse](https://github.com/search?q=%5B%22a%22%2C+%22b%22%2C+%22c%22%2C+%22d%22%2C+%22e%22%2C+%22f%22%2C+%22g%22%2C+%22h%22%2C+%22i%22%2C+%22j%22%2C+%22k%22%2C+%22l%22%2C+%22m%22%2C+%22n%22%2C+%22o%22%2C+%22p%22%2C+%22q%22%2C+%22r%22%2C+%22s%22%2C+%22t%22%2C+%22u%22%2C+%22v%22%2C+%22w%22%2C+%22x%22%2C+%22y%22%2C+%22z%22%5D+language%3AJavaScript&type=code&l=JavaScript):
```js
const alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"];
```
2024-08-06 14:37:07 +02:00
My opinion about this: it's verbose, ugly, and it pollutes your code. Instead, why not [do it like this](#how-to-use):
2021-05-24 12:32:23 +02:00
2023-08-08 21:32:11 +02:00
```js
import { latin } from 'alphabets';
2023-08-07 19:07:12 +02:00
2023-08-08 21:32:11 +02:00
for (const glyph of latin) {/* ... */}
```
This is much cleaner and more idiomatic.
2023-08-08 21:52:22 +02:00
## Questions and bugs
Did you find a mistake in an alphabet, or another bug? Please [report it](https://github.com/garraflavatra/alphabets/issues/new) — thank you! I'll try to fix it as soon as possible.
You may use the same issue form for questions, too.
2023-08-08 21:32:11 +02:00
## Copyright
2024-08-06 14:39:41 +02:00
(c) 2021-2024 [Romein van Buren](mailto:romein@vburen.nl). Licensed under the MIT license.
2023-08-07 19:07:12 +02:00
2023-08-08 21:32:11 +02:00
For the full copyright and license information, please see the [`LICENSE.md`](./LICENSE.md) file that was distributed with this source code.
2024-08-06 14:26:49 +02:00
[![Smart Yellow](https://code.smartyellow.net/smartyellow/meta/raw/branch/main/logo.png)](https://www.smartyellow.nl)