@ezs/basics 1.22.5 → 1.22.7
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 +19 -0
- package/README.md +1 -0
- package/lib/obj-flatten.js +1 -0
- package/lib/obj-standardize.js +41 -24
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
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
|
+
## [1.22.7](https://github.com/Inist-CNRS/ezs/compare/@ezs/basics@1.22.6...@ezs/basics@1.22.7) (2023-01-13)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* 🐛 backpresure control ([70c4a07](https://github.com/Inist-CNRS/ezs/commit/70c4a07010c0b1927bb57c95b3c5113e8aaa7552))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [1.22.6](https://github.com/Inist-CNRS/ezs/compare/@ezs/basics@1.22.5...@ezs/basics@1.22.6) (2023-01-05)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @ezs/basics
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
## [1.22.5](https://github.com/Inist-CNRS/ezs/compare/@ezs/basics@1.22.4...@ezs/basics@1.22.5) (2022-12-21)
|
|
7
26
|
|
|
8
27
|
|
package/README.md
CHANGED
|
@@ -437,6 +437,7 @@ Output:
|
|
|
437
437
|
#### Parameters
|
|
438
438
|
|
|
439
439
|
- `separator` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** choose a character to flatten keys (optional, default `"/"`)
|
|
440
|
+
- `reverse` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** unflatten instead of flatten keys (optional, default `false`)
|
|
440
441
|
- `safe` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** preserve arrays and their contents, (optional, default `false`)
|
|
441
442
|
|
|
442
443
|
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
|
package/lib/obj-flatten.js
CHANGED
|
@@ -36,6 +36,7 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
36
36
|
*
|
|
37
37
|
* @name OBJFlatten
|
|
38
38
|
* @param {String} [separator="/"] choose a character to flatten keys
|
|
39
|
+
* @param {Boolean} [reverse=false] unflatten instead of flatten keys
|
|
39
40
|
* @param {Boolean} [safe=false] preserve arrays and their contents,
|
|
40
41
|
* @returns {Object}
|
|
41
42
|
*/
|
package/lib/obj-standardize.js
CHANGED
|
@@ -13,6 +13,37 @@ var _streamWrite = _interopRequireDefault(require("stream-write"));
|
|
|
13
13
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
16
|
+
function normalize(data, feed) {
|
|
17
|
+
if (this.isLast()) {
|
|
18
|
+
return feed.close();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const struct = this.getEnv();
|
|
22
|
+
const vv = {};
|
|
23
|
+
struct.forEach(k => {
|
|
24
|
+
if (!data[k]) {
|
|
25
|
+
vv[k] = '';
|
|
26
|
+
} else {
|
|
27
|
+
vv[k] = data[k];
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return feed.send(vv);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function cleanup(data, feed) {
|
|
34
|
+
if (this.isLast()) {
|
|
35
|
+
const filename = this.getParam('filename');
|
|
36
|
+
|
|
37
|
+
if (filename) {
|
|
38
|
+
return _fs.default.unlink(filename, () => feed.close());
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return feed.close();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return feed.send(data);
|
|
45
|
+
}
|
|
46
|
+
|
|
16
47
|
function OBJStandardize(data, feed) {
|
|
17
48
|
const self = this;
|
|
18
49
|
const {
|
|
@@ -29,31 +60,17 @@ function OBJStandardize(data, feed) {
|
|
|
29
60
|
|
|
30
61
|
if (self.isLast()) {
|
|
31
62
|
self.tmpInput.end();
|
|
32
|
-
self.tmpHandle.then(() => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}).on('data', d => {
|
|
36
|
-
const vv = {};
|
|
37
|
-
self.struct.forEach(k => {
|
|
38
|
-
if (!d[k]) {
|
|
39
|
-
vv[k] = '';
|
|
40
|
-
} else {
|
|
41
|
-
vv[k] = d[k];
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
feed.write(vv);
|
|
45
|
-
}).on('end', () => {
|
|
46
|
-
_fs.default.unlink(self.tmpFile, () => feed.close());
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
} else {
|
|
50
|
-
Object.keys(data).forEach(k => {
|
|
51
|
-
if (self.struct.indexOf(k) === -1) {
|
|
52
|
-
self.struct.push(k);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
(0, _streamWrite.default)(self.tmpInput, data, () => feed.end());
|
|
63
|
+
return self.tmpHandle.then(() => feed.flow(_fs.default.createReadStream(self.tmpFile).pipe(ezs.uncompress()).pipe(ezs('unpack')).pipe(ezs(normalize, {}, self.struct)).pipe(ezs(cleanup, {
|
|
64
|
+
filename: self.tmpFile
|
|
65
|
+
})))).catch(e => feed.stop(e));
|
|
56
66
|
}
|
|
67
|
+
|
|
68
|
+
Object.keys(data).forEach(k => {
|
|
69
|
+
if (self.struct.indexOf(k) === -1) {
|
|
70
|
+
self.struct.push(k);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
(0, _streamWrite.default)(self.tmpInput, data, () => feed.end());
|
|
57
74
|
}
|
|
58
75
|
/**
|
|
59
76
|
* Standardize `Object`s so that each object have the same keys.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ezs/basics",
|
|
3
3
|
"description": "Basics statements for EZS",
|
|
4
|
-
"version": "1.22.
|
|
4
|
+
"version": "1.22.7",
|
|
5
5
|
"author": "Nicolas Thouvenin <nthouvenin@gmail.com>",
|
|
6
6
|
"bugs": "https://github.com/Inist-CNRS/ezs/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"directories": {
|
|
38
38
|
"test": "test"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "73aeeddfdd1152f879116a7c064ab3028419021c",
|
|
41
41
|
"homepage": "https://github.com/Inist-CNRS/ezs/tree/master/packages/basics#readme",
|
|
42
42
|
"keywords": [
|
|
43
43
|
"ezs"
|