hindicode 1.0.3 → 1.2.0
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 +21 -0
- package/README.md +97 -241
- package/index.d.ts +5 -0
- package/index.js +232 -149
- package/package.json +34 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ujjwal Dadhich
|
|
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,241 +1,97 @@
|
|
|
1
|
-
# HindiCode - हिंदी में जावास्क्रिप्ट लिखें! 🚀
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
| स्थिर | const |
|
|
99
|
-
| परिभाषा | var |
|
|
100
|
-
| सही | true |
|
|
101
|
-
| गलत | false |
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
---
|
|
106
|
-
|
|
107
|
-
## 💖 सहयोग करें!
|
|
108
|
-
अगर आपको **HindiCode** पसंद आया हो, तो हमारे प्रोजेक्ट को **सपोर्ट** करें!
|
|
109
|
-
👉 [डोनेट करें - Patreon](https://www.patreon.com/c/BABU_ISHU)
|
|
110
|
-
|
|
111
|
-
---
|
|
112
|
-
|
|
113
|
-
## 📜 लाइसेंस
|
|
114
|
-
यह प्रोजेक्ट **MIT लाइसेंस** के अंतर्गत जारी किया गया है।
|
|
115
|
-
आप इसे फ्री में उपयोग कर सकते हैं, लेकिन इसका सही उपयोग करें! 😊
|
|
116
|
-
|
|
117
|
-
---
|
|
118
|
-
|
|
119
|
-
## 🚀 योगदान करें
|
|
120
|
-
अगर आपके पास कोई सुझाव या नया फ़ीचर जोड़ना चाहते हैं, तो GitHub पर PR भेजें!
|
|
121
|
-
**Happy Coding! ❤️**
|
|
122
|
-
|
|
123
|
-
# HindiCode - Write JavaScript in Hindi! 🚀
|
|
124
|
-
|
|
125
|
-
## Introduction
|
|
126
|
-
**HindiCode** is an NPM package that allows you to **write JavaScript in Hindi**. It transpiles **Hindi keywords into JavaScript** at runtime, enabling you to code in Hindi seamlessly!
|
|
127
|
-
|
|
128
|
-
🔹 **Example:**
|
|
129
|
-
```hindi
|
|
130
|
-
स्थिर x = 10;
|
|
131
|
-
अगर (x > 5) {
|
|
132
|
-
दिखाओ("x बड़ा है!");
|
|
133
|
-
} अन्यथा {
|
|
134
|
-
दिखाओ("x छोटा है!");
|
|
135
|
-
}
|
|
136
|
-
```
|
|
137
|
-
✅ **Transpiled JavaScript:**
|
|
138
|
-
```javascript
|
|
139
|
-
const x = 10;
|
|
140
|
-
if (x > 5) {
|
|
141
|
-
console.log("x बड़ा है!");
|
|
142
|
-
} else {
|
|
143
|
-
console.log("x छोटा है!");
|
|
144
|
-
}
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
---
|
|
148
|
-
|
|
149
|
-
## 📌 Features
|
|
150
|
-
✔ **Code in Hindi:** Use Hindi keywords instead of JavaScript ones.
|
|
151
|
-
✔ **Runtime Transpiler:** Run `.hindi.js` files directly.
|
|
152
|
-
✔ **String Protection:** Keeps your string content untouched.
|
|
153
|
-
✔ **Simple Setup:** Install and start using immediately.
|
|
154
|
-
|
|
155
|
-
---
|
|
156
|
-
|
|
157
|
-
## 🔧 Installation
|
|
158
|
-
```sh
|
|
159
|
-
npm install -g hindicode
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
---
|
|
163
|
-
|
|
164
|
-
## 🚀 How to Use?
|
|
165
|
-
|
|
166
|
-
### **1️⃣ Write Hindi Code**
|
|
167
|
-
Create a `.hindi.js` file and write JavaScript using Hindi keywords:
|
|
168
|
-
```hindi
|
|
169
|
-
// test.hindi.js
|
|
170
|
-
स्थिर संख्या = 42;
|
|
171
|
-
दिखाओ("संख्या है:", संख्या);
|
|
172
|
-
|
|
173
|
-
कार्य जोड़ो(क, ख) {
|
|
174
|
-
लौटाओ क + ख;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
दिखाओ("जोड़:", जोड़ो(5, 7));
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
### **2️⃣ Run Directly**
|
|
181
|
-
```sh
|
|
182
|
-
node test.hindi.js
|
|
183
|
-
or
|
|
184
|
-
node hindicode test.hindi.js
|
|
185
|
-
```
|
|
186
|
-
✅ **Output:**
|
|
187
|
-
```
|
|
188
|
-
संख्या है: 42
|
|
189
|
-
जोड़: 12
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
---
|
|
193
|
-
|
|
194
|
-
## 🔍 How Does It Work?
|
|
195
|
-
**HindiCode** hooks into Node.js and **transpiles Hindi keywords into JavaScript** at runtime before execution.
|
|
196
|
-
|
|
197
|
-
```javascript
|
|
198
|
-
require.extensions[".hindi.js"] = function (module, filename) {
|
|
199
|
-
let content = fs.readFileSync(filename, "utf8").trim();
|
|
200
|
-
content = translateHindiJS(content);
|
|
201
|
-
module._compile(content, filename);
|
|
202
|
-
};
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
---
|
|
206
|
-
|
|
207
|
-
## 📖 Hindi to JavaScript Keyword Mapping
|
|
208
|
-
| **Hindi** | **JavaScript** |
|
|
209
|
-
|------------|--------------|
|
|
210
|
-
| अगर | if |
|
|
211
|
-
| अन्यथा | else |
|
|
212
|
-
| दिखाओ | console.log |
|
|
213
|
-
| कार्य | function |
|
|
214
|
-
| लौटाओ | return |
|
|
215
|
-
| चलाओ | for |
|
|
216
|
-
| जबतक | while |
|
|
217
|
-
| नया | let |
|
|
218
|
-
| स्थिर | const |
|
|
219
|
-
| परिभाषा | var |
|
|
220
|
-
| सही | true |
|
|
221
|
-
| गलत | false |
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
---
|
|
226
|
-
|
|
227
|
-
## 💖 Support Us!
|
|
228
|
-
If you like **HindiCode**, consider supporting the project!
|
|
229
|
-
👉 [Donate on Patreon](https://www.patreon.com/c/BABU_ISHU)
|
|
230
|
-
|
|
231
|
-
---
|
|
232
|
-
|
|
233
|
-
## 📜 License
|
|
234
|
-
This project is released under the **MIT License**.
|
|
235
|
-
Feel free to use it responsibly! 😊
|
|
236
|
-
|
|
237
|
-
---
|
|
238
|
-
|
|
239
|
-
## 🚀 Contribute
|
|
240
|
-
Have suggestions or want to add new features? Submit a PR on GitHub!
|
|
241
|
-
**Happy Coding! ❤️**
|
|
1
|
+
# HindiCode - हिंदी में जावास्क्रिप्ट लिखें! 🚀
|
|
2
|
+
> Write JavaScript in Hindi with Industrial-Grade Robustness.
|
|
3
|
+
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## 🌍 [HI] परिचय (Introduction)
|
|
7
|
+
**HindiCode** एक आधुनिक NPM पैकेज है जो आपको **हिंदी में जावास्क्रिप्ट** लिखने की सुविधा देता है। यह कोड को रन-टाइम पर पार्स करता है और हिंदी के कीवर्ड्स को जावास्क्रिप्ट में बदल देता है।
|
|
8
|
+
|
|
9
|
+
**HindiCode** is a modern NPM package that lets you **write JavaScript in Hindi**. It transpiles Hindi keywords into JavaScript at runtime, enabling a seamless native coding experience.
|
|
10
|
+
|
|
11
|
+
### 🔹 Example (उदाहरण)
|
|
12
|
+
```javascript
|
|
13
|
+
स्थिर x = 10;
|
|
14
|
+
अगर (x > 5) {
|
|
15
|
+
दिखाओ("x बड़ा है!");
|
|
16
|
+
} अन्यथा {
|
|
17
|
+
दिखाओ("x छोटा है!");
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 🌟 Features (विशेषताएँ)
|
|
24
|
+
- **Industrial-Grade Protection**:
|
|
25
|
+
- **🛡️ Comment Protection**: Keywords inside `//` or `/* */` are never translated.
|
|
26
|
+
- **🛡️ String Protection**: Your text inside `" "` or `' '` stays exactly as written.
|
|
27
|
+
- **🛡️ Regex Protection**: Search patterns like `/अगर/g` are preserved perfectly.
|
|
28
|
+
- **Smart Template Literals**: Supports full `${}` interpolation with recursive translation.
|
|
29
|
+
- **Unicode Boundaries**: Professional word boundaries ensure `नम` doesn't break `नमस्ते`.
|
|
30
|
+
- **Zero Configuration**: Just register the hook and run `.hindi.js` files.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 🔧 Installation (स्थापना)
|
|
35
|
+
```sh
|
|
36
|
+
npm install hindicode
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## 🚀 Usage (उपयोग)
|
|
42
|
+
|
|
43
|
+
### 1. Register the Transpiler
|
|
44
|
+
Add this to your entry point (e.g., `index.js`):
|
|
45
|
+
```javascript
|
|
46
|
+
require('hindicode');
|
|
47
|
+
require('./your-file.hindi.js');
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 2. Write in Hindi (`.hindi.js`)
|
|
51
|
+
```javascript
|
|
52
|
+
// app.hindi.js
|
|
53
|
+
नया नाम = "अर्जुन";
|
|
54
|
+
दिखाओ(`नमस्ते ${नाम}!`);
|
|
55
|
+
|
|
56
|
+
कार्य जोड़(अ, ब) {
|
|
57
|
+
लौटाओ अ + ब;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
दिखाओ("योग:", जोड़(10, 20));
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## 📖 Keyword Mapping (कीवर्ड्स)
|
|
66
|
+
| Hindi | JavaScript | Hindi | JavaScript |
|
|
67
|
+
| :--- | :--- | :--- | :--- |
|
|
68
|
+
| अगर | if | अन्य | else |
|
|
69
|
+
| दिखाओ | console.log | कार्य | function |
|
|
70
|
+
| लौटाओ | return | चलाओ | for |
|
|
71
|
+
| जबतक | while | नया | let |
|
|
72
|
+
| स्थिर | const | सही | true |
|
|
73
|
+
| गलत | false | असांयकालिक | async |
|
|
74
|
+
| प्रतीक्षा | await | त्रुटि | Error |
|
|
75
|
+
|
|
76
|
+
*(Check `index.js` for the full dictionary of over 90+ terms!)*
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## 🗺️ Roadmap (भविष्य की योजना)
|
|
81
|
+
- [ ] **Hindi Variables**: Support for non-keyword Hindi tokens as identifiers.
|
|
82
|
+
- [ ] **Hindi CLI**: A dedicated runner (`hindicode my-file.hindi.js`).
|
|
83
|
+
- [ ] **VS Code Extension**: Syntax highlighting and snippets for `.hindi.js`.
|
|
84
|
+
- [ ] **Hindi Error Messages**: Localized compiler errors.
|
|
85
|
+
- [ ] **Hindi-DOM**: Support for `दस्तावेज़` (document) and `खिड़की` (window).
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 💖 Contribute (योगदान)
|
|
90
|
+
We welcome contributions! Star the repo and join the movement to make coding accessible in every language.
|
|
91
|
+
|
|
92
|
+
👉 **Support Us**: [Patreon](https://www.patreon.com/c/BABU_ISHU)
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## 📜 License
|
|
97
|
+
Released under the **MIT License**. 😊
|
package/index.d.ts
ADDED
package/index.js
CHANGED
|
@@ -1,149 +1,232 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const Module = require("module");
|
|
3
|
-
const path = require("path");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"में": "in",
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
//
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const Module = require("module");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
|
|
5
|
+
const hindiToJS = {
|
|
6
|
+
// ── Multi-word phrases FIRST (longest → shortest to avoid partial matches) ──
|
|
7
|
+
"नहीं तो": "else",
|
|
8
|
+
"के रूप में": "as",
|
|
9
|
+
"का प्रकार": "typeof",
|
|
10
|
+
"नया बनाओ": "new",
|
|
11
|
+
"कम या बराबर": "<=",
|
|
12
|
+
"ज्यादा या बराबर": ">=",
|
|
13
|
+
"बराबर नहीं": "!==",
|
|
14
|
+
|
|
15
|
+
// ── Control Flow ─────────────────────────────────
|
|
16
|
+
"अगर": "if",
|
|
17
|
+
"वरना": "else",
|
|
18
|
+
"करो": "do",
|
|
19
|
+
"जबतक": "while",
|
|
20
|
+
"केलिए": "for",
|
|
21
|
+
"स्विच": "switch",
|
|
22
|
+
"मामला": "case",
|
|
23
|
+
"रोकें": "break",
|
|
24
|
+
"जारी": "continue",
|
|
25
|
+
"लौटाओ": "return",
|
|
26
|
+
"फेंको": "throw",
|
|
27
|
+
|
|
28
|
+
// ── Declarations ─────────────────────────────────
|
|
29
|
+
"नया": "let",
|
|
30
|
+
"स्थिर": "const",
|
|
31
|
+
"पुराना": "var",
|
|
32
|
+
"कार्य": "function",
|
|
33
|
+
"वर्ग": "class",
|
|
34
|
+
|
|
35
|
+
// ── Async ─────────────────────────────────────────
|
|
36
|
+
"असिंक": "async",
|
|
37
|
+
"इंतज़ार": "await",
|
|
38
|
+
|
|
39
|
+
// ── Literals ─────────────────────────────────────
|
|
40
|
+
"सच": "true",
|
|
41
|
+
"झूठ": "false",
|
|
42
|
+
"खाली": "null",
|
|
43
|
+
"अपरिभाषित": "undefined",
|
|
44
|
+
|
|
45
|
+
// ── OOP ──────────────────────────────────────────
|
|
46
|
+
"विस्तार": "extends",
|
|
47
|
+
"सुपर": "super",
|
|
48
|
+
"यह": "this",
|
|
49
|
+
"हटाओ": "delete",
|
|
50
|
+
"प्रोटो": "prototype",
|
|
51
|
+
"में": "in",
|
|
52
|
+
"सत्यापित": "instanceof",
|
|
53
|
+
"वापसी": "yield",
|
|
54
|
+
|
|
55
|
+
// ── Modules ──────────────────────────────────────
|
|
56
|
+
"आयात": "import",
|
|
57
|
+
"निर्यात": "export",
|
|
58
|
+
"डिफ़ॉल्ट": "default",
|
|
59
|
+
"से": "from",
|
|
60
|
+
"मांगो": "require",
|
|
61
|
+
"मॉड्यूल": "module",
|
|
62
|
+
|
|
63
|
+
// ── Operators ────────────────────────────────────
|
|
64
|
+
"और": "&&",
|
|
65
|
+
"या": "||",
|
|
66
|
+
"नहीं": "!",
|
|
67
|
+
"बराबर": "===",
|
|
68
|
+
"छोटा": "<",
|
|
69
|
+
"बड़ा": ">",
|
|
70
|
+
|
|
71
|
+
// ── Error Handling ────────────────────────────────
|
|
72
|
+
"कोशिश": "try",
|
|
73
|
+
"पकड़ो": "catch",
|
|
74
|
+
"पकड़": "catch",
|
|
75
|
+
"अंततः": "finally",
|
|
76
|
+
"त्रुटि": "Error",
|
|
77
|
+
|
|
78
|
+
// ── Console ──────────────────────────────────────
|
|
79
|
+
"दिखाओ": "console.log",
|
|
80
|
+
"गलती": "console.error",
|
|
81
|
+
"चेतावनी": "console.warn",
|
|
82
|
+
"जानकारी": "console.info",
|
|
83
|
+
"कंसोल": "console",
|
|
84
|
+
|
|
85
|
+
// ── Array Methods ────────────────────────────────
|
|
86
|
+
"पुश": "push",
|
|
87
|
+
"पॉप": "pop",
|
|
88
|
+
"शिफ्ट": "shift",
|
|
89
|
+
"अनशिफ्ट": "unshift",
|
|
90
|
+
"स्लाइस": "slice",
|
|
91
|
+
"जोड़ो": "concat",
|
|
92
|
+
"शामिल": "includes",
|
|
93
|
+
"ढूँढो": "find",
|
|
94
|
+
"मानचित्र": "map",
|
|
95
|
+
"फ़िल्टर": "filter",
|
|
96
|
+
"कमकरो": "reduce",
|
|
97
|
+
"हरएक": "forEach",
|
|
98
|
+
"लंबाई": "length",
|
|
99
|
+
"इंडेक्स": "indexOf",
|
|
100
|
+
"उलटाओ": "reverse",
|
|
101
|
+
"क्रमित": "sort",
|
|
102
|
+
|
|
103
|
+
// ── Object Methods ────────────────────────────────
|
|
104
|
+
"कुंजियाँ": "keys",
|
|
105
|
+
"मूल्य": "values",
|
|
106
|
+
"प्रविष्टियाँ": "entries",
|
|
107
|
+
"बनाएँ": "create",
|
|
108
|
+
"मिलाओ": "assign",
|
|
109
|
+
"जमाओ": "freeze",
|
|
110
|
+
|
|
111
|
+
// ── Map / Set ─────────────────────────────────────
|
|
112
|
+
"नक्शा": "Map",
|
|
113
|
+
"है": "has",
|
|
114
|
+
"प्राप्त": "get",
|
|
115
|
+
"रखो": "set",
|
|
116
|
+
"साफ़": "clear",
|
|
117
|
+
"आकार": "size",
|
|
118
|
+
|
|
119
|
+
// ── Promise ───────────────────────────────────────
|
|
120
|
+
"फिर": "then",
|
|
121
|
+
"सभी": "all",
|
|
122
|
+
"हल": "resolve",
|
|
123
|
+
"अस्वीकार": "reject",
|
|
124
|
+
"प्रॉमिस": "Promise",
|
|
125
|
+
|
|
126
|
+
// ── Browser APIs ──────────────────────────────────
|
|
127
|
+
"विंडो": "window",
|
|
128
|
+
"दस्तावेज": "document",
|
|
129
|
+
"ब्राउज़र": "navigator",
|
|
130
|
+
"स्थान": "location",
|
|
131
|
+
"इतिहास": "history",
|
|
132
|
+
"संग्रह": "localStorage",
|
|
133
|
+
"सत्र_संग्रह": "sessionStorage",
|
|
134
|
+
"चेतावनी_डिब्बा": "alert",
|
|
135
|
+
"पूछो": "prompt",
|
|
136
|
+
"पक्का_करो": "confirm",
|
|
137
|
+
"लाओ": "fetch",
|
|
138
|
+
"समय_बाद": "setTimeout",
|
|
139
|
+
"बार_बार": "setInterval",
|
|
140
|
+
"समय_रोकें": "clearTimeout",
|
|
141
|
+
"बार_रोकें": "clearInterval",
|
|
142
|
+
|
|
143
|
+
// ── Node.js ───────────────────────────────────────
|
|
144
|
+
"प्रक्रिया": "process",
|
|
145
|
+
"__नाम": "__filename",
|
|
146
|
+
"__डायरेक्टरी": "__dirname",
|
|
147
|
+
"बफर": "Buffer",
|
|
148
|
+
|
|
149
|
+
// ── Built-ins ─────────────────────────────────────
|
|
150
|
+
"ऑब्जेक्ट": "Object",
|
|
151
|
+
"ऐरे": "Array",
|
|
152
|
+
"टेक्स्ट": "String",
|
|
153
|
+
"नंबर": "Number",
|
|
154
|
+
"बूलियन": "Boolean",
|
|
155
|
+
"तारीख": "Date",
|
|
156
|
+
"गणित": "Math",
|
|
157
|
+
"जेसन": "JSON",
|
|
158
|
+
"रेगएक्स": "RegExp",
|
|
159
|
+
"अनंत": "Infinity",
|
|
160
|
+
|
|
161
|
+
// ── Math Shortcuts ────────────────────────────────
|
|
162
|
+
"गोलाई": "Math.round",
|
|
163
|
+
"ऊपर": "Math.ceil",
|
|
164
|
+
"नीचे": "Math.floor",
|
|
165
|
+
"अधिकतम": "Math.max",
|
|
166
|
+
"न्यूनतम": "Math.min",
|
|
167
|
+
"यादृच्छ": "Math.random",
|
|
168
|
+
"वर्गमूल": "Math.sqrt",
|
|
169
|
+
"पाई": "Math.PI",
|
|
170
|
+
|
|
171
|
+
// ── JSON Shortcuts ────────────────────────────────
|
|
172
|
+
"पार्स": "JSON.parse",
|
|
173
|
+
"तार_बनाओ": "JSON.stringify",
|
|
174
|
+
|
|
175
|
+
// ── String Methods ────────────────────────────────
|
|
176
|
+
"बड़े_अक्षर": "toUpperCase",
|
|
177
|
+
"छोटे_अक्षर": "toLowerCase",
|
|
178
|
+
"काटो": "trim",
|
|
179
|
+
"विभाजन": "split",
|
|
180
|
+
"बदलो": "replace",
|
|
181
|
+
"खोजो": "search",
|
|
182
|
+
"शुरू_से": "startsWith",
|
|
183
|
+
"खत्म_से": "endsWith",
|
|
184
|
+
"दोहराओ": "repeat",
|
|
185
|
+
"हिस्सा": "substring",
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
function translateHindiJS(code) {
|
|
189
|
+
const sortedKeywords = Object.keys(hindiToJS).sort((a, b) => b.length - a.length);
|
|
190
|
+
|
|
191
|
+
const parts = [
|
|
192
|
+
/(?<BLOCK>\/\*[\s\S]*?\*\/)/.source,
|
|
193
|
+
/(?<LINE>\/\/.*)/.source,
|
|
194
|
+
/(?<STRING_DBL>"(?:[^"\\]|\\.)*")/.source,
|
|
195
|
+
/(?<STRING_SGL>'(?:[^'\\]|\\.)*')/.source,
|
|
196
|
+
/(?<BACKTICK>`[\s\S]*?`)/.source,
|
|
197
|
+
/(?<REGEX>\/(?![*\/])(?:[^\/\\\n]|\\.)*?\/[gimuy]*)/.source,
|
|
198
|
+
`(?<KEYWORD>(?<![\\u0900-\\u097F])(?:${sortedKeywords.join("|")})(?![\\u0900-\\u097F]))`
|
|
199
|
+
];
|
|
200
|
+
|
|
201
|
+
const masterRegex = new RegExp(parts.join("|"), "g");
|
|
202
|
+
|
|
203
|
+
return code.replace(masterRegex, (...args) => {
|
|
204
|
+
const groups = args[args.length - 1];
|
|
205
|
+
const { BACKTICK, KEYWORD } = groups;
|
|
206
|
+
|
|
207
|
+
if (KEYWORD && hindiToJS[KEYWORD]) {
|
|
208
|
+
return hindiToJS[KEYWORD];
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (BACKTICK) {
|
|
212
|
+
return BACKTICK.replace(/\${([\s\S]*?)}/g, (m, inner) => {
|
|
213
|
+
return `${"$"}{${translateHindiJS(inner)}}`;
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return args[0];
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Custom require hook for `.hindi.js` files
|
|
222
|
+
require.extensions[".hindi.js"] = function (module, filename) {
|
|
223
|
+
try {
|
|
224
|
+
let content = fs.readFileSync(filename, "utf8").trim();
|
|
225
|
+
content = translateHindiJS(content);
|
|
226
|
+
module._compile(content, filename);
|
|
227
|
+
} catch (error) {
|
|
228
|
+
console.error("❌ Hindi Transpiler Error:", error);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
module.exports = { translateHindiJS };
|
package/package.json
CHANGED
|
@@ -1,12 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hindicode",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Run JavaScript with Hindi keywords",
|
|
4
5
|
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
5
7
|
"scripts": {
|
|
6
8
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
9
|
},
|
|
8
|
-
"keywords": [
|
|
9
|
-
|
|
10
|
+
"keywords": [
|
|
11
|
+
"hindi",
|
|
12
|
+
"javascript",
|
|
13
|
+
"transpiler",
|
|
14
|
+
"compiler",
|
|
15
|
+
"hindi-js",
|
|
16
|
+
"programming",
|
|
17
|
+
"education"
|
|
18
|
+
],
|
|
19
|
+
"author": "Ujjwal-08",
|
|
10
20
|
"license": "ISC",
|
|
11
|
-
"
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/Ujjwal-08/hindicode.git"
|
|
24
|
+
},
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/Ujjwal-08/hindicode/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/Ujjwal-08/hindicode#readme",
|
|
29
|
+
"files": [
|
|
30
|
+
"index.js",
|
|
31
|
+
"index.d.ts",
|
|
32
|
+
"README.md",
|
|
33
|
+
"LICENSE"
|
|
34
|
+
],
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
37
|
+
"@semantic-release/github": "^12.0.6",
|
|
38
|
+
"@semantic-release/npm": "^13.1.5",
|
|
39
|
+
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
40
|
+
"semantic-release": "^25.0.3"
|
|
41
|
+
}
|
|
12
42
|
}
|