- ✔️ Index, all in 1 page ➡️ https://juancarlospaco.github.io/nodejs
- ✔️ assert ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jsassert
- ✔️ async_hooks ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jsasynchooks
- ✔️ process ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jsprocess
- ✔️ dns ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jsdns
- ✔️ fs ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jsfs
- ✔️ inspector ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jsinspector
- ✔️ os ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jsos
- ✔️ path ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jspath
- ✔️ perf_hooks ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jsperfhooks
- ✔️ punycode ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jspunycode
- ✔️ querystring ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jsquerystring
- ✔️ util ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jsutils
- ✔️ v8 ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jsv8
- ✔️ zlib ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jszlib
- ✔️ readline ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jsreadline
- ✔️ timers ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jstimers
- ✔️ repl ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jsrepl
- ✔️ url ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jsurl
- ✔️ tracing ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jstracing
- ✔️ module ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jsmodule
- ✔️ domain ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jsdomain
- ✔️ diagnostics_channel ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jsdiagnostics_channel
- ✔️ wasi ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jswasi
- ✔️ buffer ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jsbuffer
- ✔️ stream ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jstream
- ✔️ cluster ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jscluster
- ✔️ http ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jshttp
- ✔️ http2 ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jshttp2
- ✔️ worker_threads ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jsworker_threads
- ✔️ Internationalization API ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jsintl
- ✔️ Payments API ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jspayments
- ✔️ QR-Codes and Bar-Codes API ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jsbarcodes
- ✔️ Regex utils ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jsreutils
- ✔️ HttpClient for JavaScript ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jshttpclient
- ✔️ Async HttpClient for JavaScript ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jsasynchttpclient
- ✔️ Google ZX
- ✔️ Compile-time macro-unrolled zero-overhead for loops.
- ✔️ Compile-time zero-overhead strformat
- ✔️ Common module ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jscore.html
- ✔️ Custom syntax sugar ➡️ https://juancarlospaco.github.io/nodejs/nodejs/jsugar.html
More supported modules soon...
- Backend in Frontend https://blog.stackblitz.com/posts/introducing-webcontainers
nimble install nodejs
ORnimble install https://github.com/juancarlospaco/nodejs.git
- It does not use anything from Nim standard library, very future-proof,
just imports some types to be compatible with it, like
RegExp
, etc. - We do not deprecate stuff, even if NodeJS deprecate/remove it, it will keep working for Nim.
- Stuff deprecated/demoved before year 2020 will not be supported.
- Experimental or Unstable API on NodeJS are automatically implicitly considered Experimental here.
- Package version == NodeJS version.
- is it any good ?, improves something ?.
import jsconsole, nodejs
console.log base64encode("example")
This module generated JavaScript:
console.log(Buffer.from("example", "utf-8").toString("base64"));
Standard Library:
import jsconsole, base64 # Standard Library
console.log base64encode("example")
Standard Library Generated JavaScript
function mnewString(len_33558512) {
return new Array(len_33558512);
}
function makeNimstrLit(c_33558354) {
var ln = c_33558354.length;
var result = new Array(ln);
for (var i = 0; i < ln; ++i) {
result[i] = c_33558354.charCodeAt(i);
}
return result;
}
function toJSStr(s_33558362) {
var Tmp5;
var Tmp7;
var result_33558363 = null;
var res_33558422 = newSeq_33558393((s_33558362).length);
var i_33558424 = 0;
var j_33558426 = 0;
L1: do {
L2: while (true) {
if (!(i_33558424 < (s_33558362).length)) break L2;
var c_33558427 = s_33558362[i_33558424];
if ((c_33558427 < 128)) {
res_33558422[j_33558426] = String.fromCharCode(c_33558427);
i_33558424 += 1;
} else {
var helper_33558450 = newSeq_33558393(0);
L3: do {
L4: while (true) {
if (!true) break L4;
var code_33558451 = c_33558427.toString(16);
if (((code_33558451).length == 1)) {
helper_33558450.push("%0");;
} else {
helper_33558450.push("%");;
}
helper_33558450.push(code_33558451);;
i_33558424 += 1;
if (((s_33558362).length <= i_33558424)) Tmp5 = true;
else {
Tmp5 = (s_33558362[i_33558424] < 128);
}
if (Tmp5) {
break L3;
}
c_33558427 = s_33558362[i_33558424];
}
} while (false);
++excHandler;
Tmp7 = framePtr;
try {
res_33558422[j_33558426] = decodeURIComponent(helper_33558450.join(""));
--excHandler;
} catch (EXC) {
var prevJSError = lastJSError;
lastJSError = EXC;
--excHandler;
framePtr = Tmp7;
res_33558422[j_33558426] = helper_33558450.join("");
lastJSError = prevJSError;
} finally {
framePtr = Tmp7;
}
}
j_33558426 += 1;
}
} while (false);
if (res_33558422.length < j_33558426) {
for (var i = res_33558422.length; i < j_33558426; ++i) res_33558422.push(null);
} else {
res_33558422.length = j_33558426;
};
result_33558363 = res_33558422.join("");
return result_33558363;
}
var globalRaiseHook_33557677 = [null];
if (globalThis.localRaiseHook_33557682 === undefined) {
localRaiseHook_33557682 = [null];
}
var outOfMemHook_33557685 = [null];
var unhandledExceptionHook_33557690 = [null];
var cb64_469762056 = [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, 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, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47];
var cb64safe_469762059 = [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, 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, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95];
function encode_469762156(s_469762158, safe_469762159) {
var Tmp2;
var result_469762160 = [];
L1: do {
if (safe_469762159) {
Tmp2 = cb64safe_469762059;
} else {
Tmp2 = cb64_469762056;
}
var lookupTable_469762502 = Tmp2;
(result_469762160.length = (Math.trunc(((s_469762158).length * 4) / 3) + 6));
var inputIndexHEX60gensym45_469762513 = 0;
var outputIndexHEX60gensym45_469762515 = 0;
var inputEndsHEX60gensym45_469762516 = ((s_469762158).length - Math.trunc((s_469762158).length % 3));
var nHEX60gensym45_469762517 = 0;
var bHEX60gensym45_469762518 = 0;
L3: do {
L4: while (true) {
if (!!((inputIndexHEX60gensym45_469762513 == inputEndsHEX60gensym45_469762516))) break L4;
bHEX60gensym45_469762518 = s_469762158[inputIndexHEX60gensym45_469762513];
nHEX60gensym45_469762517 = (bHEX60gensym45_469762518 << 16);
inputIndexHEX60gensym45_469762513 += 1;
bHEX60gensym45_469762518 = s_469762158[inputIndexHEX60gensym45_469762513];
nHEX60gensym45_469762517 = (nHEX60gensym45_469762517 | (bHEX60gensym45_469762518 << 8));
inputIndexHEX60gensym45_469762513 += 1;
bHEX60gensym45_469762518 = s_469762158[inputIndexHEX60gensym45_469762513];
nHEX60gensym45_469762517 = (nHEX60gensym45_469762517 | (bHEX60gensym45_469762518 << 0));
inputIndexHEX60gensym45_469762513 += 1;
result_469762160[outputIndexHEX60gensym45_469762515] = lookupTable_469762502[(((nHEX60gensym45_469762517 >>> 0) >>> 18) & 63)];
outputIndexHEX60gensym45_469762515 += 1;
result_469762160[outputIndexHEX60gensym45_469762515] = lookupTable_469762502[(((nHEX60gensym45_469762517 >>> 0) >>> 12) & 63)];
outputIndexHEX60gensym45_469762515 += 1;
result_469762160[outputIndexHEX60gensym45_469762515] = lookupTable_469762502[(((nHEX60gensym45_469762517 >>> 0) >>> 6) & 63)];
outputIndexHEX60gensym45_469762515 += 1;
result_469762160[outputIndexHEX60gensym45_469762515] = lookupTable_469762502[(((nHEX60gensym45_469762517 >>> 0) >>> 0) & 63)];
outputIndexHEX60gensym45_469762515 += 1;
}
} while (false);
var paddingHEX60gensym45_469762646 = Math.trunc((s_469762158).length % 3);
if ((paddingHEX60gensym45_469762646 == 1)) {
bHEX60gensym45_469762518 = s_469762158[inputIndexHEX60gensym45_469762513];
nHEX60gensym45_469762517 = (bHEX60gensym45_469762518 << 16);
inputIndexHEX60gensym45_469762513 += 1;
result_469762160[outputIndexHEX60gensym45_469762515] = lookupTable_469762502[(((nHEX60gensym45_469762517 >>> 0) >>> 18) & 63)];
outputIndexHEX60gensym45_469762515 += 1;
result_469762160[outputIndexHEX60gensym45_469762515] = lookupTable_469762502[(((nHEX60gensym45_469762517 >>> 0) >>> 12) & 63)];
outputIndexHEX60gensym45_469762515 += 1;
result_469762160[outputIndexHEX60gensym45_469762515] = 61;
outputIndexHEX60gensym45_469762515 += 1;
result_469762160[outputIndexHEX60gensym45_469762515] = 61;
outputIndexHEX60gensym45_469762515 += 1;
} else {
if ((paddingHEX60gensym45_469762646 == 2)) {
bHEX60gensym45_469762518 = s_469762158[inputIndexHEX60gensym45_469762513];
nHEX60gensym45_469762517 = (bHEX60gensym45_469762518 << 16);
inputIndexHEX60gensym45_469762513 += 1;
bHEX60gensym45_469762518 = s_469762158[inputIndexHEX60gensym45_469762513];
nHEX60gensym45_469762517 = (nHEX60gensym45_469762517 | (bHEX60gensym45_469762518 << 8));
inputIndexHEX60gensym45_469762513 += 1;
result_469762160[outputIndexHEX60gensym45_469762515] = lookupTable_469762502[(((nHEX60gensym45_469762517 >>> 0) >>> 18) & 63)];
outputIndexHEX60gensym45_469762515 += 1;
result_469762160[outputIndexHEX60gensym45_469762515] = lookupTable_469762502[(((nHEX60gensym45_469762517 >>> 0) >>> 12) & 63)];
outputIndexHEX60gensym45_469762515 += 1;
result_469762160[outputIndexHEX60gensym45_469762515] = lookupTable_469762502[(((nHEX60gensym45_469762517 >>> 0) >>> 6) & 63)];
outputIndexHEX60gensym45_469762515 += 1;
result_469762160[outputIndexHEX60gensym45_469762515] = 61;
outputIndexHEX60gensym45_469762515 += 1;
}
}
(result_469762160.length = outputIndexHEX60gensym45_469762515);
} while (false);
return result_469762160;
}
function newSeq_33558393(len_33558396) {
var result_33558398 = [];
result_33558398 = new Array(len_33558396);
for (var i = 0; i < len_33558396; ++i) {
result_33558398[i] = null;
}
return result_33558398;
}
console.log(toJSStr(encode_469762156(makeNimstrLit("example"), false)));
import jsconsole, nodejs
console.log deduplicate([9, 2, 3, 9, 4, 5, 6, 9])
This module generated JavaScript:
console.log([...new Set([9, 2, 3, 9, 4, 5, 6, 9])]);
Standard Library:
import jsconsole, sequtils # Standard Library
console.log deduplicate([9, 2, 3, 9, 4, 5, 6, 9])
Standard Library Generated JavaScript
var NTI369098754 = {
size: 0,
kind: 31,
base: null,
node: null,
finalizer: null
};
var NTI369098779 = {
size: 0,
kind: 24,
base: null,
node: null,
finalizer: null
};
NTI369098779.base = NTI369098754;
function setConstr() {
var result = {};
for (var i = 0; i < arguments.length; ++i) {
var x = arguments[i];
if (typeof(x) == "object") {
for (var j = x[0]; j <= x[1]; ++j) {
result[j] = true;
}
} else {
result[x] = true;
}
}
return result;
}
var ConstSet1 = setConstr(17, 16, 4, 18, 27, 19, 23, 22, 21);
function nimCopy(dest_33558821, src_33558822, ti_33558823) {
var result_33558835 = null;
switch (ti_33558823.kind) {
case 21:
case 22:
case 23:
case 5:
if (!(isFatPointer_33558808(ti_33558823))) {
result_33558835 = src_33558822;
} else {
result_33558835 = [src_33558822[0], src_33558822[1]];
}
break;
case 19:
if (dest_33558821 === null || dest_33558821 === undefined) {
dest_33558821 = {};
} else {
for (var key in dest_33558821) {
delete dest_33558821[key];
}
}
for (var key in src_33558822) {
dest_33558821[key] = src_33558822[key];
}
result_33558835 = dest_33558821;
break;
case 18:
case 17:
if (!((ti_33558823.base == null))) {
result_33558835 = nimCopy(dest_33558821, src_33558822, ti_33558823.base);
} else {
if ((ti_33558823.kind == 17)) {
result_33558835 = (dest_33558821 === null || dest_33558821 === undefined) ? {
m_type: ti_33558823
} : dest_33558821;
} else {
result_33558835 = (dest_33558821 === null || dest_33558821 === undefined) ? {} : dest_33558821;
}
}
nimCopyAux(result_33558835, src_33558822, ti_33558823.node);
break;
case 24:
case 4:
case 27:
case 16:
if (src_33558822 === null) {
result_33558835 = null;
} else {
if (dest_33558821 === null || dest_33558821 === undefined) {
dest_33558821 = new Array(src_33558822.length);
} else {
dest_33558821.length = src_33558822.length;
}
result_33558835 = dest_33558821;
for (var i = 0; i < src_33558822.length; ++i) {
result_33558835[i] = nimCopy(result_33558835[i], src_33558822[i], ti_33558823.base);
}
}
break;
case 28:
if (src_33558822 !== null) {
result_33558835 = src_33558822.slice(0);
}
break;
default:
result_33558835 = src_33558822;
break;
}
return result_33558835;
}
var globalRaiseHook_33557677 = [null];
if (globalThis.localRaiseHook_33557682 === undefined) {
localRaiseHook_33557682 = [null];
}
var outOfMemHook_33557685 = [null];
var unhandledExceptionHook_33557690 = [null];
function isFatPointer_33558808(ti_33558810) {
var result_33558811 = false;
BeforeRet: do {
result_33558811 = !((ConstSet1[ti_33558810.base.kind] != undefined));
break BeforeRet;
} while (false);
return result_33558811;
}
function nimCopyAux(dest_33558826, src_33558827, n_33558829) {
switch (n_33558829.kind) {
case 0:
break;
case 1:
dest_33558826[n_33558829.offset] = nimCopy(dest_33558826[n_33558829.offset], src_33558827[n_33558829.offset], n_33558829.typ);
break;
case 2:
for (var i = 0; i < n_33558829.sons.length; i++) {
nimCopyAux(dest_33558826, src_33558827, n_33558829.sons[i]);
}
break;
case 3:
dest_33558826[n_33558829.offset] = nimCopy(dest_33558826[n_33558829.offset], src_33558827[n_33558829.offset], n_33558829.typ);
for (var i = 0; i < n_33558829.sons.length; ++i) {
nimCopyAux(dest_33558826, src_33558827, n_33558829.sons[i][1]);
}
break;
}
}
function find_369098843(a_369098847, item_369098848) {
var result_369098849 = 0;
BeforeRet: do {
result_369098849 = 0;
L1: do {
var i_369098856 = null;
var i_369098856_Idx = 0;
var i_369098947 = 0;
L2: do {
L3: while (true) {
if (!(i_369098947 < (a_369098847).length)) break L3;
i_369098856 = a_369098847;
i_369098856_Idx = i_369098947;
if ((i_369098856[i_369098856_Idx] == item_369098848)) {
break BeforeRet;
}
result_369098849 += 1;
i_369098947 += 1;
}
} while (false);
} while (false);
result_369098849 = -1;
} while (false);
return result_369098849;
}
function contains_369098836(a_369098840, item_369098841) {
var result_369098842 = false;
BeforeRet: do {
result_369098842 = (0 <= find_369098843(a_369098840, item_369098841));
break BeforeRet;
} while (false);
return result_369098842;
}
function deduplicate_369098757(s_369098761, isSorted_369098762) {
var result_369098764 = [];
result_369098764 = nimCopy(null, [], NTI369098779);
if ((0 < (s_369098761).length)) {
if (isSorted_369098762) {
var prev_369098784 = s_369098761[0];
result_369098764.push(prev_369098784);;
L1: do {
var i_369098806 = 0;
var colontmp__369098932 = 0;
colontmp__369098932 = ((s_369098761).length - 1);
var res_369098937 = 1;
L2: do {
L3: while (true) {
if (!(res_369098937 <= colontmp__369098932)) break L3;
i_369098806 = res_369098937;
if (!((s_369098761[i_369098806] == prev_369098784))) {
prev_369098784 = s_369098761[i_369098806];
result_369098764.push(prev_369098784);;
}
res_369098937 += 1;
}
} while (false);
} while (false);
} else {
L4: do {
var itm_369098834 = null;
var itm_369098834_Idx = 0;
var i_369098944 = 0;
L5: do {
L6: while (true) {
if (!(i_369098944 < (s_369098761).length)) break L6;
itm_369098834 = s_369098761;
itm_369098834_Idx = i_369098944;
if (!(contains_369098836(result_369098764, itm_369098834[itm_369098834_Idx]))) {
result_369098764.push(itm_369098834[itm_369098834_Idx]);;
}
i_369098944 += 1;
}
} while (false);
} while (false);
}
}
return result_369098764;
}
console.log(deduplicate_369098757([9, 2, 3, 9, 4, 5, 6, 9], false));
See also:
- https://github.com/nim-lang/Nim/wiki/Nim-for-TypeScript-Programmers#table-of-contents
- https://nim-lang.github.io/Nim/jsre.html
- https://nim-lang.github.io/Nim/jsbigints.html
Promise.then()
andPromise.catch()
work in Nim.- HTTPS Requests for JavaScript target in Nim.
- nim-lang/Nim#7505 (comment)
- nim-lang/Nim#3124 (comment)