@ezs/basics 2.4.0 → 2.5.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/CHANGELOG.md CHANGED
@@ -3,6 +3,28 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.5.0](https://github.com/Inist-CNRS/ezs/compare/@ezs/basics@2.4.1...@ezs/basics@2.5.0) (2023-08-18)
7
+
8
+
9
+ ### Features
10
+
11
+ * 🎸 support text files ([2ba8571](https://github.com/Inist-CNRS/ezs/commit/2ba8571dbd651849ab12c4c08627ff29019e3c7f))
12
+
13
+
14
+
15
+
16
+
17
+ ## [2.4.1](https://github.com/Inist-CNRS/ezs/compare/@ezs/basics@2.4.0...@ezs/basics@2.4.1) (2023-07-20)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * 🐛 manifest.json ([559cda8](https://github.com/Inist-CNRS/ezs/commit/559cda8372c65c3c1cfb5a0dcfee404ece4a79d6))
23
+
24
+
25
+
26
+
27
+
6
28
  # [2.4.0](https://github.com/Inist-CNRS/ezs/compare/@ezs/basics@2.3.0...@ezs/basics@2.4.0) (2023-07-17)
7
29
 
8
30
 
package/README.md CHANGED
@@ -551,7 +551,8 @@ Take all recevied objects and build a tar file
551
551
 
552
552
  - `manifest` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Location path to store files in the tarball
553
553
  - `location` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Location path to store files in the tarball (optional, default `data`)
554
- - `json` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Parse as JSON the content of each file (optional, default `true`)
554
+ - `json` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Convert to JSON the content of each chunk (optional, default `true`)
555
+ - `extension` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Choose extension fo each file (optional, default `json`)
555
556
  - `compress` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Enable gzip compression (optional, default `false`)
556
557
 
557
558
  ### TARExtract
package/lib/tar-dump.js CHANGED
@@ -25,7 +25,8 @@ const eol = '\n';
25
25
  * @name TARDump
26
26
  * @param {String} [manifest] Location path to store files in the tarball
27
27
  * @param {String} [location=data] Location path to store files in the tarball
28
- * @param {String} [json=true] Parse as JSON the content of each file
28
+ * @param {String} [json=true] Convert to JSON the content of each chunk
29
+ * @param {String} [extension=json] Choose extension fo each file
29
30
  * @param {Boolean} [compress=false] Enable gzip compression
30
31
  */
31
32
 
@@ -33,27 +34,35 @@ function TARDump(data, feed) {
33
34
  if (!this.pack) {
34
35
  this.pack = _tarStream.default.pack();
35
36
  const compress = this.getParam('compress', false);
36
- const d = new Date();
37
- const manifest = (0, _lodash.default)({
38
- created: d.toUTCString()
39
- }, [].concat(this.getParam('manifest', [])).filter(Boolean));
40
- this.pack.entry({
41
- name: 'manifest.json'
42
- }, JSON.stringify(manifest, null, ' '));
37
+ this.created = new Date();
43
38
  const stream = compress ? this.pack.pipe((0, _zlib.createGzip)()) : this.pack;
44
39
  feed.flow(stream).finally(() => feed.close());
45
40
  }
46
41
 
47
42
  if (this.isLast()) {
43
+ const updated = new Date();
44
+ const metadata = {
45
+ 'creationDate': this.created.toUTCString(),
46
+ 'updateDate': updated.toUTCString(),
47
+ 'itemsCounter': this.getIndex() - 1,
48
+ 'processingMSTime': this.getCumulativeTimeMS()
49
+ };
50
+ const manifestArray = [metadata].concat(this.getParam('manifest', [])).filter(Boolean);
51
+ const manifest = (0, _lodash.default)(...manifestArray);
52
+ this.pack.entry({
53
+ name: 'manifest.json'
54
+ }, JSON.stringify(manifest, null, ' '));
48
55
  this.pack.finalize();
49
56
  return;
50
57
  }
51
58
 
59
+ const json = this.getParam('json', true);
60
+ const extension = this.getParam('extension', 'json');
52
61
  const id = this.getIndex().toString().padStart(10, '0');
53
- const value = JSON.stringify(data).concat(eol);
62
+ const value = json ? JSON.stringify(data).concat(eol) : data;
54
63
  const location = this.getParam('location', 'data');
55
64
  this.pack.entry({
56
- name: `${location}/f${id}.json`
65
+ name: `${location}/f${id}.${extension}`
57
66
  }, value);
58
67
  feed.end();
59
68
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ezs/basics",
3
3
  "description": "Basics statements for EZS",
4
- "version": "2.4.0",
4
+ "version": "2.5.0",
5
5
  "author": "Nicolas Thouvenin <nthouvenin@gmail.com>",
6
6
  "bugs": "https://github.com/Inist-CNRS/ezs/issues",
7
7
  "dependencies": {
@@ -42,7 +42,7 @@
42
42
  "directories": {
43
43
  "test": "test"
44
44
  },
45
- "gitHead": "313d6ef24c4b958533685a198a090b7ecd2b33b9",
45
+ "gitHead": "c2694cd502cc4daaf7b9faa74eca46f7893771d8",
46
46
  "homepage": "https://github.com/Inist-CNRS/ezs/tree/master/packages/basics#readme",
47
47
  "keywords": [
48
48
  "ezs"