Skip to content

Commit

Permalink
Release 4.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberAP committed Apr 7, 2021
1 parent ab89e6e commit a4d6041
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 40 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change log

## 4.3.0

- Updated Readme to include updated instructions, added sets preview
- Updated examples to use ES imports, removed examples for direct file imports ( `nanoid-dictionary/lowercase.js`, etc.)
- Added typings
- Simplified index.js

## 4.2.0

- Added `alphanumeric` set ([#7](https://github.com/CyberAP/nanoid-dictionary/pull/7)) by [@anshulsahni](https://github.com/anshulsahni)
Expand Down
45 changes: 18 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,13 @@ Install nanoid and dictionary

`npm i nanoid nanoid-dictionary`

Require a generator and pass a string from the dictionary
Require a `customAlphabet` from `nanoid` and pass a string from the dictionary:

```javascript
const generate = require('nanoid/generate');
const dictionary = require('nanoid-dictionary');
import { customAlphabet } from 'nanoid';
import { lowercase } from 'nanoid-dictionary';

const lowercaseRandomString = generate(dictionary.lowercase, 10);
```

Or instead you can require a specific dictionary

```javascript
const generate = require('nanoid/generate');
const englishLowercase = require('nanoid-dictionary/lowercase');

const lowercaseRandomString = generate(englishLowercase, 10);
const lowercaseRandomString = customAlphabet(lowercase, 10);
```


Expand All @@ -35,53 +26,53 @@ const lowercaseRandomString = generate(englishLowercase, 10);
Numbers from 0 to 9

```javascript
const numbers = require('nanoid-dictionary/numbers');
import { numbers } from 'nanoid-dictionary';
```

### `lowercase`

Lowercase English letters.

Available both as `alphabets.lowercase` and simply `lowercase`.
Lowercase English letters: `abcdefghijklmnopqrstuvwxyz`

```javascript
const englishLowercase = require('nanoid-dictionary/lowercase');
import { lowercase } from 'nanoid-dictionary';
```

### `uppercase`

Uppercase English letters.

Available both as `alphabets.uppercase` and simply `uppercase`.
Uppercase English letters: `ABCDEFGHIJKLMNOPQRSTUVWXYZ`

```javascript
const englishUppercase = require('nanoid-dictionary/uppercase');
import { uppercase } from 'nanoid-dictionary';
```

### `alphanumeric`

Combination of all the smallcase, uppercase charaters and numbers from 0 to 9
Combination of all the lowercase, uppercase characters and numbers from 0 to 9

Does not include any symbols or special characters

```javascript
const alphanumeric = require('nanoid-dictionary/alphanumeric');
import { alphanumeric } from 'nanoid-dictionary';
```

### `nolookalikes`

Numbers and english alphabet without lookalikes: `1`, `l`, `I`, `0`, `O`, `o`, `u`, `v`, `5`, `S`, `s`, `2`, `Z`.

Complete set: `346789ABCDEFGHJKLMNPQRTUVWXYabcdefghijkmnpqrtwxyz`

```javascript
const nolookalikes = require('nanoid-dictionary/nolookalikes');
import { nolookalikes } from 'nanoid-dictionary';
```

### `nolookalikes-safe`
### `nolookalikesSafe`

Same as `noolookalikes` but with removed vowels and following letters: `3`, `4`, `x`, `X`, `V`.

This list should protect you from accidentally getting obscene words in generated strings.

Complete set: `6789BCDFGHJKLMNPQRTWbcdfghjkmnpqrtwz`

```javascript
const nolookalikesSafe = require('nanoid-dictionary/nolookalikes-safe');
import { nolookalikesSafe } from 'nanoid-dictionary';
```
19 changes: 6 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
var lowercase = require('./lowercase');
var uppercase = require('./uppercase');
var numbers = require('./numbers');
var nolookalikes = require('./nolookalikes');
var nolookalikesSafe = require('./nolookalikes-safe');
var alphanumeric = require('./alphanumeric');

module.exports = {
lowercase: lowercase,
uppercase: uppercase,
numbers: numbers,
nolookalikes: nolookalikes,
nolookalikesSafe: nolookalikesSafe,
alphanumeric: alphanumeric,
lowercase: require('./lowercase'),
uppercase: require('./uppercase'),
numbers: require('./numbers'),
nolookalikes: require('./nolookalikes'),
nolookalikesSafe: require('./nolookalikes-safe'),
alphanumeric: require('./alphanumeric'),
}
6 changes: 6 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const lowercase: string;
export const uppercase: string;
export const numbers: string;
export const nolookalikes: string;
export const nolookalikesSafe: string;
export const alphanumeric: string;

0 comments on commit a4d6041

Please sign in to comment.