| 
									
										
										
										
											2014-07-20 17:59:51 -06:00
										 |  |  | human-readable-ids-js | 
					
						
							|  |  |  | ===================== | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Use JavaScript to generate human-readable ids from a lists of nouns and adjectives. | 
					
						
							| 
									
										
										
										
											2014-07-20 23:21:23 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | Generate ids in the format of `adjective-noun-#` such as | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | * silly-goose-37 | 
					
						
							|  |  |  | * quick-cobra-15 | 
					
						
							|  |  |  | * tricky-chicken-23 | 
					
						
							|  |  |  | * brave-ladybug-90 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | My problem is that I often want ids that I can type without having to | 
					
						
							| 
									
										
										
										
											2014-07-21 09:28:57 -06:00
										 |  |  | look at twice (nor telling someone else twice). | 
					
						
							| 
									
										
										
										
											2014-07-20 23:21:23 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | I should be able to shout one of these ids across the room to a co-worker | 
					
						
							| 
									
										
										
										
											2014-07-21 09:28:57 -06:00
										 |  |  | or spouse and have them be able to enter it without any confusion. | 
					
						
							| 
									
										
										
										
											2014-07-20 23:21:23 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-21 09:28:57 -06:00
										 |  |  | Currently the id space is about 100,000 ids (100 * 100 * 100). | 
					
						
							| 
									
										
										
										
											2014-07-20 23:21:23 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-21 09:28:57 -06:00
										 |  |  | The goal is to have several billion possible combinations by adding | 
					
						
							|  |  |  | more words as well as expanding the ids to have verbs and adverbs. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Usage | 
					
						
							| 
									
										
										
										
											2014-07-20 23:21:23 -06:00
										 |  |  | ======= | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-21 09:28:57 -06:00
										 |  |  | ### npm
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```bash | 
					
						
							| 
									
										
										
										
											2014-07-20 23:21:23 -06:00
										 |  |  | npm install --save human-readable-ids | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-21 09:28:57 -06:00
										 |  |  | ```javascript | 
					
						
							|  |  |  | 'use strict'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var hri = require('human-readable-ids').hri | 
					
						
							|  |  |  |   , i | 
					
						
							|  |  |  |   ; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // generate 100 random ids | 
					
						
							|  |  |  | for (i = 0; i < 100; i += 1) { | 
					
						
							|  |  |  |   console.log(hri.random()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ### bower / browser
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-20 23:21:23 -06:00
										 |  |  | ``` | 
					
						
							|  |  |  | bower install --save human-readable-ids | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-21 09:28:57 -06:00
										 |  |  | ```jade | 
					
						
							|  |  |  | html | 
					
						
							|  |  |  |   head | 
					
						
							|  |  |  |     script(src="bower_components/knuth-shuffle/index.js") | 
					
						
							|  |  |  |     script(src="bower_components/human-readable-ids/assets/animals.js") | 
					
						
							|  |  |  |     script(src="bower_components/human-readable-ids/assets/adjectives.js") | 
					
						
							|  |  |  |     script(src="bower_components/human-readable-ids/index.js") | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```html | 
					
						
							|  |  |  |     <script src="bower_components/knuth-shuffle/index.js"></script> | 
					
						
							|  |  |  |     <script src="bower_components/human-readable-ids/assets/animals.js"></script> | 
					
						
							|  |  |  |     <script src="bower_components/human-readable-ids/assets/adjectives.js"></script> | 
					
						
							|  |  |  |     <script src="bower_components/human-readable-ids/index.js"></script> | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```javascript | 
					
						
							|  |  |  | ;(function (exports) { | 
					
						
							|  |  |  |   'use strict'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   var hri = exports.humanReadableIds || require('human-readable-ids').hri | 
					
						
							|  |  |  |     , i | 
					
						
							|  |  |  |     ; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   for (i = 0; i < 100; i += 1) { | 
					
						
							|  |  |  |     console.log(hri.random()); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | }('undefined' !== typeof exports && exports || new Function('return this')())); | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-20 23:21:23 -06:00
										 |  |  | Contributing | 
					
						
							|  |  |  | ============ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Please add more words that fit these criteria | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   * Easy-to-spell - such that even my redneck dad can manage | 
					
						
							|  |  |  |   * Phonetically distinct - no words like bore/boar | 
					
						
							|  |  |  |   * Few syllables | 
					
						
							|  |  |  |   * Well-known | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | All of the words are sorted alphabetically (`sort -u`) and stored in | 
					
						
							|  |  |  | the `*.txt` files. | 
					
						
							|  |  |  | The pre-publish script outputs the formatted javascript. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-21 09:06:16 -06:00
										 |  |  | ### Bad Examples
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   * wednesday, hamster, ostrich (difficult to spell) | 
					
						
							|  |  |  |   * grey, gray, bore, boar (two ways of spelling the same word or sound) | 
					
						
							|  |  |  |   * prawn (not well-known) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-20 23:21:23 -06:00
										 |  |  | TODO | 
					
						
							|  |  |  | ==== | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Acheive 1 trillion ids with a combination such as | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | `number adjective noun verb adverb` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-21 09:28:57 -06:00
										 |  |  | `42-red-foxes-run-quickly` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-20 23:21:23 -06:00
										 |  |  | And allow choosing various formats based on the desired | 
					
						
							|  |  |  | number of ids. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   * `adjective noun number` | 
					
						
							|  |  |  |   * `number adjective noun verb` |