puvox-library 1.0.3 → 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.
- package/library_standard.js +24 -9
- package/package.json +1 -1
package/library_standard.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
/**
|
2
2
|
*
|
3
|
-
*
|
4
|
-
*
|
5
|
-
*
|
6
|
-
*
|
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();
|
@@ -1202,7 +1202,7 @@ const puvox_library =
|
|
1202
1202
|
} ,
|
1203
1203
|
|
1204
1204
|
// more from locutus: https://github.com/locutusjs/locutus/blob/master/src/php
|
1205
|
-
|
1205
|
+
stripTags (input, allowed) {
|
1206
1206
|
allowed = (((allowed || '') + '').toLowerCase().match(/<[a-z][a-z0-9]*>/g) || []).join('');
|
1207
1207
|
const tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>/gi;
|
1208
1208
|
const commentsAndPhpTags = /<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi;
|
@@ -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,
|
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
|
-
|
1485
|
-
|
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 },
|