@j-o-r/sh 1.1.8 → 1.1.9

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/SH.js CHANGED
@@ -31,7 +31,7 @@ import SHDispatch from './SHDispatch.js';
31
31
  import Test from './Test.js'
32
32
 
33
33
  /**
34
- * @typedef {Object.<string, string | string[]>} ArgsObject
34
+ * @typedef {Object.<string, string>} ArgsObject
35
35
  * @property {string} [key: string] - Any string key maps to a string value
36
36
  * @property {string[]} _ - Array of strings, unnamed parameters
37
37
  * @description Parsed parameters result.
@@ -111,8 +111,6 @@ const SH = new Proxy(function(pieces, ...args) {
111
111
  /**
112
112
  * Create a async/sync context in new execution callstack
113
113
  * @param {function} callback - async/sync function
114
- * @param {ResolveCallback} [resolve] - optional resolve/result callback
115
- * @param {RejectCallback} [reject] - optional reject/error callback
116
114
  * @example
117
115
  * const p = within(async () => {
118
116
  * const res = await Promise.all([
@@ -124,24 +122,8 @@ const SH = new Proxy(function(pieces, ...args) {
124
122
  * return 'res';
125
123
  * });
126
124
  */
127
- const within = (callback, resolve, reject) => {
128
- // optional, custom resolve/reject functions from an outside promise/function
129
- const RCB = jsType(resolve) === 'Function';
130
- const ECB = jsType(reject) === 'Function';
131
- (async () => {
132
- try {
133
- const res = await Promise.resolve(callback());
134
- if (RCB) {
135
- resolve(res);
136
- }
137
- } catch (e) {
138
- if (ECB) {
139
- reject(e)
140
- } else {
141
- throw (e);
142
- }
143
- }
144
- })()
125
+ const within = async (callback) => {
126
+ return await callback();
145
127
  }
146
128
 
147
129
  /**
@@ -297,6 +279,7 @@ const parseArgs = (args) => {
297
279
  result._.push(args[i]);
298
280
  }
299
281
  }
282
+ // @ts-ignore
300
283
  return result;
301
284
  };
302
285
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@j-o-r/sh",
3
3
  "author": "Jorrit Duin <j-o-r@duin.work>",
4
4
  "type": "module",
5
- "version": "1.1.8",
5
+ "version": "1.1.9",
6
6
  "description": "Execute shell commands on Linux-based systems from javascript",
7
7
  "main": "lib/SH.js",
8
8
  "types": "types/SH.d.ts",
@@ -50,4 +50,4 @@
50
50
  "process-promise",
51
51
  "process-output"
52
52
  ]
53
- }
53
+ }
package/types/SH.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export type ArgsObject = {
2
- [x: string]: string | string[];
2
+ [x: string]: string;
3
3
  };
4
4
  export type RejectCallback = Function;
5
5
  export type ResolveCallback = Function;
@@ -54,8 +54,6 @@ export function readIn(): Promise<string>;
54
54
  /**
55
55
  * Create a async/sync context in new execution callstack
56
56
  * @param {function} callback - async/sync function
57
- * @param {ResolveCallback} [resolve] - optional resolve/result callback
58
- * @param {RejectCallback} [reject] - optional reject/error callback
59
57
  * @example
60
58
  * const p = within(async () => {
61
59
  * const res = await Promise.all([
@@ -67,7 +65,7 @@ export function readIn(): Promise<string>;
67
65
  * return 'res';
68
66
  * });
69
67
  */
70
- export function within(callback: Function, resolve?: ResolveCallback, reject?: RejectCallback): void;
68
+ export function within(callback: Function): Promise<any>;
71
69
  /**
72
70
  * Generates an exponential backoff time with a random jitter.
73
71
  *
@@ -94,7 +92,7 @@ export function expBackoff(max?: string, rand?: string): Generator<number, void,
94
92
  */
95
93
  export function parseArgs(args?: string[]): ArgsObject;
96
94
  /**
97
- * @typedef {Object.<string, string | string[]>} ArgsObject
95
+ * @typedef {Object.<string, string>} ArgsObject
98
96
  * @property {string} [key: string] - Any string key maps to a string value
99
97
  * @property {string[]} _ - Array of strings, unnamed parameters
100
98
  * @description Parsed parameters result.