@iebh/reflib 2.1.0 → 2.1.2

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2021 Institute for Evidence-Based Healthcare
3
+ Copyright (c) 2022 Bond University Institute for Evidence-Based Healthcare
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
package/LICENSES.md ADDED
@@ -0,0 +1,97 @@
1
+ # @iebh/reflib (MIT)
2
+
3
+ ## [JSONStream](https://github.com/dominictarr/JSONStream)
4
+ ```
5
+ Apache License, Version 2.0
6
+
7
+ Copyright (c) 2011 Dominic Tarr
8
+
9
+ Licensed under the Apache License, Version 2.0 (the "License");
10
+ you may not use this file except in compliance with the License.
11
+ You may obtain a copy of the License at
12
+
13
+ http://www.apache.org/licenses/LICENSE-2.0
14
+
15
+ Unless required by applicable law or agreed to in writing, software
16
+ distributed under the License is distributed on an "AS IS" BASIS,
17
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ See the License for the specific language governing permissions and
19
+ limitations under the License.
20
+
21
+ ```
22
+
23
+ ## [htmlparser2](https://github.com/fb55/htmlparser2)
24
+ ```
25
+ Copyright 2010, 2011, Chris Winberry <chris@winberry.net>. All rights reserved.
26
+ Permission is hereby granted, free of charge, to any person obtaining a copy
27
+ of this software and associated documentation files (the "Software"), to
28
+ deal in the Software without restriction, including without limitation the
29
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
30
+ sell copies of the Software, and to permit persons to whom the Software is
31
+ furnished to do so, subject to the following conditions:
32
+
33
+ The above copyright notice and this permission notice shall be included in
34
+ all copies or substantial portions of the Software.
35
+
36
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
37
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
38
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
39
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
40
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
41
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
42
+ IN THE SOFTWARE.
43
+ ```
44
+
45
+ ## [mitt](https://github.com/developit/mitt)
46
+ ```
47
+ MIT License
48
+
49
+ Copyright (c) 2021 Jason Miller
50
+
51
+ Permission is hereby granted, free of charge, to any person obtaining a copy
52
+ of this software and associated documentation files (the "Software"), to deal
53
+ in the Software without restriction, including without limitation the rights
54
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
55
+ copies of the Software, and to permit persons to whom the Software is
56
+ furnished to do so, subject to the following conditions:
57
+
58
+ The above copyright notice and this permission notice shall be included in all
59
+ copies or substantial portions of the Software.
60
+
61
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
62
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
63
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
64
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
65
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
66
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
67
+ SOFTWARE.
68
+
69
+ ```
70
+
71
+ ## [vite-plugin-replace](https://github.com/leanupjs/leanup)
72
+ ```
73
+ MIT License
74
+
75
+ Copyright (c) 2021 leanupjs
76
+
77
+ Permission is hereby granted, free of charge, to any person obtaining a copy
78
+ of this software and associated documentation files (the "Software"), to deal
79
+ in the Software without restriction, including without limitation the rights
80
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
81
+ copies of the Software, and to permit persons to whom the Software is
82
+ furnished to do so, subject to the following conditions:
83
+
84
+ The above copyright notice and this permission notice shall be included in all
85
+ copies or substantial portions of the Software.
86
+
87
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
88
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
89
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
90
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
91
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
92
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
93
+ SOFTWARE.
94
+
95
+ ```
96
+
97
+
package/README.md CHANGED
@@ -4,8 +4,7 @@ Reference library processing for Node.
4
4
 
5
5
  This library provides various read/write functionality to process citation libraries and handle individual references (henceforth "Refs").
6
6
 
7
- **NOTE: THIS LIBRARY IS STILL UNDER CONSTRUCTION**
8
- **Please use [Version 1](https://github.com/hash-bang/Reflib-Node) ([NPM](https://www.npmjs.com/package/reflib)) until this message is removed**
7
+ This module forms part of the [Systematic Review Accelerator](https://sr-accelerator.com)
9
8
 
10
9
 
11
10
  Compatibility
@@ -3,6 +3,7 @@ import Emitter from '../shared/emitter.js';
3
3
 
4
4
  // TODO: CF: Don't need to import both, it depends if we are on browser or node
5
5
  import * as htmlparser2 from "htmlparser2";
6
+ // FIXME: CF: Browsers freak out without pollyfills if this is imported
6
7
  import {WritableStream as XMLParser} from 'htmlparser2/lib/WritableStream';
7
8
 
8
9
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iebh/reflib",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "description": "Reference / Citation reference library utilities",
5
5
  "scripts": {
6
6
  "lint": "eslint lib modules shared test",
@@ -17,7 +17,10 @@
17
17
  "citations",
18
18
  "library"
19
19
  ],
20
- "author": "Matt Carter <m@ttcarter.com>",
20
+ "author": [
21
+ "Matt Carter <m@ttcarter.com> (https://github.com/hash-bang)",
22
+ "Connor Forbes <cforbes.software@gmail.com> (https://github.com/connorf25)"
23
+ ],
21
24
  "license": "MIT",
22
25
  "bugs": {
23
26
  "url": "https://github.com/IEBH/RefLib/issues"
@@ -40,13 +43,13 @@
40
43
  "eslint": "^8.15.0",
41
44
  "mocha": "^10.0.0",
42
45
  "mocha-logger": "^1.0.8",
43
- "temp": "^0.9.4"
46
+ "temp": "^0.9.4",
47
+ "vite-plugin-replace": "^0.1.1"
44
48
  },
45
49
  "dependencies": {
46
50
  "htmlparser2": "^8.0.1",
47
51
  "JSONStream": "^1.3.5",
48
- "mitt": "^3.0.0",
49
- "vite-plugin-replace": "^0.1.1"
52
+ "mitt": "^3.0.0"
50
53
  },
51
54
  "eslintConfig": {
52
55
  "extends": "eslint:recommended",
@@ -11,8 +11,50 @@ import Emitter from '../shared/emitter.js';
11
11
  * @emits error Emitted as `(Error)` on any read error
12
12
  */
13
13
  export default function streamEmitter(inStream) {
14
- // FIXME: Need to examine inStream and multiplex
15
- // inStream.pipeTo - a browser stream - passthru
16
- // !inStream.pipeTo - probably Node stream - need to glue pipeTo as a promiseable
17
- return inStream;
14
+ if (inStream.getReader) { // Assume browser compatible ReadableStream
15
+ /**
16
+ * MC's tiny ReadableStream -> stream.Readable / Emitter pattern
17
+ * There is a non-zero chance that this is going to break at some future point
18
+ * This is really just a shiv for browser functionality to replicate Stream-a-like emitter pattern
19
+ * @date 2023-10-19
20
+ * @author Matt Carter <m@ttcarter.com>
21
+ */
22
+ let reader = new Emitter();
23
+ Object.assign(reader, {
24
+ bytesRead: 0,
25
+ reader: inStream.getReader(),
26
+ textDecoder: new TextDecoder('utf-8'),
27
+ read() { // Read one chunk + trigger emitters
28
+ this.reader.read()
29
+ .then(({done, value}) => {
30
+ if (done) {
31
+ reader.emit('end');
32
+
33
+ if (this.pipeTarget)
34
+ this.pipeTarget.end();
35
+ } else if (value) {
36
+ let data = this.textDecoder.decode(value);
37
+ this.bytesRead += data.length;
38
+ reader.emit('data', data);
39
+
40
+ if (this.pipeTarget)
41
+ this.pipeTarget.write(data);
42
+
43
+ setTimeout(this.read.bind(this));
44
+ }
45
+ })
46
+ .catch(e => this.emit('error', e))
47
+ },
48
+ pipeTarget: null,
49
+ pipe(target) {
50
+ this.pipeTarget = target;
51
+ return this;
52
+ },
53
+ });
54
+
55
+ setTimeout(()=> reader.read());
56
+ return reader;
57
+ } else { // Assume Node native stream.Readable
58
+ return inStream;
59
+ }
18
60
  }