rayid 2.1.2 → 2.1.4

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.
@@ -0,0 +1,15 @@
1
+ image: python:3.13-bookworm
2
+
3
+ pages:
4
+ stage: deploy
5
+ before_script:
6
+ - pip install uv
7
+ - uv sync --group dev
8
+ script:
9
+ - uv run mkdocs build --strict
10
+ - mv site public
11
+ artifacts:
12
+ paths:
13
+ - public
14
+ rules:
15
+ - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
@@ -0,0 +1 @@
1
+ 3.13
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,143 +1,33 @@
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.
1
+ # RayID (JavaScript)
2
+
3
+ Generate short IDs for logs, events, and traces.
4
+
5
+ ```bash
6
+ npm install rayid
7
+ ```
8
+
9
+ ```javascript
10
+ import RayID from "rayid";
11
+
12
+ const ray = new RayID("lower");
13
+
14
+ console.log(ray.gen(16));
15
+ ```
16
+
17
+ **Types:** `digit` · `lower` · `upper` · `symbol` · (default = all)
18
+
19
+ ## Docs
20
+
21
+ Full documentation: [rayid-js.amirhossein.info](https://rayid-js.amirhossein.info)
22
+
23
+ ## Links
24
+
25
+ | | |
26
+ | -------------------- | --------------------------------------------- |
27
+ | npm | https://www.npmjs.com/package/rayid |
28
+ | Source | https://gitlab.com/blackiq-packages/npm/rayid |
29
+ | **RayID for Python** | https://pypi.org/project/rayid/ |
30
+
31
+ ## License
32
+
33
+ MIT
package/docs/index.md ADDED
@@ -0,0 +1,21 @@
1
+ # RayID for JavaScript
2
+
3
+ Generate short, readable IDs for logs, events, requests, and traces.
4
+
5
+ ```javascript
6
+ import RayID from "rayid";
7
+
8
+ const ray = new RayID("lower");
9
+ console.log(ray.gen(16));
10
+ ```
11
+
12
+ | | |
13
+ | ---------------- | ------------------------------------------------------------------------------------------- |
14
+ | npm | [npmjs.com/package/rayid](https://www.npmjs.com/package/rayid) |
15
+ | Source | [GitLab](https://gitlab.com/blackiq-packages/npm/rayid) |
16
+ | **RayID Python** | [PyPI `rayid`](https://pypi.org/project/rayid/) · [docs](https://rayid-py.amirhossein.info) |
17
+
18
+ ## Next
19
+
20
+ - [Install](learn/install.md)
21
+ - [Usage](learn/usage.md)
@@ -0,0 +1,17 @@
1
+ # Install
2
+
3
+ ```bash
4
+ npm install rayid
5
+ ```
6
+
7
+ ESM:
8
+
9
+ ```javascript
10
+ import RayID from "rayid";
11
+ ```
12
+
13
+ CommonJS (if your toolchain still uses it):
14
+
15
+ ```javascript
16
+ const RayID = require("rayid");
17
+ ```
@@ -0,0 +1,54 @@
1
+ # Usage
2
+
3
+ ## Create a generator
4
+
5
+ ```javascript
6
+ import RayID from "rayid";
7
+
8
+ const ray = new RayID("lower");
9
+ ```
10
+
11
+ ### Types
12
+
13
+ | Type | Characters |
14
+ | ------------------ | ------------------------- |
15
+ | `digit` | `0-9` |
16
+ | `lower` | `a-z` |
17
+ | `upper` | `A-Z` |
18
+ | `symbol` | common symbols |
19
+ | _(omit / unknown)_ | all of the above combined |
20
+
21
+ ```javascript
22
+ const digits = new RayID("digit");
23
+ const symbols = new RayID("symbol");
24
+ const mixed = new RayID(); // all character sets
25
+ ```
26
+
27
+ ## Generate an ID
28
+
29
+ ```javascript
30
+ ray.gen(12);
31
+ ```
32
+
33
+ If the result would start with `0`, generation is retried so the first character is non-zero.
34
+
35
+ ```javascript
36
+ import RayID from "rayid";
37
+
38
+ console.log(new RayID("digit").gen(10));
39
+ console.log(new RayID("lower").gen(10));
40
+ console.log(new RayID("symbol").gen(10));
41
+ console.log(new RayID().gen(16));
42
+ ```
43
+
44
+ ## API
45
+
46
+ ### `new RayID(type?)`
47
+
48
+ | Argument | Description |
49
+ | -------- | ---------------------------------------------------- |
50
+ | `type` | `digit`, `lower`, `upper`, `symbol`, or omit for all |
51
+
52
+ ### `gen(length) → string`
53
+
54
+ Returns a string of the given length from the selected alphabet.
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,48 +1,48 @@
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;
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/mkdocs.yml ADDED
@@ -0,0 +1,38 @@
1
+ site_name: RayID Docs
2
+ site_description: Official RayID Package on NPM documentation
3
+ site_url: https://rayid-js.amirhossein.info
4
+
5
+ repo_url: https://gitlab.com/blackiq-packages/npm/rayid
6
+ repo_name: amirhossein/rayid-js
7
+
8
+ theme:
9
+ name: material
10
+ palette:
11
+ - scheme: default
12
+ primary: orange
13
+ toggle:
14
+ icon: material/brightness-7
15
+ name: Dark mode
16
+ - scheme: slate
17
+ primary: orange
18
+ toggle:
19
+ icon: material/brightness-4
20
+ name: Light mode
21
+ features:
22
+ - navigation.tabs
23
+ - navigation.sections
24
+ - content.code.copy
25
+ - search.suggest
26
+
27
+ nav:
28
+ - Home: index.md
29
+ - Learn:
30
+ - Install: learn/install.md
31
+ - Usage: learn/usage.md
32
+
33
+ markdown_extensions:
34
+ - tables
35
+ - admonition
36
+ - pymdownx.superfences
37
+ - pymdownx.highlight:
38
+ anchor_linenums: true
package/package.json CHANGED
@@ -1,31 +1,28 @@
1
- {
2
- "name": "rayid",
3
- "version": "2.1.2",
4
- "description": "RayID generator.",
5
- "main": "index.js",
6
- "type": "module",
7
- "directories": {
8
- "lib": "lib",
9
- "test": "test"
10
- },
11
- "scripts": {
12
- "test": "node index.js"
13
- },
14
- "repository": {
15
- "type": "git",
16
- "url": "git+https://gitlab.com/BlackIQ/rayid.git"
17
- },
18
- "keywords": [
19
- "RayID",
20
- "Express",
21
- "ID",
22
- "Code",
23
- "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"
31
- }
1
+ {
2
+ "name": "rayid",
3
+ "version": "2.1.4",
4
+ "description": "RayID generator.",
5
+ "main": "index.js",
6
+ "type": "module",
7
+ "author": "Amirhossein Mohammadi",
8
+ "license": "MIT",
9
+ "scripts": {
10
+ "test": "node index.js"
11
+ },
12
+ "homepage": "https://gitlab.com/blackiq-packages/npm/rayid",
13
+ "repository": {
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"
20
+ },
21
+ "keywords": [
22
+ "RayID",
23
+ "Express",
24
+ "ID",
25
+ "Code",
26
+ "Generator"
27
+ ]
28
+ }
package/pyproject.toml ADDED
@@ -0,0 +1,13 @@
1
+ [project]
2
+ name = "rayid"
3
+ version = "0.1.0"
4
+ description = "Generate RayIDs for tracking logs, posts, and events"
5
+ readme = "README.md"
6
+ requires-python = ">=3.13"
7
+ dependencies = []
8
+
9
+ [dependency-groups]
10
+ dev = [
11
+ "mkdocs>=1.6.1",
12
+ "mkdocs-material>=9.8.0",
13
+ ]
package/test/test.js CHANGED
@@ -1,11 +1,11 @@
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)); // ?,^.+</::/
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)); // ?,^.+</::/