🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

human-id

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

human-id - npm Package Compare versions

Comparing version
4.0.0
to
4.1.0
+39
cli.ts
#!/usr/bin/env node
import { humanId } from './index'
// @ts-ignore
const args = process.argv.slice(2)
const options = {
adjectiveCount: 1,
addAdverb: false,
separator: '',
capitalize: true
}
const adverb = ['a', 'adverb', 'addadverb']
const lower = ['l', 'lower', 'lowercase']
let reps = 1
for(const arg of args){
if(String(parseInt(arg)) === String(arg))
options.adjectiveCount = parseInt(arg)
else if(typeof arg === 'string'){
const lc = arg.toLowerCase()
if(adverb.includes(lc))
options.addAdverb = true
else if(lower.includes(lc))
options.capitalize = false
else if(lc.endsWith('x'))
reps = parseInt(arg)
else if(lc === 'space')
options.separator = ' '
else if(!options.separator && arg.length === 1)
options.separator = arg
}
}
for(let i = 0; i < reps; i++){
console.log(humanId(options))
}
#!/usr/bin/env node
export {};
#!/usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var index_1 = require("./index");
var args = process.argv.slice(2);
var options = {
adjectiveCount: 1,
addAdverb: false,
separator: '',
capitalize: true
};
var adverb = ['a', 'adverb', 'addadverb'];
var lower = ['l', 'lower', 'lowercase'];
var reps = 1;
for (var _i = 0, args_1 = args; _i < args_1.length; _i++) {
var arg = args_1[_i];
if (String(parseInt(arg)) === String(arg))
options.adjectiveCount = parseInt(arg);
else if (typeof arg === 'string') {
var lc = arg.toLowerCase();
if (adverb.includes(lc))
options.addAdverb = true;
else if (lower.includes(lc))
options.capitalize = false;
else if (lc.endsWith('x'))
reps = parseInt(arg);
else if (lc === 'space')
options.separator = ' ';
else if (!options.separator && arg.length === 1)
options.separator = arg;
}
}
for (var i = 0; i < reps; i++) {
console.log((0, index_1.humanId)(options));
}
//# sourceMappingURL=cli.js.map
{"version":3,"file":"c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C,SAAS,GAAG,GAAG,CAAA;KAC1B;CACF;AAED,KAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAC;IAC3B,OAAO,CAAC,GAAG,CAAC,IAAA,eAAO,EAAC,OAAO,CAAC,CAAC,CAAA;CAC9B"}
+3
-2
{
"name": "human-id",
"version": "4.0.0",
"version": "4.1.0",
"description": "Returns from a pool of 10m human-readable IDs",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"bin": "dist/cli.js",
"scripts": {
"start": "tsc -w",
"dev": "tsc -w",
"build": "rm -rf ./dist && tsc",

@@ -10,0 +11,0 @@ "examples": "tsc && node ./dist/examples.js"

+47
-11

@@ -11,3 +11,3 @@ <h3 align="center">💃🆔</h3>

Human-ID generates readable strings by chaining common short words of the english language in a semi-meaningful way.
The result is concatenated of `adjective + noun + verb` resulting in an [minimum](#extended-pool-size) pool size of **15 000 000** possible combinations.
The result is concatenated of `adjective + noun + verb` resulting in a [minimum](#extended-pool-size) pool size of **15 000 000** possible combinations.

@@ -42,4 +42,17 @@ - **SFW**: no bad words; family friendly results

### Command line
```sh
npx human-id
# RareGeckosJam
npx human-id lowercase + 2x
# rare+geckos+jam
# healthy+cows+smile
```
### Programmatic
```js
import humanId from 'human-id'
import {humanId, poolSize, minLength, maxLength} from 'human-id'

@@ -76,3 +89,3 @@ // RareGeckosJam

humanId(options) // Ten.Wet.Files.Cheer.Lazily
poolSize(options) // 630.000.000
poolSize(options) // 630,000,000
minLength(options) // 20

@@ -82,5 +95,27 @@ maxLength(options) // 41

## Executable arguments
Use the following arguments to modify the default options or print multiple results.
| Argument | Effect |
| -------------------------- | ------------------------------------------------- |
| `a`, `adverb`, `addAdverb` | Sets `option.addAdverb` to `true` |
| `l`, `lower`, `lowercase` | Sets `option.capitalize` to `false` |
| `space` | Sets `option.separator` to an empty space ` ` |
| `number` | Sets `option.adjectiveCount` to the given integer |
| any single character | Sets `option.separator` to the character |
| `number` + `x` | Repeats the output `number` times |
### Example
```bash
npx human-id adverb lower 2 _ 3x
# clever_shaggy_memes_sit_quietly
# cuddly_spicy_boxes_wave_politely
# sweet_fair_wombats_fetch_bravely
```
## API
### `humanId(options?: string | Option): string`
#### `humanId(options?: string | Option): string`
Generates a human ID. **Options** can be a `string` (separator), a `boolean` (capitalize) or an `Options` object of:

@@ -94,24 +129,25 @@ - **separator** `string = ''` - Separates the words from each other

### `poolSize(options?: string | Option): number`
#### `poolSize(options?: string | Option): number`
Returns the number of possible combinations for a given set of options.
### `minLength(options?: Option): number`
#### `minLength(options?: Option): number`
The length of the shortest possible id for a given set of options.
### `maxLength(options?: Option): number`
#### `maxLength(options?: Option): number`
The length of the longest possible id for a given set of options.
### `adjectives: string[]`
#### `adjectives: string[]`
List of possible values for the first part of the human id.
### `nouns: string[]`
#### `nouns: string[]`
List of possible values for the second part of the human id.
### `verbs: string[]`
#### `verbs: string[]`
List of possible values for the third part of the human id.
### `adverbs: string[]`
#### `adverbs: string[]`
List of possible values for the optional fourth part of the human id.
<h6 align="center">💃🆔</h6>