You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					22 lines
				
				469 B
			
		
		
			
		
	
	
					22 lines
				
				469 B
			| 
								 
											4 years ago
										 
									 | 
							
								let urlAlphabet =
							 | 
						||
| 
								 | 
							
								  'ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW'
							 | 
						||
| 
								 | 
							
								let customAlphabet = (alphabet, size) => {
							 | 
						||
| 
								 | 
							
								  return () => {
							 | 
						||
| 
								 | 
							
								    let id = ''
							 | 
						||
| 
								 | 
							
								    let i = size
							 | 
						||
| 
								 | 
							
								    while (i--) {
							 | 
						||
| 
								 | 
							
								      id += alphabet[(Math.random() * alphabet.length) | 0]
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								    return id
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								let nanoid = (size = 21) => {
							 | 
						||
| 
								 | 
							
								  let id = ''
							 | 
						||
| 
								 | 
							
								  let i = size
							 | 
						||
| 
								 | 
							
								  while (i--) {
							 | 
						||
| 
								 | 
							
								    id += urlAlphabet[(Math.random() * 64) | 0]
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								  return id
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								module.exports = { nanoid, customAlphabet }
							 |