@ezs/basics 2.5.8 → 2.6.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/README.md +19 -0
- package/lib/bib-parse.js +60 -0
- package/lib/index.js +2 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -14,6 +14,7 @@ npm install @ezs/basics
|
|
|
14
14
|
|
|
15
15
|
#### Table of Contents
|
|
16
16
|
|
|
17
|
+
- [BIBParse](#bibparse)
|
|
17
18
|
- [BUFObject](#bufobject)
|
|
18
19
|
- [CSVObject](#csvobject)
|
|
19
20
|
- [CSVParse](#csvparse)
|
|
@@ -47,6 +48,24 @@ npm install @ezs/basics
|
|
|
47
48
|
- [XMLString](#xmlstring)
|
|
48
49
|
- [ZIPExtract](#zipextract)
|
|
49
50
|
|
|
51
|
+
### BIBParse
|
|
52
|
+
|
|
53
|
+
Take a `String` and split it at bibtext entry.
|
|
54
|
+
|
|
55
|
+
Input:
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
["@article{my_article,\ntitle = {Hello world},\n", "journal = \"Some Journal\"\n"]
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Output:
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
["a", "b", "c", "d"]
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
|
|
68
|
+
|
|
50
69
|
### BUFObject
|
|
51
70
|
|
|
52
71
|
Take `Mixed` and produce Buffer.
|
package/lib/bib-parse.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _string_decoder = require("string_decoder");
|
|
8
|
+
var _bib2json = _interopRequireDefault(require("bib2json"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
function BIBParse(data, feed) {
|
|
11
|
+
if (!this.decoder) {
|
|
12
|
+
this.decoder = new _string_decoder.StringDecoder('utf8');
|
|
13
|
+
this.remainder = '';
|
|
14
|
+
this.counter = 0;
|
|
15
|
+
this.parser = new _bib2json.default(entry => {
|
|
16
|
+
feed.write(entry);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
if (this.isLast()) {
|
|
20
|
+
this.remainder += this.decoder.end();
|
|
21
|
+
if (this.remainder && this.counter > 1) {
|
|
22
|
+
this.parser.parse(this.remainder);
|
|
23
|
+
}
|
|
24
|
+
return feed.close();
|
|
25
|
+
}
|
|
26
|
+
let chunk;
|
|
27
|
+
if (Buffer.isBuffer(data)) {
|
|
28
|
+
chunk = this.decoder.write(data);
|
|
29
|
+
} else if (typeof data === 'string') {
|
|
30
|
+
chunk = data;
|
|
31
|
+
} else {
|
|
32
|
+
chunk = '';
|
|
33
|
+
}
|
|
34
|
+
this.parser.parse(chunk);
|
|
35
|
+
this.counter += 1;
|
|
36
|
+
feed.end();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Take a `String` and split it at bibtext entry.
|
|
41
|
+
*
|
|
42
|
+
* Input:
|
|
43
|
+
*
|
|
44
|
+
* ```json
|
|
45
|
+
* ["@article{my_article,\ntitle = {Hello world},\n", "journal = \"Some Journal\"\n"]
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* Output:
|
|
49
|
+
*
|
|
50
|
+
* ```json
|
|
51
|
+
* ["a", "b", "c", "d"]
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @name BIBParse
|
|
55
|
+
* @returns {Object}
|
|
56
|
+
*/
|
|
57
|
+
var _default = {
|
|
58
|
+
BIBParse
|
|
59
|
+
};
|
|
60
|
+
exports.default = _default;
|
package/lib/index.js
CHANGED
|
@@ -9,6 +9,7 @@ var _objCount = _interopRequireDefault(require("./obj-count"));
|
|
|
9
9
|
var _objNamespaces = _interopRequireDefault(require("./obj-namespaces"));
|
|
10
10
|
var _objStandardize = _interopRequireDefault(require("./obj-standardize"));
|
|
11
11
|
var _objFlatten = _interopRequireDefault(require("./obj-flatten"));
|
|
12
|
+
var _bibParse = _interopRequireDefault(require("./bib-parse"));
|
|
12
13
|
var _txtConcat = _interopRequireDefault(require("./txt-concat"));
|
|
13
14
|
var _txtObject = _interopRequireDefault(require("./txt-object"));
|
|
14
15
|
var _txtParse = _interopRequireDefault(require("./txt-parse"));
|
|
@@ -43,6 +44,7 @@ const funcs = {
|
|
|
43
44
|
OBJNamespaces: _objNamespaces.default,
|
|
44
45
|
OBJStandardize: _objStandardize.default,
|
|
45
46
|
OBJFlatten: _objFlatten.default,
|
|
47
|
+
BIBParse: _bibParse.default,
|
|
46
48
|
TXTParse: _txtParse.default,
|
|
47
49
|
TXTObject: _txtObject.default,
|
|
48
50
|
TXTConcat: _txtConcat.default,
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ezs/basics",
|
|
3
3
|
"description": "Basics statements for EZS",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.6.0",
|
|
5
5
|
"author": "Nicolas Thouvenin <nthouvenin@gmail.com>",
|
|
6
6
|
"bugs": "https://github.com/Inist-CNRS/ezs/issues",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"JSONStream": "1.3.5",
|
|
9
9
|
"async-retry": "1.3.3",
|
|
10
10
|
"better-https-proxy-agent": "1.0.9",
|
|
11
|
+
"bib2json": "0.0.1",
|
|
11
12
|
"csv-string": "3.2.0",
|
|
12
13
|
"debug": "4.3.3",
|
|
13
14
|
"fetch-with-proxy": "3.0.1",
|
|
@@ -41,7 +42,7 @@
|
|
|
41
42
|
"directories": {
|
|
42
43
|
"test": "test"
|
|
43
44
|
},
|
|
44
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "3c080564bbee1b2e2f74fa453fb6781ad5aeb145",
|
|
45
46
|
"homepage": "https://github.com/Inist-CNRS/ezs/tree/master/packages/basics#readme",
|
|
46
47
|
"keywords": [
|
|
47
48
|
"ezs"
|