@sjcrh/proteinpaint-rust 2.135.2-0 → 2.136.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.
Files changed (2) hide show
  1. package/index.js +14 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,3 +1,15 @@
1
+ /*
2
+ Module for running rust binaries
3
+
4
+ Arguments:
5
+ - <binfile>: [string] name of the rust binary file.
6
+ - <input_data>: [string|Buffer|ReadableStream] input data for the rust binary.
7
+ - <args>: [array] arguments for the rust binary (optional).
8
+
9
+ Input data is streamed into the standard input of the rust binary.
10
+ Standard output of the rust binary is returned.
11
+ */
12
+
1
13
  // Import necessary modules
2
14
  import fs from 'fs'
3
15
  import path from 'path'
@@ -14,10 +26,10 @@ const binaryDir = path.join(__dirname, '/target/release/')
14
26
  if (!fs.existsSync(binaryDir)) throw `missing rust binary directory='${binaryDir}'`
15
27
  if (!fs.readdirSync(binaryDir).length) throw `empty rust binary directory='${binaryDir}'`
16
28
 
17
- export function run_rust(binfile, input_data) {
29
+ export function run_rust(binfile, input_data, args = []) {
18
30
  return new Promise((resolve, reject) => {
19
31
  const binpath = path.join(__dirname, '/target/release/', binfile)
20
- const ps = spawn(binpath)
32
+ const ps = spawn(binpath, args)
21
33
  const stdout = []
22
34
  const stderr = []
23
35
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.135.2-0",
2
+ "version": "2.136.0",
3
3
  "name": "@sjcrh/proteinpaint-rust",
4
4
  "type": "module",
5
5
  "description": "Rust-based utilities for proteinpaint",