Skip to content

Commit cb9e531

Browse files
committed
Package got released!
1 parent 8c12424 commit cb9e531

File tree

4 files changed

+80
-0
lines changed

4 files changed

+80
-0
lines changed

Readme.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Random array element without repetition
2+
3+
![npm](https://img.shields.io/npm/v/@smakss/random-string) ![Snyk Vulnerabilities for npm package](https://img.shields.io/snyk/vulnerabilities/npm/@smakss/random-string) ![NPM](https://img.shields.io/npm/l/@smakss/random-string) ![npm](https://img.shields.io/npm/dm/@smakss/random-string) ![npm bundle size (scoped)](https://img.shields.io/bundlephobia/min/@smakss/random-string)
4+
5+
This package will generate a random dummy string based on the available set of characters and given the length of the desired string. In case you don't care about uniqueness and don't want to use UUID this one will help you to achieve what you want.
6+
7+
## How it works?
8+
9+
To install it you can simply do the following command:
10+
11+
```
12+
npm i @smakss/random-string
13+
or
14+
yarn add @smakss/random-string
15+
```
16+
17+
to include with `ES5` or common js you can simply do this:
18+
19+
```
20+
var randomString = require('@smakss/random-string');
21+
```
22+
23+
or to include with `ES6` you simply do this one:
24+
25+
```
26+
import randomString from '@smakss/random-string'
27+
```
28+
29+
then to use it within your application you can do it just like this:
30+
31+
```
32+
randomString(10) // This will generate a random string with length of then
33+
```

index.cjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict'
2+
module.exports = function randomString(length) {
3+
var string = '',
4+
allowedCharacters =
5+
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*'
6+
const allowedCharactersLength = allowedCharacters.length
7+
for (var i = 0; i < length; i++)
8+
string += allowedCharacters.charAt(
9+
Math.floor(Math.random() * allowedCharactersLength)
10+
)
11+
return string
12+
}

index.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'use strict'
2+
import randomString from './index.cjs'
3+
export default randomString

package.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "@smakss/random-string",
3+
"version": "1.0.0",
4+
"description": "Generates random dummy string.",
5+
"type": "module",
6+
"main": "index.cjs",
7+
"exports": {
8+
"import": "./index.mjs",
9+
"require": "./index.cjs"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/SMAliKSS/random-string.git"
14+
},
15+
"keywords": [
16+
"ES5",
17+
"ES6",
18+
"npm",
19+
"yarn",
20+
"dummy",
21+
"string",
22+
"SMAKSS",
23+
"random",
24+
"random-string"
25+
],
26+
"author": "SMAKSS",
27+
"license": "MIT",
28+
"bugs": {
29+
"url": "https://github.com/SMAliKSS/random-string/issues"
30+
},
31+
"homepage": "https://github.com/SMAliKSS/random-string#readme"
32+
}

0 commit comments

Comments
 (0)