sdf-parser 5.0.0 → 5.0.1

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/lib/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var ensureString = require('ensure-string');
5
6
  var pipeline = require('pumpify');
6
7
  var split2 = require('split2');
7
8
  var through2 = require('through2');
@@ -31,6 +32,16 @@ function getEntriesBoundaries(string, substring, eol) {
31
32
  return res;
32
33
  }
33
34
 
35
+ /**
36
+ * Parse a SDF file
37
+ * @param {string|ArrayBuffer|Uint8Array} sdf SDF file to parse
38
+ * @param {any} [options={}]
39
+ * @param {array<string>} [options.include] List of fields to include
40
+ * @param {array<string>} [options.exclude] List of fields to exclude
41
+ * @param {boolean} [options.dynamicTyping] Dynamically type the data
42
+ * @param {object} [options.modifiers] Object containing callbacks to apply on some specific fields
43
+ * @param {boolean} [options.mixedEOL=false] Set to true if you know there is a mixture between \r\n and \n
44
+ */
34
45
  function parse(sdf, options = {}) {
35
46
  const {
36
47
  include,
@@ -41,6 +52,7 @@ function parse(sdf, options = {}) {
41
52
  dynamicTyping = true,
42
53
  } = options;
43
54
 
55
+ sdf = ensureString.ensureString(sdf);
44
56
  if (typeof sdf !== 'string') {
45
57
  throw new TypeError('Parameter "sdf" must be a string');
46
58
  }
@@ -179,6 +191,7 @@ function parse(sdf, options = {}) {
179
191
  }
180
192
 
181
193
  const filterStream = filter__default["default"].bind(null, { objectMode: true });
194
+
182
195
  function filterCb(chunk) {
183
196
  return chunk.length > 1 && chunk.trim().length > 1;
184
197
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sdf-parser",
3
- "version": "5.0.0",
3
+ "version": "5.0.1",
4
4
  "description": "SDF parser",
5
5
  "main": "lib/index.js",
6
6
  "module": "src/index.js",
@@ -8,6 +8,7 @@
8
8
  "lib",
9
9
  "src"
10
10
  ],
11
+ "sideEffects": false,
11
12
  "scripts": {
12
13
  "build": "npm run compile && cheminfo-build --root SDFParser",
13
14
  "compile": "rollup -c",
@@ -42,19 +43,20 @@
42
43
  },
43
44
  "homepage": "https://github.com/cheminfo/sdf-parser",
44
45
  "devDependencies": {
45
- "@babel/plugin-transform-modules-commonjs": "^7.15.4",
46
+ "@babel/plugin-transform-modules-commonjs": "^7.16.8",
46
47
  "babel-eslint": "^10.1.0",
47
48
  "callback-stream": "^1.1.0",
48
49
  "cheminfo-build": "^1.1.11",
49
- "eslint": "^7.32.0",
50
- "eslint-config-cheminfo": "^6.0.1",
51
- "jest": "^27.2.5",
50
+ "eslint": "^8.10.0",
51
+ "eslint-config-cheminfo": "^7.3.0",
52
+ "jest": "^27.5.1",
52
53
  "openchemlib": "^7.4.3",
53
- "prettier": "^2.4.1"
54
+ "prettier": "^2.5.1"
54
55
  },
55
56
  "dependencies": {
57
+ "ensure-string": "^1.1.0",
56
58
  "pumpify": "^2.0.1",
57
- "split2": "^3.2.2",
59
+ "split2": "^4.1.0",
58
60
  "through2": "^4.0.2",
59
61
  "through2-filter": "^3.0.0"
60
62
  }
package/src/parse.js CHANGED
@@ -1,5 +1,16 @@
1
- import { getEntriesBoundaries } from './getEntriesBoundaries';
1
+ import { ensureString } from 'ensure-string';
2
2
 
3
+ import { getEntriesBoundaries } from './getEntriesBoundaries';
4
+ /**
5
+ * Parse a SDF file
6
+ * @param {string|ArrayBuffer|Uint8Array} sdf SDF file to parse
7
+ * @param {any} [options={}]
8
+ * @param {array<string>} [options.include] List of fields to include
9
+ * @param {array<string>} [options.exclude] List of fields to exclude
10
+ * @param {boolean} [options.dynamicTyping] Dynamically type the data
11
+ * @param {object} [options.modifiers] Object containing callbacks to apply on some specific fields
12
+ * @param {boolean} [options.mixedEOL=false] Set to true if you know there is a mixture between \r\n and \n
13
+ */
3
14
  export function parse(sdf, options = {}) {
4
15
  const {
5
16
  include,
@@ -10,6 +21,7 @@ export function parse(sdf, options = {}) {
10
21
  dynamicTyping = true,
11
22
  } = options;
12
23
 
24
+ sdf = ensureString(sdf);
13
25
  if (typeof sdf !== 'string') {
14
26
  throw new TypeError('Parameter "sdf" must be a string');
15
27
  }
package/src/stream.js CHANGED
@@ -6,6 +6,7 @@ import filter from 'through2-filter';
6
6
  import { parse } from './parse';
7
7
 
8
8
  const filterStream = filter.bind(null, { objectMode: true });
9
+
9
10
  function filterCb(chunk) {
10
11
  return chunk.length > 1 && chunk.trim().length > 1;
11
12
  }