@qingfu/core-env 0.2.2 → 0.2.4
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/utils.js +7 -7
- package/package.json +4 -4
package/lib/utils.js
CHANGED
|
@@ -8,14 +8,14 @@ const qrcode = require( 'qr-image' );
|
|
|
8
8
|
const request = require( 'superagent' );
|
|
9
9
|
const utils = global.utils = module.exports = {};
|
|
10
10
|
|
|
11
|
-
utils.xml2json = async xml => {
|
|
12
|
-
|
|
13
|
-
var parser = new xml2js.Parser(
|
|
11
|
+
utils.xml2json = async ( xml, opts ) => {
|
|
12
|
+
if ( !opts ) opts = { explicitRoot: false, explicitArray: false };
|
|
13
|
+
var parser = new xml2js.Parser( opts );
|
|
14
14
|
return await parser.parseStringPromise( xml );
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
utils.json2xml = json => {
|
|
18
|
-
let builder = new xml2js.Builder();
|
|
17
|
+
utils.json2xml = ( json, opts ) => {
|
|
18
|
+
let builder = new xml2js.Builder( opts );
|
|
19
19
|
return builder.buildObject( json );
|
|
20
20
|
};
|
|
21
21
|
|
|
@@ -34,11 +34,11 @@ utils.json2sheet = ( json, mapping ) => {
|
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
utils.sheet2xlsx = ( data, type = 'xlsx', wch = 30 ) => {
|
|
37
|
-
let ws = xlsx.utils.aoa_to_sheet( data );
|
|
37
|
+
let ws = xlsx.utils.aoa_to_sheet( data, { dense: true });
|
|
38
38
|
ws[ '!cols' ] = data[ 0 ].map( v => ({ wch }));
|
|
39
39
|
let wb = xlsx.utils.book_new();
|
|
40
40
|
xlsx.utils.book_append_sheet( wb, ws, 'Sheet1' );
|
|
41
|
-
return { buffer: xlsx.write( wb, { bookType: type, type: 'buffer' })};
|
|
41
|
+
return { buffer: xlsx.write( wb, { bookType: type, type: 'buffer', compression: true })};
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
utils.json2xlsx = ( json, mapping, type ) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qingfu/core-env",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"readmeFilename": "README.md",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@koa/cors": "4.0.0",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"koa-qs": "3.0.0",
|
|
22
22
|
"lodash": "4.17.21",
|
|
23
23
|
"moleculer": "0.14.29",
|
|
24
|
-
"mongoose": "7.
|
|
24
|
+
"mongoose": "7.2.4",
|
|
25
25
|
"mongoose-cast-aggregation": "0.3.1",
|
|
26
26
|
"mongoose-geojson-schema": "2.2.4",
|
|
27
27
|
"mongoose-lean-defaults": "2.2.1",
|
|
28
|
-
"mongoose-lean-getters": "
|
|
28
|
+
"mongoose-lean-getters": "1.1.0",
|
|
29
29
|
"mongoose-lean-virtuals": "0.9.1",
|
|
30
30
|
"ms": "2.1.3",
|
|
31
31
|
"notepack.io": "3.0.1",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"qr-image": "3.2.0",
|
|
36
36
|
"superagent": "8.0.9",
|
|
37
37
|
"wechat-encrypt": "1.1.1",
|
|
38
|
-
"winston": "3.
|
|
38
|
+
"winston": "3.9.0",
|
|
39
39
|
"winston-mongodb": "5.1.1",
|
|
40
40
|
"xlsx": "0.18.5",
|
|
41
41
|
"xml2js": "0.4.23"
|