puvox-library 1.0.4 → 1.0.5

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.
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  *
3
- * ################################################################################
4
- * ############################### Our JS Library ##############################
5
- * ##### Here we collect frequently used methods across our JS applications. #####
6
- * ##### (Some of them are generic javascript functions, some are for NodeJS) #####
7
- * ################################################################################
3
+ * ############################################################################
4
+ * ############################# Our JS Library ############################
5
+ * ### Here we collect frequently used methods across our JS applications. ###
6
+ * ### (Some of them are generic javascript functions, some are for NodeJS) ###
7
+ * ############################################################################
8
8
  *
9
9
  * ########## Example usage: ##########
10
10
  * const helpers = new PuvoxLibrary();
@@ -1287,6 +1287,14 @@ const puvox_library =
1287
1287
  return obj1;
1288
1288
  },
1289
1289
 
1290
+ // returns a new object with the values at each key mapped using mapFn(value)
1291
+ objectMap(obj, fn) {
1292
+ return Object.fromEntries(
1293
+ Object.entries(obj).map(
1294
+ ([k, v], i) => [k, fn(v, k, i)]
1295
+ )
1296
+ )
1297
+ },
1290
1298
 
1291
1299
  fancyTimeFormat(time)
1292
1300
  {
@@ -1473,7 +1481,7 @@ const puvox_library =
1473
1481
  },
1474
1482
 
1475
1483
  // https://stackoverflow.com/a/41407246/2377343
1476
- consoleLogColor (text, color, backgroundOrForeground = false) {
1484
+ consoleLogColor (text, backgroundColor=null, foregroundColor=null) {
1477
1485
  const prefix = '\x1b[';
1478
1486
  const suffix = 'm';
1479
1487
  const objectTree = {
@@ -1481,8 +1489,15 @@ const puvox_library =
1481
1489
  foreground: { black: "30", red: "31", green: "32", yellow: "33", blue: "34", magenta: "35", cyan: "36", white: "37", },
1482
1490
  background: { black: "40", red: "41", green: "42", yellow: "43", blue: "44", magenta: "45", cyan: "46", white: "47", }
1483
1491
  };
1484
- const bfKeyname = backgroundOrForeground ? 'background' : 'foreground';
1485
- console.log (prefix + objectTree[bfKeyname][color] + suffix + "%s" + prefix + objectTree.types.reset + suffix, text);
1492
+ let backColorString = '';
1493
+ let foreColorString = '';
1494
+ if (backgroundColor) {
1495
+ backColorString = prefix + objectTree['background'][backgroundColor] + suffix;
1496
+ }
1497
+ if (foregroundColor) {
1498
+ foreColorString = prefix + objectTree['foreground'][foregroundColor] + suffix;
1499
+ }
1500
+ console.log (backColorString + foreColorString + "%s" + prefix + objectTree.types.reset + suffix, text);
1486
1501
  },
1487
1502
 
1488
1503
  toggleWindowsMessages_WindowConfirm() { return window.confirm },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "puvox-library",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "library-class-javascript",
5
5
  "main": "library_standard.js",
6
6
  "scripts": {