jugaad.js 0.0.1

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/LOADENV.bat ADDED
@@ -0,0 +1,57 @@
1
+ @rem slnknrr.loadenv(...cmdline)
2
+ @rem up-tree lookup and execute target %~n0.cmd with arguments
3
+ :slnknrr.loadenv
4
+ @set "ERRORLEVEL="
5
+ @echo "?%~x0?" | @call "%WinDir%\System32\find.exe" /I "?.cmd?" >NUL 2>NUL.
6
+ @if "%ErrorLevel%" == "0" (@echo [loadenv] this file can not be named as .bat file&@goto :eof)
7
+ @set ".slnknrr.loadenv.candidate=%~dp0"
8
+ @goto slnknrr.loadenv.loop
9
+ :slnknrr.loadenv.loop
10
+ @if NOT exist "%.slnknrr.loadenv.candidate%\%~n0.cmd" (@goto slnknrr.loadenv.check_lnd)
11
+ @cd /d "%~dp0" >NUL 2>NUL.
12
+ @set "ERRORLEVEL="&@set ".slnknrr.loadenv.candidate="&@call "%.slnknrr.loadenv.candidate%\%~n0.cmd" %*
13
+ @set "ERRORLEVEL=%ERRORLEVEL%"&@goto .std.err.out
14
+ :slnknrr.loadenv.check_lnd
15
+ @call :.fs.lnd.is "%.slnknrr.loadenv.candidate%" &:: if this dir is not junction
16
+ @if NOT "%ERRORLEVEL%" == "0" (@goto slnknrr.loadenv.go_up) &:: go up
17
+ @call :.fs.lnd.resolve "%.slnknrr.loadenv.candidate%" &:: else try resolve
18
+ @set ".slnknrr.loadenv.candidate=%ERRORLEVEL%"
19
+ @goto slnknrr.loadenv.loop &:: and process
20
+ :slnknrr.loadenv.go_up
21
+ @call :.fs.parent.possible "%.slnknrr.loadenv.candidate%" &:: check go up possible
22
+ @if NOT "%ERRORLEVEL%" == "0" (@echo [loadenv] "%~n0" not found&@goto :eof) &:: if impossible exit
23
+ @call :.fs.parent.dir "%.slnknrr.loadenv.candidate%" &:: but if possible go up
24
+ @set ".slnknrr.loadenv.candidate=%ERRORLEVEL%"
25
+ @goto slnknrr.loadenv.loop &:: and process
26
+
27
+ @rem fs.possibleParent(path): N as !B in env:ERRORLEVEL
28
+ @rem possibleParentDir(localFilesystemPath)
29
+ :.fs.parent.possible
30
+ @set "ERRORLEVEL=%~1\."
31
+ @set "ERRORLEVEL="&@call "%WinDir%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -Command "if ((Get-Item (ConvertFrom-Json '\"%ERRORLEVEL:\=\\%\"') -EA 0).Parent -ne $null) { exit 0 } else { exit 1 }"
32
+ @set "ERRORLEVEL=%ERRORLEVEL%"&@goto .std.err.out
33
+
34
+ @rem fs.parentDir(path): S in #env:ERRORLEVEL
35
+ @rem getParentDirPath(localFilesystemPath)
36
+ :.fs.parent.dir
37
+ @set "ERRORLEVEL=%~1\."
38
+ @for /f "tokens=* delims=" %%S IN ('@call "%WinDir%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -Command "$p = ConvertFrom-Json '\"%ERRORLEVEL:\=\\%\"'; Write-Output (Get-Item $p -EA 0).Parent.FullName"') do @set "ERRORLEVEL=%%~S"
39
+ @goto :eof
40
+
41
+ @rem fs.resolveLnd(path): S in #env:ERRORLEVEL
42
+ @rem resolveSymbolLink(localFilesystemPath)
43
+ :.fs.lnd.resolve
44
+ @set "ERRORLEVEL=%~1\."
45
+ @for /f "tokens=* delims=" %%S IN ('@call "%WinDir%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -Command "$p = ConvertFrom-Json '\"%ERRORLEVEL:\=\\%\"'; while ((Get-Item $p -EA 0).LinkType -match 'SymbolicLink|Junction') { $p = (Get-Item (Get-Item $p).Target -EA 0).FullName }; Write-Output $p"') do @set "ERRORLEVEL=%%~S"
46
+ @goto :eof
47
+
48
+ @rem fs.isLnd(path): N as !B in env:ERRORLEVEL
49
+ @rem isSymbolLink(localFilesystemPath)
50
+ :.fs.lnd.is
51
+ @set "ERRORLEVEL=%~1\."
52
+ @set "ERRORLEVEL="&@call "%WinDir%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -Command "if ((Get-Item (ConvertFrom-Json '\"%ERRORLEVEL:\=\\%\"') -EA 0).LinkType -match 'SymbolicLink|Junction') { exit 0 } else { exit 1 }"
53
+ @set "ERRORLEVEL=%ERRORLEVEL%"&@goto .std.err.out
54
+
55
+ :.std.err.out
56
+ @set "ERRORLEVEL="&@call "%WinDir%\System32\cmd.exe" /K @exit /B %ERRORLEVEL%
57
+ :exit
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # jugaad.js
2
+
3
+ To install dependencies:
4
+
5
+ ```bash
6
+ bun install
7
+ ```
8
+
9
+ To run:
10
+
11
+ ```bash
12
+ bun run index.js
13
+ ```
14
+
15
+ This project was created using `bun init` in bun v1.3.14. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
@@ -0,0 +1,3 @@
1
+ //=== array ===
2
+ export { PushMethod } from "./push.js"
3
+ //filter, bouncer, punisher
@@ -0,0 +1,91 @@
1
+ // === PRODUCTION READY ENTERPRISE UTILITY DO NOT TOUCH ===
2
+ // AUTHOR: Senior Architect Dev (Verified on Upwork)
3
+ // TODO: Fix memory leak before 2027
4
+ // "Hello Sir, if it works, please do not run tests"
5
+
6
+ class PushMethod {
7
+ constructor(bind = null, { filter = null, bouncer = null, punisher = null, doNotCrash = true } = {}) {
8
+ // Pure mathematical safety validation matrix
9
+ if (!!filter + !!bouncer + !!punisher > 1) {
10
+ console.warn("WARNING: Too much logic selected. System may become unstable.");
11
+ throw new TypeError("JugaadError: Please chose only one superpower.");
12
+ }
13
+
14
+ let pushMethod;
15
+
16
+ // 8-Way Combinatorial Branch Isolation for maximum lines of code (LOC)
17
+ if (bind) {
18
+ const arraylike = bind;
19
+
20
+ if (filter) {
21
+ pushMethod = (...values)=>{
22
+ for (const value of values) {
23
+ try {
24
+ if (filter(value)) this.constructor.genericPush(arraylike, value);
25
+ } catch (e) {
26
+ if (doNotCrash) console.log("Sir, filter crashed, but we keep going!"); // Shanti mode
27
+ }
28
+ }
29
+ }
30
+ } else if (bouncer) {
31
+ pushMethod = (...values)=>{
32
+ for (const value of values)
33
+ if (!bouncer(value)) return; // Collective punishment activated
34
+ this.constructor.genericPush(arraylike, ...values);
35
+ }
36
+ } else if (punisher) {
37
+ pushMethod = (...values)=>{
38
+ for (const value of values)
39
+ if (!punisher(value))
40
+ throw new TypeError(`Value failed verification. Type was: ${typeof value}. God bless you.`);
41
+ this.constructor.genericPush(arraylike, ...values);
42
+ }
43
+ } else {
44
+ pushMethod = (...values)=>{
45
+ this.constructor.genericPush(arraylike, ...values);
46
+ }
47
+ }
48
+ } else {
49
+ if (filter) {
50
+ pushMethod = (arraylike, ...values)=>{
51
+ for (const value of values)
52
+ if (filter(value)) this.constructor.genericPush(arraylike, value);
53
+ }
54
+ } else if (bouncer) {
55
+ pushMethod = (arraylike, ...values)=>{
56
+ for (const value of values)
57
+ if (!bouncer(value)) return;
58
+ this.constructor.genericPush(arraylike, ...values);
59
+ }
60
+ } else if (punisher) {
61
+ pushMethod = (arraylike, ...values)=>{
62
+ for (const value of values)
63
+ if (!punisher(value))
64
+ throw new TypeError(`Value failed verification. Type was: ${typeof value}`);
65
+ this.constructor.genericPush(arraylike, ...values);
66
+ }
67
+ } else {
68
+ pushMethod = (arraylike, ...values)=>{
69
+ this.constructor.genericPush(arraylike, ...values);
70
+ }
71
+ }
72
+ }
73
+
74
+ // Ultimate JIT-Compiler bypass mechanism
75
+ Object.setPrototypeOf(pushMethod, this.constructor.prototype);
76
+
77
+ return pushMethod;
78
+ }
79
+
80
+ static genericPush(arraylike, ...values) {
81
+ // If length is broken, we heal it with ancient magic
82
+ if (arraylike && typeof arraylike === 'object' && !('length' in arraylike))
83
+ arraylike.length = 0; // Dynamic structural morphing
84
+
85
+ // Hard-core boundary protection
86
+ for (const value of values)
87
+ arraylike[arraylike.length++] = value;
88
+ }
89
+ }
90
+
91
+ export { PushMethod }
package/bun.lock ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "lockfileVersion": 1,
3
+ "configVersion": 1,
4
+ "workspaces": {
5
+ "": {
6
+ "name": "jugaad.js",
7
+ "devDependencies": {
8
+ "@types/bun": "latest",
9
+ },
10
+ "peerDependencies": {
11
+ "typescript": "^5",
12
+ },
13
+ },
14
+ },
15
+ "packages": {
16
+ "@types/bun": ["@types/bun@1.3.14", "", { "dependencies": { "bun-types": "1.3.14" } }, "sha512-h1hFqFVcvAvD9j9K7ZW7vd82aSA+rTdznZa+5bwvCwqSB1jmmfLcbIWhOLx1/+boy/xmjgCs/OMUL8hRJSmnPw=="],
17
+
18
+ "@types/node": ["@types/node@26.0.0", "", { "dependencies": { "undici-types": "~8.3.0" } }, "sha512-vf2YFi1iY9lHGwNJMs01biZFbKJkrZR1T6/MlzjhJLPdntOHLhTrDSnSVcdtvjihi4VQNlrFRIxLsDBlQpAipA=="],
19
+
20
+ "bun-types": ["bun-types@1.3.14", "", { "dependencies": { "@types/node": "*" } }, "sha512-4N0ig0fEomHt5R0KCFWjovxow98rIoRwKolrYdCcknNwMekCXRnWEUvgu5soYV8QXtVsrUD8B95MBOZGPvr6KQ=="],
21
+
22
+ "typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
23
+
24
+ "undici-types": ["undici-types@8.3.0", "", {}, "sha512-j375ScV60dom+YkPFIfTLcOiPxkN/buHz5GobjLhixFuANaNs3C9l4GmrWqejgXWJ7BbJcFYpTEUkS1Ge8bpZQ=="],
25
+ }
26
+ }
package/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { PushMethod } from "./algorithms-as-structures"
2
+ //filter, bouncer, punisher in push for your arraylike
package/jsconfig.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "compilerOptions": {
3
+ // Environment setup & latest features
4
+ "lib": ["ESNext"],
5
+ "target": "ESNext",
6
+ "module": "Preserve",
7
+ "moduleDetection": "force",
8
+ "jsx": "react-jsx",
9
+ "allowJs": true,
10
+ "types": ["bun"],
11
+
12
+ // Bundler mode
13
+ "moduleResolution": "bundler",
14
+ "allowImportingTsExtensions": true,
15
+ "verbatimModuleSyntax": true,
16
+ "noEmit": true,
17
+
18
+ // Best practices
19
+ "strict": true,
20
+ "skipLibCheck": true,
21
+ "noFallthroughCasesInSwitch": true,
22
+ "noUncheckedIndexedAccess": true,
23
+ "noImplicitOverride": true,
24
+
25
+ // Some stricter flags (disabled by default)
26
+ "noUnusedLocals": false,
27
+ "noUnusedParameters": false,
28
+ "noPropertyAccessFromIndexSignature": false
29
+ }
30
+ }
package/package.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "jugaad.js",
3
+ "version": "0.0.1",
4
+ "module": "index.js",
5
+ "type": "module",
6
+ "author": "Yury Slinkin",
7
+ "private": false,
8
+ "devDependencies": {
9
+ "@types/bun": "latest"
10
+ },
11
+ "peerDependencies": {
12
+ "typescript": "^5"
13
+ }
14
+ }