excellentexport 3.9.9 → 3.9.10

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,74 +1,74 @@
1
- const assert = require('assert');
2
-
3
- import ExcellentExport, { ConvertOptions } from '../src/excellentexport';
4
-
5
-
6
- describe('Fix data', function() {
7
- beforeEach(() => {
8
- window.URL.createObjectURL = () => "blob:fake_URL";
9
-
10
- document.body.innerHTML = '';
11
- const element = document.createElement("div");
12
- element.innerHTML = '<a id="anchor">Link</a>';
13
-
14
- document.body.appendChild(element);
15
- });
16
-
17
- it('should fix values', function() {
18
- const options = {
19
- anchor: 'anchor',
20
- filename: 'data_from_array',
21
- format: 'xlsx'
22
- } as ConvertOptions;
23
-
24
- const sheets = [
25
- {
26
- name: 'Sheet Name Here 1',
27
- from: {
28
- array: [
29
- ['hello', '<td>hello</td>', 'bye'],
30
- ]
31
- },
32
- fixValue: (value, row, col) => {
33
- let v = value.replace(/<br>/gi, "\n");
34
- let strippedString = v.replace(/(<([^>]+)>)/gi, "");
35
- return strippedString;
36
- }
37
- }
38
- ];
39
-
40
- const workbook = ExcellentExport.convert(options, sheets);
41
- assert.ok(workbook, 'Result must not be null');
42
- });
43
-
44
- it('should process the whole array', function() {
45
- const options = {
46
- anchor: 'anchor',
47
- filename: 'data_from_array',
48
- format: 'xlsx'
49
- } as ConvertOptions;
50
-
51
- const sheets = [
52
- {
53
- name: 'Sheet Name Here 1',
54
- from: {
55
- array: [
56
- ['hello', '<td>hello</td>', 'bye'],
57
- ]
58
- },
59
- fixData: (array) => {
60
- return array.map(r => {
61
- return r.map(v => {
62
- return "fixed-" + v;
63
- })
64
- });
65
- }
66
- }
67
- ];
68
-
69
- const workbook = ExcellentExport.convert(options, sheets);
70
- assert.ok(workbook, 'Result must not be null');
71
- });
72
-
73
- });
74
-
1
+ const assert = require('assert');
2
+
3
+ import ExcellentExport, { ConvertOptions } from '../src/excellentexport';
4
+
5
+
6
+ describe('Fix data', function() {
7
+ beforeEach(() => {
8
+ window.URL.createObjectURL = () => "blob:fake_URL";
9
+
10
+ document.body.innerHTML = '';
11
+ const element = document.createElement("div");
12
+ element.innerHTML = '<a id="anchor">Link</a>';
13
+
14
+ document.body.appendChild(element);
15
+ });
16
+
17
+ it('should fix values', function() {
18
+ const options = {
19
+ anchor: 'anchor',
20
+ filename: 'data_from_array',
21
+ format: 'xlsx'
22
+ } as ConvertOptions;
23
+
24
+ const sheets = [
25
+ {
26
+ name: 'Sheet Name Here 1',
27
+ from: {
28
+ array: [
29
+ ['hello', '<td>hello</td>', 'bye'],
30
+ ]
31
+ },
32
+ fixValue: (value, row, col) => {
33
+ let v = value.replace(/<br>/gi, "\n");
34
+ let strippedString = v.replace(/(<([^>]+)>)/gi, "");
35
+ return strippedString;
36
+ }
37
+ }
38
+ ];
39
+
40
+ const workbook = ExcellentExport.convert(options, sheets);
41
+ assert.ok(workbook, 'Result must not be null');
42
+ });
43
+
44
+ it('should process the whole array', function() {
45
+ const options = {
46
+ anchor: 'anchor',
47
+ filename: 'data_from_array',
48
+ format: 'xlsx'
49
+ } as ConvertOptions;
50
+
51
+ const sheets = [
52
+ {
53
+ name: 'Sheet Name Here 1',
54
+ from: {
55
+ array: [
56
+ ['hello', '<td>hello</td>', 'bye'],
57
+ ]
58
+ },
59
+ fixData: (array) => {
60
+ return array.map(r => {
61
+ return r.map(v => {
62
+ return "fixed-" + v;
63
+ })
64
+ });
65
+ }
66
+ }
67
+ ];
68
+
69
+ const workbook = ExcellentExport.convert(options, sheets);
70
+ assert.ok(workbook, 'Result must not be null');
71
+ });
72
+
73
+ });
74
+
@@ -1,29 +1,29 @@
1
- const assert = require('assert');
2
-
3
- import * as utils from '../src/utils';
4
-
5
-
6
- describe('Test utility functions', () => {
7
-
8
- describe('base64', () => {
9
- it('should encode a string to base64', () => {
10
- assert.equal(utils.base64('test'), 'dGVzdA==');
11
- });
12
-
13
- it('should encode a unicode string to base64', () => {
14
- assert.equal(utils.base64('test\u00A9'), "dGVzdMKp");
15
- });
16
-
17
- });
18
-
19
-
20
- describe('test format function', () => {
21
- it('should format a string', () => {
22
- assert.equal(utils.format('aaaa {a} bbbb {b} cccc', {a:'1', b:'2', c:'3', d:'4'}), 'aaaa 1 bbbb 2 cccc');
23
- });
24
-
25
- it('should not replace if no data is provided', () => {
26
- assert.equal(utils.format('aaaa {a} bbbb {b} cccc', {}), 'aaaa {a} bbbb {b} cccc');
27
- });
28
- });
29
- });
1
+ const assert = require('assert');
2
+
3
+ import * as utils from '../src/utils';
4
+
5
+
6
+ describe('Test utility functions', () => {
7
+
8
+ describe('base64', () => {
9
+ it('should encode a string to base64', () => {
10
+ assert.equal(utils.base64('test'), 'dGVzdA==');
11
+ });
12
+
13
+ it('should encode a unicode string to base64', () => {
14
+ assert.equal(utils.base64('test\u00A9'), "dGVzdMKp");
15
+ });
16
+
17
+ });
18
+
19
+
20
+ describe('test format function', () => {
21
+ it('should format a string', () => {
22
+ assert.equal(utils.format('aaaa {a} bbbb {b} cccc', {a:'1', b:'2', c:'3', d:'4'}), 'aaaa 1 bbbb 2 cccc');
23
+ });
24
+
25
+ it('should not replace if no data is provided', () => {
26
+ assert.equal(utils.format('aaaa {a} bbbb {b} cccc', {}), 'aaaa {a} bbbb {b} cccc');
27
+ });
28
+ });
29
+ });
@@ -1,24 +1,24 @@
1
- const assert = require('assert');
2
-
3
- import { fixCSVField } from '../src/utils';
4
-
5
-
6
- describe('Test utility functions: csv functions', () => {
7
-
8
- it('should keep the value if not delimiter found', () => {
9
- assert.equal(fixCSVField('test', ','), 'test');
10
- });
11
-
12
- it('should fix a string with double quotes', () => {
13
- const str = 'aaa"bbb';
14
- const result = fixCSVField(str, "\"");
15
- assert.equal(result, '\"aaa\"\"bbb\"');
16
- });
17
-
18
- it('should fix a field with space delimiter', () => {
19
- const str = 'aaa bbb';
20
- const result = fixCSVField(str, " ");
21
- assert.equal(result, '\"aaa bbb\"');
22
- });
23
-
24
- });
1
+ const assert = require('assert');
2
+
3
+ import { fixCSVField } from '../src/utils';
4
+
5
+
6
+ describe('Test utility functions: csv functions', () => {
7
+
8
+ it('should keep the value if not delimiter found', () => {
9
+ assert.equal(fixCSVField('test', ','), 'test');
10
+ });
11
+
12
+ it('should fix a string with double quotes', () => {
13
+ const str = 'aaa"bbb';
14
+ const result = fixCSVField(str, "\"");
15
+ assert.equal(result, '\"aaa\"\"bbb\"');
16
+ });
17
+
18
+ it('should fix a field with space delimiter', () => {
19
+ const str = 'aaa bbb';
20
+ const result = fixCSVField(str, " ");
21
+ assert.equal(result, '\"aaa bbb\"');
22
+ });
23
+
24
+ });
@@ -1,98 +1,98 @@
1
- const assert = require('assert');
2
-
3
- import { removeColumns } from '../src/utils';
4
-
5
-
6
- describe('Test utility functions: removeColumns', () => {
7
-
8
- it('should remove one column correctly', function() {
9
- const columns = [
10
- ['a', 'b', 'c'],
11
- ['d', 'e', 'f'],
12
- ['g', 'h', 'i'],
13
- ];
14
-
15
- removeColumns(columns, [0]);
16
- expect(columns.length).toEqual(3)
17
- expect(columns[0]).toStrictEqual(['b', 'c']);
18
- expect(columns[1]).toStrictEqual(['e', 'f']);
19
- expect(columns[2]).toStrictEqual(['h', 'i']);
20
- });
21
-
22
- it('should remove two columns', () => {
23
- const columns = [
24
- ['a', 'b', 'c'],
25
- ['d', 'e', 'f'],
26
- ['g', 'h', 'i'],
27
- ];
28
-
29
- removeColumns(columns, [0, 1]);
30
- expect(columns.length).toEqual(3)
31
- expect(columns[0]).toStrictEqual(['c']);
32
- expect(columns[1]).toStrictEqual(['f']);
33
- });
34
-
35
- it('should remove the last column', () => {
36
- const columns = [
37
- ['a', 'b', 'c'],
38
- ['d', 'e', 'f'],
39
- ['g', 'h', 'i'],
40
- ];
41
-
42
- removeColumns(columns, [2]);
43
- expect(columns.length).toEqual(3)
44
- expect(columns[0]).toStrictEqual(['a', 'b']);
45
- expect(columns[1]).toStrictEqual(['d', 'e']);
46
- expect(columns[2]).toStrictEqual(['g', 'h']);
47
- });
48
-
49
- it('should skip if remove out of range', () => {
50
- const columns = [
51
- ['a', 'b', 'c'],
52
- ['d', 'e', 'f'],
53
- ['g', 'h', 'i'],
54
- ];
55
-
56
- removeColumns(columns, [99]);
57
- expect(columns.length).toEqual(3);
58
- expect(columns[0]).toEqual(['a', 'b', 'c']);
59
- });
60
-
61
- it('should skip if remove out of range', () => {
62
- const columns = [
63
- ['a', 'b', 'c'],
64
- ['d', 'e', 'f'],
65
- ['g', 'h', 'i'],
66
- ];
67
-
68
- removeColumns(columns, [0, 99]);
69
- expect(columns.length).toEqual(3);
70
- expect(columns[0]).toEqual(['b', 'c']);
71
- });
72
-
73
- it('should not remove repeated columns', () => {
74
- const columns = [
75
- ['a', 'b', 'c'],
76
- ['d', 'e', 'f'],
77
- ['g', 'h', 'i'],
78
- ];
79
-
80
- removeColumns(columns, [0, 0]);
81
- expect(columns.length).toEqual(3);
82
- expect(columns[0]).toEqual(['b', 'c']);
83
- });
84
-
85
- it('should remove columns in the correct order', () => {
86
- const columns = [
87
- ['a', 'b', 'c'],
88
- ['d', 'e', 'f'],
89
- ['g', 'h', 'i'],
90
- ];
91
-
92
- removeColumns(columns, [0, 2]);
93
- expect(columns.length).toEqual(3);
94
- expect(columns[0]).toEqual(['b']);
95
- expect(columns[1]).toEqual(['e']);
96
- });
97
-
98
- });
1
+ const assert = require('assert');
2
+
3
+ import { removeColumns } from '../src/utils';
4
+
5
+
6
+ describe('Test utility functions: removeColumns', () => {
7
+
8
+ it('should remove one column correctly', function() {
9
+ const columns = [
10
+ ['a', 'b', 'c'],
11
+ ['d', 'e', 'f'],
12
+ ['g', 'h', 'i'],
13
+ ];
14
+
15
+ removeColumns(columns, [0]);
16
+ expect(columns.length).toEqual(3)
17
+ expect(columns[0]).toStrictEqual(['b', 'c']);
18
+ expect(columns[1]).toStrictEqual(['e', 'f']);
19
+ expect(columns[2]).toStrictEqual(['h', 'i']);
20
+ });
21
+
22
+ it('should remove two columns', () => {
23
+ const columns = [
24
+ ['a', 'b', 'c'],
25
+ ['d', 'e', 'f'],
26
+ ['g', 'h', 'i'],
27
+ ];
28
+
29
+ removeColumns(columns, [0, 1]);
30
+ expect(columns.length).toEqual(3)
31
+ expect(columns[0]).toStrictEqual(['c']);
32
+ expect(columns[1]).toStrictEqual(['f']);
33
+ });
34
+
35
+ it('should remove the last column', () => {
36
+ const columns = [
37
+ ['a', 'b', 'c'],
38
+ ['d', 'e', 'f'],
39
+ ['g', 'h', 'i'],
40
+ ];
41
+
42
+ removeColumns(columns, [2]);
43
+ expect(columns.length).toEqual(3)
44
+ expect(columns[0]).toStrictEqual(['a', 'b']);
45
+ expect(columns[1]).toStrictEqual(['d', 'e']);
46
+ expect(columns[2]).toStrictEqual(['g', 'h']);
47
+ });
48
+
49
+ it('should skip if remove out of range', () => {
50
+ const columns = [
51
+ ['a', 'b', 'c'],
52
+ ['d', 'e', 'f'],
53
+ ['g', 'h', 'i'],
54
+ ];
55
+
56
+ removeColumns(columns, [99]);
57
+ expect(columns.length).toEqual(3);
58
+ expect(columns[0]).toEqual(['a', 'b', 'c']);
59
+ });
60
+
61
+ it('should skip if remove out of range', () => {
62
+ const columns = [
63
+ ['a', 'b', 'c'],
64
+ ['d', 'e', 'f'],
65
+ ['g', 'h', 'i'],
66
+ ];
67
+
68
+ removeColumns(columns, [0, 99]);
69
+ expect(columns.length).toEqual(3);
70
+ expect(columns[0]).toEqual(['b', 'c']);
71
+ });
72
+
73
+ it('should not remove repeated columns', () => {
74
+ const columns = [
75
+ ['a', 'b', 'c'],
76
+ ['d', 'e', 'f'],
77
+ ['g', 'h', 'i'],
78
+ ];
79
+
80
+ removeColumns(columns, [0, 0]);
81
+ expect(columns.length).toEqual(3);
82
+ expect(columns[0]).toEqual(['b', 'c']);
83
+ });
84
+
85
+ it('should remove columns in the correct order', () => {
86
+ const columns = [
87
+ ['a', 'b', 'c'],
88
+ ['d', 'e', 'f'],
89
+ ['g', 'h', 'i'],
90
+ ];
91
+
92
+ removeColumns(columns, [0, 2]);
93
+ expect(columns.length).toEqual(3);
94
+ expect(columns[0]).toEqual(['b']);
95
+ expect(columns[1]).toEqual(['e']);
96
+ });
97
+
98
+ });
package/tsconfig.json CHANGED
@@ -1,17 +1,17 @@
1
- {
2
- "compilerOptions": {
3
- "outDir": "./dist",
4
- "allowJs": true,
5
- "target": "ESNext",
6
- "sourceMap": true,
7
- "removeComments": false,
8
- "declaration": true,
9
- "rootDir": "src",
10
- "moduleResolution": "node",
11
- "esModuleInterop": true
12
- },
13
- "include": [
14
- "src/**/*.ts",
15
- "test/**/*.{ts,js}"
16
- ]
17
- }
1
+ {
2
+ "compilerOptions": {
3
+ "outDir": "./dist",
4
+ "allowJs": true,
5
+ "target": "ESNext",
6
+ "sourceMap": true,
7
+ "removeComments": false,
8
+ "declaration": true,
9
+ "rootDir": "src",
10
+ "moduleResolution": "node",
11
+ "esModuleInterop": true
12
+ },
13
+ "include": [
14
+ "src/**/*.ts",
15
+ "test/**/*.{ts,js}"
16
+ ]
17
+ }