nodejs-nomer 1.0.8 → 1.0.11

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/dist/index.js CHANGED
@@ -41,25 +41,25 @@ var Nomer = /*#__PURE__*/function () {
41
41
  }, {
42
42
  key: "clean",
43
43
  value: function clean() {
44
- var res = (0, _utils.runNomer)((0, _utils.getNomerSimpleCmd)("clean", this.getPropertiesPath()));
44
+ var res = (0, _utils.runNomer)((0, _utils.getNomerSimpleCmd)("clean", false, this.getPropertiesPath()));
45
45
  return res;
46
46
  }
47
47
  }, {
48
48
  key: "inputSchema",
49
49
  value: function inputSchema() {
50
- var res = (0, _utils.runNomer)((0, _utils.getNomerSimpleCmd)("input-schema", this.getPropertiesPath()));
50
+ var res = (0, _utils.runNomer)((0, _utils.getNomerSimpleCmd)("input-schema", false, this.getPropertiesPath()));
51
51
  return res;
52
52
  }
53
53
  }, {
54
54
  key: "outputSchema",
55
55
  value: function outputSchema() {
56
- var res = (0, _utils.runNomer)((0, _utils.getNomerSimpleCmd)("output-schema", this.getPropertiesPath()));
56
+ var res = (0, _utils.runNomer)((0, _utils.getNomerSimpleCmd)("output-schema", false, this.getPropertiesPath()));
57
57
  return res;
58
58
  }
59
59
  }, {
60
60
  key: "properties",
61
61
  value: function properties() {
62
- var res = (0, _utils.runNomer)((0, _utils.getNomerSimpleCmd)("properties", this.getPropertiesPath()));
62
+ var res = (0, _utils.runNomer)((0, _utils.getNomerSimpleCmd)("properties", false, this.getPropertiesPath()));
63
63
  return res;
64
64
  }
65
65
  }, {
@@ -91,9 +91,16 @@ var Nomer = /*#__PURE__*/function () {
91
91
  var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
92
92
  var matcher = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "globi-taxon-cache";
93
93
  var outputFormat = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "tsv";
94
- var res = (0, _utils.runNomer)((0, _utils.getNomerMatchCmd)(query, "append", matcher, this.getPropertiesPath(), outputFormat, this.echoOpt));
94
+ var res = (0, _utils.runNomer)((0, _utils.getNomerMatchCmd)(query, "append", matcher, this.getPropertiesPath(), outputFormat, this.echoOpt), query);
95
95
  return res;
96
96
  }
97
+ }, {
98
+ key: "appendAsync",
99
+ value: function appendAsync() {
100
+ var matcher = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "globi-taxon-cache";
101
+ var outputFormat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "tsv";
102
+ return (0, _utils.runNomerAsync)("nomer append ".concat(matcher, " -o ").concat(outputFormat));
103
+ }
97
104
  }, {
98
105
  key: "getPropertiesPath",
99
106
  value: function getPropertiesPath() {
package/dist/result.js CHANGED
@@ -13,7 +13,6 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
13
13
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
14
14
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
15
15
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
16
- var TSV_COLUMNS = ['inputId', 'inputName', 'match', 'externalId', 'name', 'authorship', 'rank', 'commonNames', 'path', 'pathIds', 'pathNames', 'pathAuthorship', 'externalUrl'];
17
16
  var Result = /*#__PURE__*/function () {
18
17
  function Result() {
19
18
  _classCallCheck(this, Result);
package/dist/utils.js CHANGED
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  var _require = require('child_process'),
4
- execSync = _require.execSync;
4
+ execSync = _require.execSync,
5
+ exec = _require.exec;
5
6
  var getNomerValidateCmd = function getNomerValidateCmd() {
6
7
  var filepath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
7
8
  var cmd = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "validate-term";
@@ -50,7 +51,9 @@ var getNomerSimpleCmd = function getNomerSimpleCmd() {
50
51
  };
51
52
  var runNomer = function runNomer(nomerCmd) {
52
53
  try {
53
- var result = execSync(nomerCmd).toString();
54
+ var result = execSync(nomerCmd, {
55
+ maxBuffer: 4096 * 4096
56
+ }).toString();
54
57
  if (result) {
55
58
  return result.trimEnd();
56
59
  }
@@ -59,9 +62,19 @@ var runNomer = function runNomer(nomerCmd) {
59
62
  return null;
60
63
  }
61
64
  };
65
+ var runNomerAsync = function runNomerAsync(nomerCmd) {
66
+ var p = exec(nomerCmd, {
67
+ maxBuffer: 4096 * 4096
68
+ });
69
+ return {
70
+ stdin: p.stdin,
71
+ stdout: p.stdout
72
+ };
73
+ };
62
74
  module.exports = {
63
75
  getNomerValidateCmd: getNomerValidateCmd,
64
76
  getNomerMatchCmd: getNomerMatchCmd,
65
77
  getNomerSimpleCmd: getNomerSimpleCmd,
66
- runNomer: runNomer
78
+ runNomer: runNomer,
79
+ runNomerAsync: runNomerAsync
67
80
  };
package/package.json CHANGED
@@ -1,14 +1,18 @@
1
1
  {
2
2
  "name": "nodejs-nomer",
3
- "version": "1.0.8",
3
+ "version": "1.0.11",
4
4
  "description": "NodeJS wrapper for nomer",
5
- "directories": {
6
- "bin": "./bin"
5
+ "bin": {
6
+ "nomer": "./bin/nomer"
7
+ },
8
+ "config": {
9
+ "nomerVersion": "0.5.7"
7
10
  },
8
11
  "main": "index.js",
9
12
  "scripts": {
10
13
  "test": "npm run test",
11
- "build": "babel src -d dist"
14
+ "build": "babel src -d dist",
15
+ "preinstall": "./install_nomer.sh ${npm_package_config_nomerVersion}"
12
16
  },
13
17
  "repository": {
14
18
  "type": "git",
@@ -32,4 +36,4 @@
32
36
  "dependencies": {
33
37
  "properties-file": "^3.5.1"
34
38
  }
35
- }
39
+ }
package/src/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { runNomer, getNomerSimpleCmd, getNomerValidateCmd, getNomerMatchCmd } from "./utils";
1
+ import { runNomer, runNomerAsync, getNomerSimpleCmd, getNomerValidateCmd, getNomerMatchCmd } from "./utils";
2
2
  import Result from './result'
3
3
  import { getProperties } from "properties-file";
4
4
 
@@ -23,22 +23,22 @@ class Nomer {
23
23
  }
24
24
 
25
25
  clean() {
26
- const res = runNomer(getNomerSimpleCmd("clean", this.getPropertiesPath()))
26
+ const res = runNomer(getNomerSimpleCmd("clean", false, this.getPropertiesPath()))
27
27
  return res;
28
28
  }
29
29
 
30
30
  inputSchema() {
31
- const res = runNomer(getNomerSimpleCmd("input-schema", this.getPropertiesPath()))
31
+ const res = runNomer(getNomerSimpleCmd("input-schema", false, this.getPropertiesPath()))
32
32
  return res;
33
33
  }
34
34
 
35
35
  outputSchema() {
36
- const res = runNomer(getNomerSimpleCmd("output-schema", this.getPropertiesPath()))
36
+ const res = runNomer(getNomerSimpleCmd("output-schema", false, this.getPropertiesPath()))
37
37
  return res;
38
38
  }
39
39
 
40
40
  properties() {
41
- const res = runNomer(getNomerSimpleCmd("properties", this.getPropertiesPath()))
41
+ const res = runNomer(getNomerSimpleCmd("properties", false, this.getPropertiesPath()))
42
42
  return res;
43
43
  }
44
44
 
@@ -75,11 +75,16 @@ class Nomer {
75
75
  this.getPropertiesPath(),
76
76
  outputFormat,
77
77
  this.echoOpt
78
- )
78
+ ),
79
+ query
79
80
  );
80
81
  return res;
81
82
  }
82
83
 
84
+ appendAsync(matcher = "globi-taxon-cache", outputFormat = "tsv") {
85
+ return runNomerAsync(`nomer append ${matcher} -o ${outputFormat}`)
86
+ }
87
+
83
88
  getPropertiesPath() {
84
89
  return this.propertiesPath;
85
90
  }
package/src/result.js CHANGED
@@ -1,19 +1,3 @@
1
- const TSV_COLUMNS = [
2
- 'inputId',
3
- 'inputName',
4
- 'match',
5
- 'externalId',
6
- 'name',
7
- 'authorship',
8
- 'rank',
9
- 'commonNames',
10
- 'path',
11
- 'pathIds',
12
- 'pathNames',
13
- 'pathAuthorship',
14
- 'externalUrl'
15
- ];
16
-
17
1
  class Result {
18
2
 
19
3
  static json(result) {
package/src/utils.js CHANGED
@@ -1,10 +1,10 @@
1
- const { execSync } = require('child_process')
1
+ const { execSync, exec } = require('child_process')
2
2
 
3
3
  const getNomerValidateCmd = (filepath = "", cmd = "validate-term", properties = null) => {
4
4
  if (filepath === "") {
5
5
  throw new Exception("Filepath cannot be empty string");
6
6
  }
7
- let nomerCmd = `curl -L ${filepath} | ./bin/nomer ${cmd}`;
7
+ let nomerCmd = `curl -L ${filepath} | nomer ${cmd}`;
8
8
  if (properties) {
9
9
  nomerCmd = `${nomerCmd} -p ${properties}`;
10
10
  }
@@ -13,7 +13,7 @@ const getNomerValidateCmd = (filepath = "", cmd = "validate-term", properties =
13
13
  }
14
14
 
15
15
  const getNomerMatchCmd = (query = "", cmd = "append", matcher = "globi-taxon-cache", properties = null, outputFormat = null, echoOpt = "-e") => {
16
- let nomerCmd = `echo ${echoOpt} '${query}' | ./bin/nomer ${cmd} ${matcher}`;
16
+ let nomerCmd = `echo ${echoOpt} '${query}' | nomer ${cmd} ${matcher}`;
17
17
  if (properties) {
18
18
  nomerCmd = `${nomerCmd} -p ${properties}`;
19
19
  }
@@ -25,7 +25,7 @@ const getNomerMatchCmd = (query = "", cmd = "append", matcher = "globi-taxon-cac
25
25
  }
26
26
 
27
27
  const getNomerSimpleCmd = (cmd = "version", verbose = false, properties = null, outputFormat = null) => {
28
- let nomerCmd = `./bin/nomer ${cmd}`;
28
+ let nomerCmd = `nomer ${cmd}`;
29
29
  if (properties) {
30
30
  nomerCmd = `${nomerCmd} -p ${properties}`;
31
31
  }
@@ -41,7 +41,9 @@ const getNomerSimpleCmd = (cmd = "version", verbose = false, properties = null,
41
41
 
42
42
  const runNomer = (nomerCmd) => {
43
43
  try {
44
- const result = execSync(nomerCmd).toString();
44
+ const result = execSync(nomerCmd, {
45
+ maxBuffer: 4096 * 4096,
46
+ }).toString();
45
47
  if (result) {
46
48
  return result.trimEnd();
47
49
  }
@@ -51,9 +53,18 @@ const runNomer = (nomerCmd) => {
51
53
  }
52
54
  }
53
55
 
56
+ const runNomerAsync = (nomerCmd) => {
57
+ const p = exec(nomerCmd, {
58
+ maxBuffer: 4096 * 4096
59
+ })
60
+
61
+ return { stdin: p.stdin, stdout: p.stdout }
62
+ }
63
+
54
64
  module.exports = {
55
65
  getNomerValidateCmd,
56
66
  getNomerMatchCmd,
57
67
  getNomerSimpleCmd,
58
- runNomer
68
+ runNomer,
69
+ runNomerAsync
59
70
  };
package/test/script.js CHANGED
@@ -1,7 +1,23 @@
1
1
  const Nomer = require("nodejs-nomer")
2
2
 
3
3
  const nomer = new Nomer();
4
+
5
+ console.time("version")
4
6
  console.log(nomer.version());
7
+ console.timeEnd("version")
8
+
9
+
10
+
11
+ // console.time("append")
12
+ // const results = []
13
+ // for (let index = 0; index < 100; index++) {
14
+ // results.push(nomer.append("\tBauhinia rufa\t", "gbif"))
15
+ // }
16
+ // console.timeEnd("append")
5
17
 
6
- console.log(nomer.matcher());
7
- console.log(nomer.append("\tHomo sapiens", "gbif-web"));
18
+ // console.time("toObject")
19
+ // for (let index = 0; index < results.length; index++) {
20
+ // const element = results[index];
21
+ // nomer.toObject(element)
22
+ // }
23
+ // console.timeEnd("toObject")
package/bin/nomer DELETED
Binary file
package/package.json.bkp DELETED
@@ -1,39 +0,0 @@
1
- {
2
- "name": "nodejs-nomer",
3
- "version": "1.0.7",
4
- "description": "NodeJS wrapper for nomer",
5
- "config": {
6
- "nomerVersion": "0.5.7"
7
- },
8
- "directories": {
9
- "bin": "./bin"
10
- },
11
- "main": "index.js",
12
- "scripts": {
13
- "test": "npm run test",
14
- "build": "babel src -d dist",
15
- //"preinstall": "./install_nomer.sh ${npm_package_config_nomerVersion}"
16
- },
17
- "repository": {
18
- "type": "git",
19
- "url": "git+https://github.com/zedomel/nodejs-nomer.git"
20
- },
21
- "keywords": [
22
- "nomer",
23
- "nodejs"
24
- ],
25
- "author": "Jose A Salim",
26
- "license": "GPL-3.0",
27
- "bugs": {
28
- "url": "https://github.com/zedomel/nodejs-nomer/issues"
29
- },
30
- "homepage": "https://github.com/zedomel/nodejs-nomer#readme",
31
- "devDependencies": {
32
- "@babel/cli": "^7.23.9",
33
- "@babel/core": "^7.24.0",
34
- "@babel/preset-env": "^7.24.0"
35
- },
36
- "dependencies": {
37
- "properties-file": "^3.5.1"
38
- }
39
- }