@lmjs/cli 1.0.43 → 1.0.44

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.
Files changed (2) hide show
  1. package/lib/fcs.js +21 -3
  2. package/package.json +1 -1
package/lib/fcs.js CHANGED
@@ -364,6 +364,22 @@ function validURL(string) {
364
364
 
365
365
  exports.validURL = validURL;
366
366
 
367
+
368
+ let getPairs = (obj, keys = []) =>
369
+ Object.entries(obj).reduce((pairs, [key, value]) => {
370
+ if (typeof value === 'object')
371
+ pairs.push(...getPairs(value, [...keys, key]));
372
+ else
373
+ pairs.push([[...keys, key], value]);
374
+ return pairs;
375
+ }, []);
376
+
377
+ function pairIt(obj) {
378
+ return getPairs(obj).map(([[key0, ...keysRest], value]) =>
379
+ `${key0}${keysRest.map(a => `[${a}]`).join('')}=${value}`)
380
+ .join('&');
381
+ }
382
+
367
383
  var API = {
368
384
  get: async function (u, d, h, a) {
369
385
  return await this.req(u, d, h, "GET", a);
@@ -381,16 +397,18 @@ var API = {
381
397
  return await this.req(u, d, h, "PATCH", a);
382
398
  },
383
399
  req: async function (u, d, h, m, a, f) {
400
+
384
401
  var urled = validURL(u) ? u : config.apis[a ?? 0].baseURL + u;
385
402
  if (m.toString().toLowerCase() == 'get') {
386
- if (urled.indexOf('?') > -1) urled = urled + "&" + new URLSearchParams(d ?? {});
387
- else urled = urled + "?" + new URLSearchParams(d ?? {});
403
+ if (urled.indexOf('?') > -1) urled = urled + "&" + pairIt(d ?? {});
404
+ else urled = urled + "?" + pairIt(d ?? {});
388
405
  }
389
406
  let resa = await fetch(urled, {
390
407
  method: m.toString().toLowerCase(),
391
408
  body: m.toString().toLowerCase() == 'get' ? null : JSON.stringify(d ?? {}),
392
409
  headers: h ?? config.apis[a ?? 0].headers,
393
410
  });
411
+
394
412
  if (f) return resa;
395
413
  let res = await resa.text();
396
414
  try {
@@ -464,7 +482,7 @@ function processCommands(cmd) {
464
482
  } else if (command == "build") {
465
483
  let cmds = process.argv;
466
484
  _bp(cmds);
467
- } else if (command == "-v" || command == "-version") {
485
+ } else if (command == "-v" || command == "-version") {
468
486
  console.log("LumenJS version " + require('../package.json').version);
469
487
  } else {
470
488
  console.log("LumenJS CLI's command not found!");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lmjs/cli",
3
- "version": "1.0.43",
3
+ "version": "1.0.44",
4
4
  "description": "Command line interface for super fast LumenJS development. LumenJS is a tiny robust reactive javascript framework for building scalable and high-performant web applications and web user interfaces, be it simple or complex, with standard HTML, CSS and JavaScript",
5
5
  "bin": {
6
6
  "lm": "./bin/commands.js",