https://github.com/dizmo/functions-random
dizmoFun: random strings
https://github.com/dizmo/functions-random
dizmo function javascript library random string typescript
Last synced: 8 months ago
JSON representation
dizmoFun: random strings
- Host: GitHub
- URL: https://github.com/dizmo/functions-random
- Owner: dizmo
- License: isc
- Created: 2018-07-18T15:32:19.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-10-18T13:43:26.000Z (about 2 years ago)
- Last Synced: 2025-02-17T07:16:26.778Z (8 months ago)
- Topics: dizmo, function, javascript, library, random, string, typescript
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/@dizmo/functions-random
- Size: 1.55 MB
- Stars: 0
- Watchers: 5
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://npmjs.org/package/@dizmo/functions-random)
[](https://travis-ci.com/dizmo/functions-random)
[](https://coveralls.io/github/dizmo/functions-random?branch=master)
# @dizmo/functions-random
Attaches to the `String` type a `random` function which returns a random string for the provided number of bytes and encoding with `ascii`, `base64`, `hex`, `latin1` and `ucs2` as possible values. By default the number of bytes is `16` and the default encoding is `hex`.
## Usage
### Install
```sh
npm install @dizmo/functions-random --save
```
### Require
```javascript
const { random } = require('@dizmo/functions-random');
```
### Examples
```javascript
random(16);
```
```javascript
2fa6651ce3680dd13899156f9550ec61
```
```javascript
random(16, 'hex');
```
```javascript
d00e24ae8348004bca2f9c07ba6ae43b
```
```javascript
random(16, 'ascii');
```
```javascript
lZq\x01\x07j\x17:OnlG9u[\x13
```
```javascript
random(16, 'base64');
```
```javascript
QbqxfgF3JBiCktUQl+p9lQ==
```
```javascript
random(16, 'latin1');
```
```javascript
ؼ\x8D\x9F*>\nØ\x83BÃÑë{\x15Ð
```
```javascript
random(16, 'ucs2');
```
```javascript
☔戠䰍⧗灺밄䯗晡
```
## Development
### Clean
```sh
npm run clean
```
### Build
```sh
npm run build
```
#### without linting and cleaning:
```sh
npm run -- build --no-lint --no-clean
```
#### with UMD bundling (incl. minimization):
```sh
npm run -- build --prepack
```
#### with UMD bundling (excl. minimization):
```sh
npm run -- build --prepack --no-minify
```
### Lint
```sh
npm run lint
```
#### with auto-fixing:
```sh
npm run -- lint --fix
```
### Test
```sh
npm run test
```
#### without linting, cleaning and (re-)building:
```sh
npm run -- test --no-lint --no-clean --no-build
```
### Cover
```sh
npm run cover
```
#### without linting, cleaning and (re-)building:
```sh
npm run -- cover --no-lint --no-clean --no-build
```
## Documentation
```sh
npm run docs
```
## Publish
```sh
npm publish
```
#### initially (if public):
```sh
npm publish --access=public
```
## Copyright
© 2020 [dizmo AG](http://dizmo.com/), Switzerland