hindicode 1.0.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/index.js +26 -0
- package/package.json +12 -0
package/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
|
|
3
|
+
// Hindi to JavaScript keyword mapping
|
|
4
|
+
const hindiToJS = {
|
|
5
|
+
"अगर": "if",
|
|
6
|
+
"अन्यथा": "else",
|
|
7
|
+
"दिखाओ": "console.log",
|
|
8
|
+
"कार्य": "function",
|
|
9
|
+
"लौटाओ": "return"
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// Function to translate Hindi JavaScript code
|
|
13
|
+
function translateHindiJS(code) {
|
|
14
|
+
for (const [hindi, js] of Object.entries(hindiToJS)) {
|
|
15
|
+
const regex = new RegExp(`\\b${hindi}\\b`, "g");
|
|
16
|
+
code = code.replace(regex, js);
|
|
17
|
+
}
|
|
18
|
+
return code;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Hook into Node.js `require` to automatically translate Hindi JS files
|
|
22
|
+
require.extensions[".js"] = function (module, filename) {
|
|
23
|
+
let content = fs.readFileSync(filename, "utf8");
|
|
24
|
+
content = translateHindiJS(content);
|
|
25
|
+
module._compile(content, filename);
|
|
26
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "hindicode",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
|
+
},
|
|
8
|
+
"keywords": [],
|
|
9
|
+
"author": "",
|
|
10
|
+
"license": "ISC",
|
|
11
|
+
"description": "Run JavaScript with Hindi keywords"
|
|
12
|
+
}
|