https://github.com/articulate/tinygen
Tiniest of tiny base64 uid generators
https://github.com/articulate/tinygen
Last synced: 3 months ago
JSON representation
Tiniest of tiny base64 uid generators
- Host: GitHub
- URL: https://github.com/articulate/tinygen
- Owner: articulate
- License: mit
- Created: 2016-11-17T16:16:51.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-12-21T20:55:14.000Z (over 9 years ago)
- Last Synced: 2024-04-24T17:58:29.201Z (about 2 years ago)
- Language: JavaScript
- Homepage:
- Size: 17.6 KB
- Stars: 1
- Watchers: 64
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tinygen [](https://www.npmjs.com/package/tinygen) [](https://www.npmjs.com/package/tinygen)
Tiniest of tiny `base64` uid generators. Teeny-tiny browser version included, only 757 bytes.
## API
```haskell
tinygen :: Number -> String
```
#### Parameters
- Number `len`
Desired length of `id`. Defaults to `16`.
#### Returns
- String `id`
A `base64` random uid.
```js
const tinygen = require('tinygen')
tinygen() // => "K4UP_gkFtzHMt5TN"
tinygen(32) // => "4Z65y6VjtIaid-PpG6eSnzJ5P7lZwoNI"
```
## CLI
```sh
$ npm i -g tinygen
$ tinygen
Wsk6V84y9C0xI1Us
$ tinygen 32
05jrftGx1WROHu6_VQMVwLTtAxJ3AF1_
```
## Maintenance
To publish a new version:
```
yarn version
npm publish --access public
```
You will be prompted for a new version number, the package will be rebuilt, and the tag pushed to `git` before publishing to `npm`. The second step is required until [#1694](https://github.com/yarnpkg/yarn/issues/1694) is resolved.