rayid 1.0.0 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 AmirHossein Mohammadi
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2022 AmirHossein Mohammadi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,122 +1,143 @@
1
- # RayID
2
-
3
- **RayID** is a generated code that we use to track logs, posts or events. You can generate your own rayid, but we made your job easier!
4
-
5
- In this instructure you will learn about how to use this package in your apps.
6
-
7
- ## Table of content
8
-
9
- - [Installation](#installation)
10
- - [methods](#methods)
11
- - [Development](#development)
12
-
13
- ## Installation
14
-
15
- How to install **RayID**? To install this package, use **NPM**.
16
-
17
- ```shell
18
- $ npm i rayid
19
- ```
20
-
21
- ## Config
22
-
23
- So, import the package.
24
-
25
- ```javascript
26
- // ESM 6 and higher
27
- import RayID from "rayid";
28
-
29
- // ESM 5 and lower
30
- const RayID = require("rayid");
31
- ```
32
-
33
- Now create your instance with what kind of rayid you want.
34
-
35
- - digit: Numbers
36
- - lower: Alphabet in lower case.
37
- - upper: Alphabet in upper case.
38
-
39
- > No type means all combined togather.
40
-
41
- ```javascript
42
- const ray = new RayID("lower");
43
- ```
44
-
45
- ## Methods
46
-
47
- Only one method! `gen()`.
48
-
49
- ### `gen()`
50
-
51
- in **gen()** just say the length.
52
-
53
- > There is no limit :)
54
-
55
- ```javascript
56
- const r = ray.gen(50);
57
- console.log(r); // zpciqivbkgoubrurrnozqhcdzlerjkllgtwbqbhllrxcremprd
58
- ```
59
-
60
- Or do it inside.
61
-
62
- ```javascript
63
- console.log(ray.gen(50)); // clherhvpkhwynhqhzluozionumnjqgjroeiymgqvlaknzjtdic
64
- ```
65
-
66
- All done!
67
-
68
- ---
69
-
70
- ## Development
71
-
72
- If you want to develop the package, it is so simple. just follow steps below.
73
-
74
- - Clone the project
75
- - Install dependencies by running `$ npm install`
76
- - Start changing!
77
- - Link package
78
- - Test
79
-
80
- > Before you start: **Remember the base or code are stored in `lib/rayid.js`**. You need to edit there.
81
-
82
- ### Cloning the project
83
-
84
- To clone the project, you need to have git installed. Ok, now clone it same as command below.
85
-
86
- ```shell
87
- $ git clone https://gitlab.com/BlackIQ/rayid
88
- ```
89
-
90
- ### installing dependencies
91
-
92
- Next, install what package uses with `npm i` or `npm install`.
93
-
94
- ```shell
95
- $ npm i
96
- ```
97
-
98
- ### Changing
99
-
100
- To change package or anything, your need a testing environment to use linked package. Just follow steps.
101
-
102
- #### Link package
103
-
104
- We asoume you are in `lib` directory. Right. You can open a **tmux** or in another terminal to cd in `test` directory.
105
-
106
- In `lib` directory enter link command:
107
-
108
- ```shell
109
- $ npm link
110
- ```
111
-
112
- So, in other terminal, or other tmux part, link your development package to your `test` directory. If you are in the `test` directory ok, if not, just say `cd test` and enter the linking command:
113
-
114
- ```shell
115
- $ npm link rayid
116
- ```
117
-
118
- Linking step is done.
119
-
120
- #### Test
121
-
122
- Your test app is linked. Change anything in package and test it in `test` directory.
1
+ # RayID
2
+
3
+ **RayID** is a generated code that we use to track logs, posts or events. You can generate your own rayid, but we made your job easier!
4
+
5
+ In this instructure you will learn about how to use this package in your apps.
6
+
7
+ ## Table of content
8
+
9
+ - [Installation](#installation)
10
+ - [methods](#methods)
11
+ - [Development](#development)
12
+
13
+ ## Installation
14
+
15
+ How to install **RayID**? To install this package, use **NPM**.
16
+
17
+ ```shell
18
+ $ npm i rayid
19
+ ```
20
+
21
+ ## Config
22
+
23
+ So, import the package.
24
+
25
+ ```javascript
26
+ // ESM 6 and higher
27
+ import RayID from "rayid";
28
+
29
+ // ESM 5 and lower
30
+ const RayID = require("rayid");
31
+ ```
32
+
33
+ Now create your instance with what kind of rayid you want.
34
+
35
+ - digit: Numbers
36
+ - lower: Alphabet in lower case.
37
+ - upper: Alphabet in upper case.
38
+ - symbol: Symbols for password and stuff.
39
+
40
+ > No type means all combined togather.
41
+
42
+ ```javascript
43
+ const ray = new RayID("lower");
44
+ ```
45
+
46
+ ## Methods
47
+
48
+ Only one method! `gen()`.
49
+
50
+ ### `gen()`
51
+
52
+ in **gen()** just say the length.
53
+
54
+ > There is no limit :)
55
+
56
+ ```javascript
57
+ const r = ray.gen(50);
58
+ console.log(r); // zpciqivbkgoubrurrnozqhcdzlerjkllgtwbqbhllrxcremprd
59
+ ```
60
+
61
+ Or do it inside.
62
+
63
+ ```javascript
64
+ console.log(ray.gen(50)); // clherhvpkhwynhqhzluozionumnjqgjroeiymgqvlaknzjtdic
65
+ ```
66
+
67
+ ## Examples
68
+
69
+ Create common instances.
70
+
71
+ ```javascript
72
+ const ray = new RayID(); // All values
73
+ const srt = new RayID("lower"); // Loercase generator
74
+ const int = new RayID("digit"); // Only int generator
75
+ const sym = new RayID("symbol"); // Symbol generator
76
+ ```
77
+
78
+ Now use them:
79
+
80
+ ```javascript
81
+ console.log(ray.gen(10)); // Z*jVQ3c:+H
82
+ console.log(srt.gen(10)); // ksixvpqohi
83
+ console.log(int.gen(10)); // 4748182066
84
+ console.log(sym.gen(10)); // ?,^.+</::/
85
+ ```
86
+
87
+ All done!
88
+
89
+ ---
90
+
91
+ ## Development
92
+
93
+ If you want to develop the package, it is so simple. just follow steps below.
94
+
95
+ - Clone the project
96
+ - Install dependencies by running `$ npm install`
97
+ - Start changing!
98
+ - Link package
99
+ - Test
100
+
101
+ > Before you start: **Remember the base or code are stored in `lib/rayid.js`**. You need to edit there.
102
+
103
+ ### Cloning the project
104
+
105
+ To clone the project, you need to have git installed. Ok, now clone it same as command below.
106
+
107
+ ```shell
108
+ $ git clone https://gitlab.com/BlackIQ/rayid
109
+ ```
110
+
111
+ ### installing dependencies
112
+
113
+ Next, install what package uses with `npm i` or `npm install`.
114
+
115
+ ```shell
116
+ $ npm i
117
+ ```
118
+
119
+ ### Changing
120
+
121
+ To change package or anything, your need a testing environment to use linked package. Just follow steps.
122
+
123
+ #### Link package
124
+
125
+ We asoume you are in `lib` directory. Right. You can open a **tmux** or in another terminal to cd in `test` directory.
126
+
127
+ In `lib` directory enter link command:
128
+
129
+ ```shell
130
+ $ npm link
131
+ ```
132
+
133
+ So, in other terminal, or other tmux part, link your development package to your `test` directory. If you are in the `test` directory ok, if not, just say `cd test` and enter the linking command:
134
+
135
+ ```shell
136
+ $ npm link rayid
137
+ ```
138
+
139
+ Linking step is done.
140
+
141
+ #### Test
142
+
143
+ Your test app is linked. Change anything in package and test it in `test` directory.
package/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import RayID from "./lib/rayid.js";
2
-
3
- export default RayID;
1
+ import RayID from "./lib/rayid.js";
2
+
3
+ export default RayID;
package/lib/rayid.js CHANGED
@@ -1,37 +1,48 @@
1
- const values = {
2
- digit: "0123456789",
3
- lower: "abcdefghijklmnopqrstuvwxyz",
4
- upper: "abcdefghijklmnopqrstuvwxyz".toUpperCase(),
5
- };
6
-
7
- class RayID {
8
- constructor(type) {
9
- this.type = type;
10
- }
11
-
12
- characters = () => {
13
- if (values[this.type] !== undefined) return values[this.type];
14
- else {
15
- let chars = "";
16
-
17
- Object.values(values).map((value) => (chars += value));
18
-
19
- return chars;
20
- }
21
- };
22
-
23
- gen = (length) => {
24
- let result = "";
25
-
26
- const characters = this.characters();
27
- const charactersLength = characters.length;
28
-
29
- for (let i = 0; i < length; i++) {
30
- result += characters.charAt(Math.floor(Math.random() * charactersLength));
31
- }
32
-
33
- return result;
34
- };
35
- }
36
-
37
- export default RayID;
1
+ const values = {
2
+ digit: "0123456789",
3
+ lower: "abcdefghijklmnopqrstuvwxyz",
4
+ upper: "abcdefghijklmnopqrstuvwxyz".toUpperCase(),
5
+ symbol: "!@#$%^&*()_+|}]{[:;?/>.<,`",
6
+ };
7
+
8
+ class RayID {
9
+ constructor(type) {
10
+ this.type = type;
11
+ }
12
+
13
+ engine = (length) => {
14
+ let result = "";
15
+
16
+ const characters = this.characters();
17
+ const charactersLength = characters.length;
18
+
19
+ for (let i = 0; i < length; i++) {
20
+ result += characters.charAt(Math.floor(Math.random() * charactersLength));
21
+ }
22
+
23
+ return result;
24
+ };
25
+
26
+ characters = () => {
27
+ if (values[this.type] !== undefined) return values[this.type];
28
+ else {
29
+ let chars = "";
30
+
31
+ Object.values(values).map((value) => (chars += value));
32
+
33
+ return chars;
34
+ }
35
+ };
36
+
37
+ gen = (length) => {
38
+ const generated = this.engine(length);
39
+
40
+ if (generated[0] === "0") {
41
+ return this.gen(length);
42
+ } else {
43
+ return generated;
44
+ }
45
+ };
46
+ }
47
+
48
+ export default RayID;
package/package.json CHANGED
@@ -1,19 +1,22 @@
1
1
  {
2
2
  "name": "rayid",
3
- "version": "1.0.0",
3
+ "version": "2.1.3",
4
4
  "description": "RayID generator.",
5
5
  "main": "index.js",
6
6
  "type": "module",
7
- "directories": {
8
- "lib": "lib",
9
- "test": "test"
10
- },
7
+ "author": "Amirhossein Mohammadi",
8
+ "license": "MIT",
11
9
  "scripts": {
12
10
  "test": "node index.js"
13
11
  },
12
+ "homepage": "https://gitlab.com/blackiq-packages/npm/rayid",
14
13
  "repository": {
15
- "type": "git",
16
- "url": "git+https://gitlab.com/BlackIQ/rayid.git"
14
+ "url": "git+https://gitlab.com/blackiq-packages/npm/rayid.git",
15
+ "type": "git"
16
+ },
17
+ "bugs": {
18
+ "url": "https://gitlab.com/blackiq-packages/npm/rayid/-/issues",
19
+ "email": "bugs@amirhossein.info"
17
20
  },
18
21
  "keywords": [
19
22
  "RayID",
@@ -21,11 +24,5 @@
21
24
  "ID",
22
25
  "Code",
23
26
  "Generator"
24
- ],
25
- "author": "Amirhossein Mohammadi",
26
- "license": "MIT",
27
- "bugs": {
28
- "url": "https://gitlab.com/BlackIQ/rayid/issues"
29
- },
30
- "homepage": "https://gitlab.com/BlackIQ/rayid#readme"
27
+ ]
31
28
  }
package/test/test.js CHANGED
@@ -1,5 +1,11 @@
1
- import RayID from "rayid";
2
-
3
- const ray = new RayID("lower");
4
-
5
- console.log(ray.gen(50));
1
+ import RayID from "rayid";
2
+
3
+ const ray = new RayID(); // All values
4
+ const srt = new RayID("lower"); // Loercase generator
5
+ const int = new RayID("digit"); // Only int generator
6
+ const sym = new RayID("symbol"); // Symbol generator
7
+
8
+ console.log("Random of everything: " + ray.gen(10)); // Z*jVQ3c:+H
9
+ console.log("String in lowercase: " + srt.gen(10)); // ksixvpqohi
10
+ console.log("Number, 0 is not first: " + int.gen(10)); // 4748182066
11
+ console.log("Some symbols stuff: " + sym.gen(10)); // ?,^.+</::/