@reldens/utils 0.35.0 → 0.37.0
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/lib/logger.js +2 -1
- package/lib/shortcuts.js +16 -1
- package/package.json +2 -2
package/lib/logger.js
CHANGED
|
@@ -50,7 +50,8 @@ class Logger
|
|
|
50
50
|
|
|
51
51
|
log(levelLabel, ...args)
|
|
52
52
|
{
|
|
53
|
-
|
|
53
|
+
let date = (new Date()).toISOString().slice(0, 19).replace('T', ' ')+' - ';
|
|
54
|
+
console.log(date+levelLabel.toUpperCase()+' -', ...args);
|
|
54
55
|
if(-1 !== this.enableTraceFor().indexOf('all') || -1 !== this.enableTraceFor().indexOf(levelLabel)){
|
|
55
56
|
if('function' !== typeof Error?.captureStackTrace){
|
|
56
57
|
console.log('Error.captureStackTrace is not available.', typeof Error?.captureStackTrace);
|
package/lib/shortcuts.js
CHANGED
|
@@ -129,11 +129,26 @@ class Shortcuts
|
|
|
129
129
|
|
|
130
130
|
sortObjectKeysBy(obj, sortField)
|
|
131
131
|
{
|
|
132
|
-
return Object.keys(obj).sort((a,b) => {
|
|
132
|
+
return Object.keys(obj).sort((a, b) => {
|
|
133
133
|
return (obj[a][sortField] > obj[b][sortField]) ? 1 : -1;
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
arraySort(collection, sortField, direction = 'asc')
|
|
138
|
+
{
|
|
139
|
+
if(!collection){
|
|
140
|
+
return collection;
|
|
141
|
+
}
|
|
142
|
+
if(!sortField){
|
|
143
|
+
return collection;
|
|
144
|
+
}
|
|
145
|
+
let directionValue = 'act' === direction ? 1 : -1;
|
|
146
|
+
let directionOpposite = 'act' === direction ? -1 : 1;
|
|
147
|
+
return collection.sort((a, b) => {
|
|
148
|
+
return a[sortField] > b[sortField] ? directionValue : directionOpposite;
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
137
152
|
propsAssign(from, to, props)
|
|
138
153
|
{
|
|
139
154
|
if(!this.isArray(props)){
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reldens/utils",
|
|
3
3
|
"scope": "@reldens",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.37.0",
|
|
5
5
|
"description": "Reldens - Utils",
|
|
6
6
|
"author": "Damian A. Pastorini",
|
|
7
7
|
"license": "MIT",
|
|
@@ -35,6 +35,6 @@
|
|
|
35
35
|
"url": "https://github.com/damian-pastorini/reldens-utils/issues"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"await-event-emitter": "
|
|
38
|
+
"await-event-emitter": "2.0.2"
|
|
39
39
|
}
|
|
40
40
|
}
|