@mixd-id/web-scaffold 0.1.240411108 → 0.1.240411109
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/package.json
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
for (const key in obj) {
|
|
3
|
-
if (typeof obj[key] === 'string') {
|
|
4
|
-
obj[key] = obj[key].trim();
|
|
5
|
-
} else if (typeof obj[key] === 'object') {
|
|
6
|
-
trimStrings(obj[key]);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
}
|
|
1
|
+
const { trimStrings } = require('../../utils/helpers')
|
|
10
2
|
|
|
11
3
|
module.exports = async function(req, res, next){
|
|
12
4
|
|
package/src/utils/helpers.cjs
CHANGED
|
@@ -598,6 +598,21 @@ const groupBy = (arr, key) => {
|
|
|
598
598
|
}, {});
|
|
599
599
|
}
|
|
600
600
|
|
|
601
|
+
// Trims string values of an object/array in place (recursive), skips Buffers/typed arrays
|
|
602
|
+
const trimStrings = (obj) => {
|
|
603
|
+
if(!obj || typeof obj !== 'object' || ArrayBuffer.isView(obj)) return obj
|
|
604
|
+
|
|
605
|
+
for(const key in obj){
|
|
606
|
+
const value = obj[key]
|
|
607
|
+
if(typeof value === 'string')
|
|
608
|
+
obj[key] = value.trim()
|
|
609
|
+
else if(value && typeof value === 'object')
|
|
610
|
+
trimStrings(value)
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
return obj
|
|
614
|
+
}
|
|
615
|
+
|
|
601
616
|
module.exports = {
|
|
602
617
|
capitalize,
|
|
603
618
|
ceil,
|
|
@@ -631,5 +646,6 @@ module.exports = {
|
|
|
631
646
|
hashMake,
|
|
632
647
|
hashCheck,
|
|
633
648
|
transactionWithRetry,
|
|
634
|
-
groupBy
|
|
649
|
+
groupBy,
|
|
650
|
+
trimStrings
|
|
635
651
|
}
|
package/src/utils/helpers.js
CHANGED
|
@@ -598,6 +598,21 @@ const groupBy = (arr, key) => {
|
|
|
598
598
|
}, {});
|
|
599
599
|
}
|
|
600
600
|
|
|
601
|
+
// Trims string values of an object/array in place (recursive), skips Buffers/typed arrays
|
|
602
|
+
const trimStrings = (obj) => {
|
|
603
|
+
if(!obj || typeof obj !== 'object' || ArrayBuffer.isView(obj)) return obj
|
|
604
|
+
|
|
605
|
+
for(const key in obj){
|
|
606
|
+
const value = obj[key]
|
|
607
|
+
if(typeof value === 'string')
|
|
608
|
+
obj[key] = value.trim()
|
|
609
|
+
else if(value && typeof value === 'object')
|
|
610
|
+
trimStrings(value)
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
return obj
|
|
614
|
+
}
|
|
615
|
+
|
|
601
616
|
module.exports = {
|
|
602
617
|
capitalize,
|
|
603
618
|
ceil,
|
|
@@ -631,5 +646,6 @@ module.exports = {
|
|
|
631
646
|
hashMake,
|
|
632
647
|
hashCheck,
|
|
633
648
|
transactionWithRetry,
|
|
634
|
-
groupBy
|
|
649
|
+
groupBy,
|
|
650
|
+
trimStrings
|
|
635
651
|
}
|
package/src/utils/helpers.mjs
CHANGED
|
@@ -510,6 +510,21 @@ const groupBy = (arr, key) => {
|
|
|
510
510
|
}, {});
|
|
511
511
|
}
|
|
512
512
|
|
|
513
|
+
// Trims string values of an object/array in place (recursive), skips Buffers/typed arrays
|
|
514
|
+
const trimStrings = (obj) => {
|
|
515
|
+
if(!obj || typeof obj !== 'object' || ArrayBuffer.isView(obj)) return obj
|
|
516
|
+
|
|
517
|
+
for(const key in obj){
|
|
518
|
+
const value = obj[key]
|
|
519
|
+
if(typeof value === 'string')
|
|
520
|
+
obj[key] = value.trim()
|
|
521
|
+
else if(value && typeof value === 'object')
|
|
522
|
+
trimStrings(value)
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
return obj
|
|
526
|
+
}
|
|
527
|
+
|
|
513
528
|
const arrayPush = (arr, items, opt = { update:true }) => {
|
|
514
529
|
if(!Array.isArray(arr)) return
|
|
515
530
|
if(!Array.isArray(items)) items = [ items ]
|
|
@@ -653,6 +668,7 @@ export {
|
|
|
653
668
|
queueForLaterWithKey,
|
|
654
669
|
transactionWithRetry,
|
|
655
670
|
groupBy,
|
|
671
|
+
trimStrings,
|
|
656
672
|
arrayPush,
|
|
657
673
|
arrayRemove,
|
|
658
674
|
arrayUnshift,
|
package/src/utils/importer.js
CHANGED
|
@@ -3,7 +3,7 @@ const fs = require("fs");
|
|
|
3
3
|
const AdmZip = require("adm-zip");
|
|
4
4
|
const glob = require("glob");
|
|
5
5
|
const Exceljs = require("exceljs")
|
|
6
|
-
const { saveBuffer, unflatten } = require('./helpers.js')
|
|
6
|
+
const { saveBuffer, unflatten, trimStrings } = require('./helpers.js')
|
|
7
7
|
|
|
8
8
|
const getCellText = (cell, image) => {
|
|
9
9
|
if(!cell) return image?.buffer ?? ''
|
|
@@ -259,7 +259,7 @@ const importRequest = async(req) => {
|
|
|
259
259
|
//Object.assign(obj, row)
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
rows.push(unflatten(obj))
|
|
262
|
+
rows.push(trimStrings(unflatten(obj)))
|
|
263
263
|
}
|
|
264
264
|
|
|
265
265
|
Object.assign(doc, {
|