You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+2-8
Original file line number
Diff line number
Diff line change
@@ -45,15 +45,9 @@ For macOS, the binary can be installed with [Homebrew](https://brew.sh/):
45
45
brew install unrtf
46
46
```
47
47
48
-
## API
48
+
## Example usage
49
49
50
-
```js
51
-
const { UnRTF } =require("node-unrtf");
52
-
```
53
-
54
-
[**API Documentation can be found here**](https://github.com/Fdawgs/node-unrtf/blob/main/API.md)
55
-
56
-
## Examples
50
+
Please refer to the [JSDoc comments in the source code](./src/index.js) or the [generated type definitions](https://www.npmjs.com/package/node-unrtf?activeTab=code) for information on the available options.
* @param {{[key: string]: any}} options - Object containing options to pass to binary.
27
+
* @param {string} version - Semantic version of binary.
26
28
* @returns {string[]} Array of CLI arguments.
27
29
* @throws If invalid arguments provided.
28
30
*/
@@ -48,23 +50,15 @@ function parseOptions(acceptedOptions, options, version) {
48
50
);
49
51
}
50
52
51
-
if(
52
-
acceptedOptions[key].minVersion&&
53
-
version&&
54
-
lt(version,acceptedOptions[key].minVersion)
55
-
){
53
+
/* istanbul ignore next: unable to test due to https://github.com/jestjs/jest/pull/14297 */
54
+
if(lt(version,acceptedOptions[key].minVersion)){
56
55
invalidArgs.push(
57
56
`Invalid option provided for the current version of the binary used. '${key}' was introduced in v${acceptedOptions[key].minVersion}, but received v${version}`
58
57
);
59
58
}
60
59
61
-
/* istanbul ignore next: requires incredibly old version of UnRTF to test */
62
-
if(
63
-
acceptedOptions[key].maxVersion&&
64
-
version&&
65
-
// @ts-ignore: type checking is done above
66
-
gt(version,acceptedOptions[key].maxVersion)
67
-
){
60
+
/* istanbul ignore next: unable to test due to https://github.com/jestjs/jest/pull/14297 */
`Invalid option provided for the current version of the binary used. '${key}' is only present up to v${acceptedOptions[key].maxVersion}, but received v${version}`
70
64
);
@@ -80,6 +74,10 @@ function parseOptions(acceptedOptions, options, version) {
80
74
}
81
75
82
76
classUnRTF{
77
+
#unrtfPath;
78
+
79
+
#unrtfVersion;
80
+
83
81
/**
84
82
* @param {string} [binPath] - Path of UnRTF binary.
85
83
* If not provided, the constructor will attempt to find the binary
@@ -89,10 +87,12 @@ class UnRTF {
89
87
* if a local installation is not found.
90
88
*/
91
89
constructor(binPath){
90
+
this.#unrtfPath ="";
91
+
92
92
/* istanbul ignore else: requires specific OS */
93
93
if(binPath){
94
94
/** @type {string|undefined} */
95
-
this.unrtfPath=binPath;
95
+
this.#unrtfPath =binPath;
96
96
}else{
97
97
const{ platform }=process;
98
98
@@ -102,10 +102,10 @@ class UnRTF {
102
102
constunrtfPath=unrtfPathRegex.exec(which)?.[1];
103
103
104
104
if(unrtfPath){
105
-
this.unrtfPath=unrtfPath;
105
+
this.#unrtfPath =unrtfPath;
106
106
}
107
107
if(platform==="win32"&&!unrtfPath){
108
-
this.unrtfPath=joinSafe(
108
+
this.#unrtfPath =joinSafe(
109
109
__dirname,
110
110
"lib",
111
111
"win32",
@@ -115,24 +115,29 @@ class UnRTF {
115
115
}
116
116
}
117
117
118
-
if(!this.unrtfPath){
118
+
/* istanbul ignore next: unable to test due to https://github.com/jestjs/jest/pull/14297 */
119
+
if(!this.#unrtfPath){
119
120
thrownewError(
120
121
`Unable to find ${process.platform} UnRTF binaries, please pass the installation directory as a parameter to the UnRTF instance.`
121
122
);
122
123
}
123
-
this.unrtfPath=normalizeTrim(this.unrtfPath);
124
+
this.#unrtfPath =normalizeTrim(this.#unrtfPath);
124
125
125
126
/**
126
127
* Get version of UnRTF binary for use in `convert` function.
0 commit comments