@ezs/basics 2.2.0 → 2.4.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.4.0](https://github.com/Inist-CNRS/ezs/compare/@ezs/basics@2.3.0...@ezs/basics@2.4.0) (2023-07-17)
7
+
8
+
9
+ ### Features
10
+
11
+ * 🎸 add [TARDump] ([d3ff2a9](https://github.com/Inist-CNRS/ezs/commit/d3ff2a99650fc7c9eacd2c1ad015d9907addeebb))
12
+
13
+
14
+
15
+
16
+
17
+ # [2.3.0](https://github.com/Inist-CNRS/ezs/compare/@ezs/basics@2.2.0...@ezs/basics@2.3.0) (2023-06-23)
18
+
19
+
20
+ ### Features
21
+
22
+ * **strings:** Add inflection and sentences statements ([67ba36c](https://github.com/Inist-CNRS/ezs/commit/67ba36c8ba68c1798f5430a087172fed45d2b3c0))
23
+
24
+
25
+
26
+
27
+
6
28
  # [2.2.0](https://github.com/Inist-CNRS/ezs/compare/@ezs/basics@2.1.3...@ezs/basics@2.2.0) (2023-06-22)
7
29
 
8
30
 
package/README.md CHANGED
@@ -27,6 +27,7 @@ npm install @ezs/basics
27
27
  - [OBJFlatten](#objflatten)
28
28
  - [OBJNamespaces](#objnamespaces)
29
29
  - [OBJStandardize](#objstandardize)
30
+ - [TARDump](#tardump)
30
31
  - [TARExtract](#tarextract)
31
32
  - [TXTConcat](#txtconcat)
32
33
  - [TXTInflection](#txtinflection)
@@ -537,6 +538,22 @@ Output:
537
538
 
538
539
  Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
539
540
 
541
+ ### TARDump
542
+
543
+ Take all recevied objects and build a tar file
544
+
545
+ ```json
546
+ {
547
+ }
548
+ ```
549
+
550
+ #### Parameters
551
+
552
+ - `manifest` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Location path to store files in the tarball
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`)
555
+ - `compress` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Enable gzip compression (optional, default `false`)
556
+
540
557
  ### TARExtract
541
558
 
542
559
  Take the content of a tar file, extract some files.
@@ -582,9 +599,6 @@ Returns **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
582
599
 
583
600
  ### TXTInflection
584
601
 
585
- - **See: <https://www.npmjs.com/package/inflection>
586
- **
587
-
588
602
  Take a `String` and inflect it with or more transformers from this list
589
603
  pluralize, singularize, camelize, underscore, humanize, capitalize,
590
604
  dasherize, titleize, demodulize, tableize, classify, foreign_key, ordinalize
@@ -617,6 +631,12 @@ Output:
617
631
 
618
632
  Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>**
619
633
 
634
+ **Meta**
635
+
636
+ - **deprecated**: see <https://inist-cnrs.github.io/ezs/#/plugin-strings?id=inflection>
637
+ see <https://www.npmjs.com/package/inflection>
638
+
639
+
620
640
  ### TXTObject
621
641
 
622
642
  Take an array of values and generate an array containing objects with the
@@ -684,6 +704,11 @@ Output:
684
704
 
685
705
  Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>**
686
706
 
707
+ **Meta**
708
+
709
+ - **deprecated**: see <https://inist-cnrs.github.io/ezs/#/plugin-strings?id=sentences>
710
+
711
+
687
712
  ### TXTZip
688
713
 
689
714
  Take a `String` and zip it.
package/lib/index.js CHANGED
@@ -61,6 +61,8 @@ var _zipExtract = _interopRequireDefault(require("./zip-extract"));
61
61
 
62
62
  var _tarExtract = _interopRequireDefault(require("./tar-extract"));
63
63
 
64
+ var _tarDump = _interopRequireDefault(require("./tar-dump"));
65
+
64
66
  var _iniString = _interopRequireDefault(require("./ini-string"));
65
67
 
66
68
  var _fileSave = _interopRequireDefault(require("./file-save"));
@@ -98,6 +100,7 @@ const funcs = {
98
100
  TXTZip: _txtZip.default,
99
101
  ZIPExtract: _zipExtract.default,
100
102
  TARExtract: _tarExtract.default,
103
+ TARDump: _tarDump.default,
101
104
  INIString: _iniString.default,
102
105
  FILESave: _fileSave.default,
103
106
  FILELoad: _fileLoad.default,
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = TARDump;
7
+
8
+ var _tarStream = _interopRequireDefault(require("tar-stream"));
9
+
10
+ var _zlib = require("zlib");
11
+
12
+ var _lodash = _interopRequireDefault(require("lodash.merge"));
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ const eol = '\n';
17
+ /**
18
+ * Take all recevied objects and build a tar file
19
+ *
20
+ * ```json
21
+ * {
22
+ * }
23
+ * ```
24
+ *
25
+ * @name TARDump
26
+ * @param {String} [manifest] Location path to store files in the tarball
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
29
+ * @param {Boolean} [compress=false] Enable gzip compression
30
+ */
31
+
32
+ function TARDump(data, feed) {
33
+ if (!this.pack) {
34
+ this.pack = _tarStream.default.pack();
35
+ 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, ' '));
43
+ const stream = compress ? this.pack.pipe((0, _zlib.createGzip)()) : this.pack;
44
+ feed.flow(stream).finally(() => feed.close());
45
+ }
46
+
47
+ if (this.isLast()) {
48
+ this.pack.finalize();
49
+ return;
50
+ }
51
+
52
+ const id = this.getIndex().toString().padStart(10, '0');
53
+ const value = JSON.stringify(data).concat(eol);
54
+ const location = this.getParam('location', 'data');
55
+ this.pack.entry({
56
+ name: `${location}/f${id}.json`
57
+ }, value);
58
+ feed.end();
59
+ }
@@ -56,7 +56,9 @@ const TXTInflection = (data, feed, ctx) => {
56
56
  * @param {String} [path="value"] path of the field to segment
57
57
  * @param {String} [transform] name of a transformer
58
58
  * @returns {String[]}
59
- * @see https://www.npmjs.com/package/inflection
59
+ * @deprecated
60
+ * see https://inist-cnrs.github.io/ezs/#/plugin-strings?id=inflection
61
+ * see https://www.npmjs.com/package/inflection
60
62
  */
61
63
 
62
64
 
@@ -81,6 +81,8 @@ const TXTSentences = (data, feed, ctx) => {
81
81
  * @name TXTSentences
82
82
  * @param {String} [path="value"] path of the field to segment
83
83
  * @returns {String[]}
84
+ * @deprecated
85
+ * see https://inist-cnrs.github.io/ezs/#/plugin-strings?id=sentences
84
86
  */
85
87
 
86
88
 
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.2.0",
4
+ "version": "2.4.0",
5
5
  "author": "Nicolas Thouvenin <nthouvenin@gmail.com>",
6
6
  "bugs": "https://github.com/Inist-CNRS/ezs/issues",
7
7
  "dependencies": {
@@ -20,15 +20,16 @@
20
20
  "lodash.get": "4.4.2",
21
21
  "lodash.mapkeys": "4.6.0",
22
22
  "lodash.mapvalues": "4.6.0",
23
+ "lodash.merge": "4.6.2",
23
24
  "lodash.set": "4.3.2",
24
25
  "lodash.zipobject": "4.1.3",
25
- "make-dir": "3.1.0",
26
+ "make-dir": "4.0.0",
26
27
  "micromatch": "4.0.4",
27
28
  "node-abort-controller": "1.1.0",
28
29
  "parse-headers": "2.0.4",
29
30
  "path-exists": "4.0.0",
30
31
  "stream-write": "1.0.1",
31
- "tar-stream": "3.1.4",
32
+ "tar-stream": "3.1.6",
32
33
  "tmp-filepath": "2.0.0",
33
34
  "unzipper": "0.10.11",
34
35
  "xml-mapping": "1.7.2",
@@ -41,7 +42,7 @@
41
42
  "directories": {
42
43
  "test": "test"
43
44
  },
44
- "gitHead": "6868634896b6171224fe54c59360a3668d71bd5f",
45
+ "gitHead": "313d6ef24c4b958533685a198a090b7ecd2b33b9",
45
46
  "homepage": "https://github.com/Inist-CNRS/ezs/tree/master/packages/basics#readme",
46
47
  "keywords": [
47
48
  "ezs"