@camjn/getargv 0.0.5 → 0.0.7
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/binding.d.ts +1 -9
- package/dist/binding.js +28 -12
- package/dist/types.d.ts +100 -0
- package/dist/types.js +2 -0
- package/package.json +6 -3
package/dist/binding.d.ts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
interface GetArgv {
|
|
3
|
-
readonly PID_MAX: number;
|
|
4
|
-
readonly ARG_MAX: number;
|
|
5
|
-
get_argv_of_pid(pid: number, nuls: boolean, skip: number): ArrayBuffer;
|
|
6
|
-
as_string(pid: number, encoding: Labels, nuls: boolean, skip: number): String;
|
|
7
|
-
get_argv_and_argc_of_pid(pid: number): Array<ArrayBuffer>;
|
|
8
|
-
as_array(pid: number, encoding: Labels): Array<string>;
|
|
9
|
-
}
|
|
1
|
+
import { GetArgv } from './types';
|
|
10
2
|
declare const addon: GetArgv;
|
|
11
3
|
export = addon;
|
package/dist/binding.js
CHANGED
|
@@ -1,24 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const addon = require('../build/Release/getargv_native');
|
|
3
|
-
addon.as_string = function as_string(pid, encoding, nuls, skip) {
|
|
4
|
-
|
|
5
|
-
throw new TypeError('The "pid" argument must be specified');
|
|
3
|
+
addon.as_string = function as_string(pid, encoding, nuls, skip, options) {
|
|
4
|
+
switch (arguments.length) {
|
|
5
|
+
case 0: throw new TypeError('The "pid" argument must be specified');
|
|
6
|
+
case 1: throw new TypeError('The "encoding" argument must be specified');
|
|
7
|
+
case 2:
|
|
8
|
+
case 3:
|
|
9
|
+
case 4:
|
|
10
|
+
case 5: break;
|
|
11
|
+
default: throw new TypeError('Too many arguments were specified');
|
|
6
12
|
}
|
|
7
|
-
if (
|
|
8
|
-
throw new TypeError('The "
|
|
13
|
+
if (typeof pid !== "number") {
|
|
14
|
+
throw new TypeError('The "pid" argument must be a number');
|
|
9
15
|
}
|
|
10
|
-
|
|
16
|
+
if (typeof encoding !== "string") {
|
|
17
|
+
throw new TypeError(`The "encoding" argument must be a string, is a: ${typeof encoding}`);
|
|
18
|
+
}
|
|
19
|
+
const decoder = new TextDecoder(encoding, options);
|
|
11
20
|
const array = addon.get_argv_of_pid(pid, nuls !== null && nuls !== void 0 ? nuls : false, skip !== null && skip !== void 0 ? skip : 0);
|
|
12
21
|
return decoder.decode(array);
|
|
13
22
|
};
|
|
14
|
-
addon.as_array = function as_array(pid, encoding) {
|
|
15
|
-
|
|
16
|
-
throw new TypeError('The "pid" argument must be specified');
|
|
23
|
+
addon.as_array = function as_array(pid, encoding, options) {
|
|
24
|
+
switch (arguments.length) {
|
|
25
|
+
case 0: throw new TypeError('The "pid" argument must be specified');
|
|
26
|
+
case 1: throw new TypeError('The "encoding" argument must be specified');
|
|
27
|
+
case 2:
|
|
28
|
+
case 3: break;
|
|
29
|
+
default: throw new TypeError('Too many arguments were specified');
|
|
30
|
+
}
|
|
31
|
+
if (typeof pid !== "number") {
|
|
32
|
+
throw new TypeError('The "pid" argument must be a number');
|
|
17
33
|
}
|
|
18
|
-
if (
|
|
19
|
-
throw new TypeError(
|
|
34
|
+
if (typeof encoding !== "string") {
|
|
35
|
+
throw new TypeError(`The "encoding" argument must be a string, is a: ${typeof encoding}`);
|
|
20
36
|
}
|
|
21
|
-
const decoder = new TextDecoder(encoding);
|
|
37
|
+
const decoder = new TextDecoder(encoding, options);
|
|
22
38
|
const array = addon.get_argv_and_argc_of_pid(pid);
|
|
23
39
|
return array.map(b => decoder.decode(b));
|
|
24
40
|
};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
type utf_8 = "unicode-1-1-utf-8" | "utf-8" | "utf8";
|
|
3
|
+
type ibm866 = "866" | "cp866" | "csibm866" | "ibm866";
|
|
4
|
+
type iso_8859_2 = "csisolatin2" | "iso-8859-2" | "iso-ir-101" | "iso8859-2" | "iso88592" | "iso_8859-2" | "iso_8859-2:1987" | "l2" | "latin2";
|
|
5
|
+
type iso_8859_3 = "csisolatin3" | "iso-8859-3" | "iso-ir-109" | "iso8859-3" | "iso88593" | "iso_8859-3" | "iso_8859-3:1988" | "l3" | "latin3";
|
|
6
|
+
type iso_8859_4 = "csisolatin4" | "iso-8859-4" | "iso-ir-110" | "iso8859-4" | "iso88594" | "iso_8859-4" | "iso_8859-4:1988" | "l4" | "latin4";
|
|
7
|
+
type iso_8859_5 = "csisolatincyrillic" | "cyrillic" | "iso-8859-5" | "iso-ir-144" | "iso88595" | "iso_8859-5" | "iso_8859-5:1988";
|
|
8
|
+
type iso_8859_6 = "arabic" | "asmo-708" | "csiso88596e" | "csiso88596i" | "csisolatinarabic" | "ecma-114" | "iso-8859-6" | "iso-8859-6-e" | "iso-8859-6-i" | "iso-ir-127" | "iso8859-6" | "iso88596" | "iso_8859-6" | "iso_8859-6:1987";
|
|
9
|
+
type iso_8859_7 = "csisolatingreek" | "ecma-118" | "elot_928" | "greek" | "greek8" | "iso-8859-7" | "iso-ir-126" | "iso8859-7" | "iso88597" | "iso_8859-7" | "iso_8859-7:1987" | "sun_eu_greek";
|
|
10
|
+
type iso_8859_8 = "csiso88598e" | "csisolatinhebrew" | "hebrew" | "iso-8859-8" | "iso-8859-8-e" | "iso-ir-138" | "iso8859-8" | "iso88598" | "iso_8859-8" | "iso_8859-8:1988" | "visual";
|
|
11
|
+
type iso_8859_8i = "csiso88598i" | "iso-8859-8-i" | "logical";
|
|
12
|
+
type iso_8859_10 = "csisolatin6" | "iso-8859-10" | "iso-ir-157" | "iso8859-10" | "iso885910" | "l6" | "latin6";
|
|
13
|
+
type iso_8859_13 = "iso-8859-13" | "iso8859-13" | "iso885913";
|
|
14
|
+
type iso_8859_14 = "iso-8859-14" | "iso8859-14" | "iso885914";
|
|
15
|
+
type iso_8859_15 = "csisolatin9" | "iso-8859-15" | "iso8859-15" | "iso885915" | "l9" | "latin9";
|
|
16
|
+
type iso_8859_16 = "iso-8859-16";
|
|
17
|
+
type koi8_r = "cskoi8r" | "koi" | "koi8" | "koi8-r" | "koi8_r";
|
|
18
|
+
type koi8_u = "koi8-u";
|
|
19
|
+
type macintosh = "csmacintosh" | "mac" | "macintosh" | "x-mac-roman";
|
|
20
|
+
type windows_874 = "dos-874" | "iso-8859-11" | "iso8859-11" | "iso885911" | "tis-620" | "windows-874";
|
|
21
|
+
type windows_1250 = "cp1250" | "windows-1250" | "x-cp1250";
|
|
22
|
+
type windows_1251 = "cp1251" | "windows-1251" | "x-cp1251";
|
|
23
|
+
type windows_1252 = "ansi_x3.4-1968" | "ascii" | "cp1252" | "cp819" | "csisolatin1" | "ibm819" | "iso-8859-1" | "iso-ir-100" | "iso8859-1" | "iso88591" | "iso_8859-1" | "iso_8859-1:1987" | "l1" | "latin1" | "us-ascii" | "windows-1252" | "x-cp1252";
|
|
24
|
+
type windows_1253 = "cp1253" | "windows-1253" | "x-cp1253";
|
|
25
|
+
type windows_1254 = "cp1254" | "csisolatin5" | "iso-8859-9" | "iso-ir-148" | "iso8859-9" | "iso88599" | "iso_8859-9" | "iso_8859-9:1989" | "l5" | "latin5" | "windows-1254" | "x-cp1254";
|
|
26
|
+
type windows_1255 = "cp1255" | "windows-1255" | "x-cp1255";
|
|
27
|
+
type windows_1256 = "cp1256" | "windows-1256" | "x-cp1256";
|
|
28
|
+
type windows_1257 = "cp1257" | "windows-1257" | "x-cp1257";
|
|
29
|
+
type windows_1258 = "cp1258" | "windows-1258" | "x-cp1258";
|
|
30
|
+
type x_mac_cyrillic = "x-mac-cyrillic" | "x-mac-ukrainian";
|
|
31
|
+
type gbk = "chinese" | "csgb2312" | "csiso58gb231280" | "gb2312" | "gb_2312" | "gb_2312-80" | "gbk" | "iso-ir-58" | "x-gbk";
|
|
32
|
+
type gb18030 = "gb18030";
|
|
33
|
+
type hz_gb_2312 = "hz-gb-2312";
|
|
34
|
+
type big5 = "big5" | "big5-hkscs" | "cn-big5" | "csbig5" | "x-x-big5";
|
|
35
|
+
type euc_jp = "cseucpkdfmtjapanese" | "euc-jp" | "x-euc-jp";
|
|
36
|
+
type iso_2022_jp = "csiso2022jp" | "iso-2022-jp";
|
|
37
|
+
type shift_jis = "csshiftjis" | "ms_kanji" | "shift-jis" | "shift_jis" | "sjis" | "windows-31j" | "x-sjis";
|
|
38
|
+
type euc_kr = "cseuckr" | "csksc56011987" | "euc-kr" | "iso-ir-149" | "korean" | "ks_c_5601-1987" | "ks_c_5601-1989" | "ksc5601" | "ksc_5601" | "windows-949";
|
|
39
|
+
type iso_2022_kr = "csiso2022kr" | "iso-2022-kr";
|
|
40
|
+
type utf_16be = "utf-16be";
|
|
41
|
+
type utf_16le = "utf-16" | "utf-16le";
|
|
42
|
+
type x_user_defined = "x-user-defined";
|
|
43
|
+
type replacement = "iso-2022-cn" | "iso-2022-cn-ext";
|
|
44
|
+
export type TextEncoding = utf_8 | ibm866 | iso_8859_2 | iso_8859_3 | iso_8859_4 | iso_8859_5 | iso_8859_6 | iso_8859_7 | iso_8859_8 | iso_8859_8i | iso_8859_10 | iso_8859_13 | iso_8859_14 | iso_8859_15 | iso_8859_16 | koi8_r | koi8_u | macintosh | windows_874 | windows_1250 | windows_1251 | windows_1252 | windows_1253 | windows_1254 | windows_1255 | windows_1256 | windows_1257 | windows_1258 | x_mac_cyrillic | gbk | gb18030 | hz_gb_2312 | big5 | euc_jp | iso_2022_jp | shift_jis | euc_kr | iso_2022_kr | utf_16be | utf_16le | x_user_defined | replacement;
|
|
45
|
+
export type TextDecoderOptions = ConstructorParameters<typeof TextDecoder>[1];
|
|
46
|
+
export interface GetArgv {
|
|
47
|
+
/** @constant
|
|
48
|
+
* @description the maximum value a pid may have on the system
|
|
49
|
+
*/
|
|
50
|
+
readonly PID_MAX: number;
|
|
51
|
+
/** @constant
|
|
52
|
+
* @description the maximum number of bytes that can be passed as args to a process (including env vars, etc)
|
|
53
|
+
*/
|
|
54
|
+
readonly ARG_MAX: number;
|
|
55
|
+
/**
|
|
56
|
+
* Gets the arguments of a process as an ArrayBuffer
|
|
57
|
+
* @param pid - The pid of the process whose arguments you want, must be between 0..{@link PID_MAX} inclusive.
|
|
58
|
+
* @param nuls - Whether to replace nul bytes with spaces for human consumption.
|
|
59
|
+
* @param skip - The number of leading args to skip past.
|
|
60
|
+
* @returns An ArrayBuffer representing the arguments of pid, formatted as requested.
|
|
61
|
+
* @throws {@link TypeError} if called with: missing pid argument, invalid number as pid, invalid number as skip.
|
|
62
|
+
* @throws {@link RangeError} if called with pid outside valid range: 0..{@link PID_MAX} inclusive.
|
|
63
|
+
* @throws {@link SystemError} if the underlying sysctl or parsing fails.
|
|
64
|
+
*/
|
|
65
|
+
get_argv_of_pid(pid: number, nuls: boolean, skip: number): ArrayBuffer;
|
|
66
|
+
/**
|
|
67
|
+
* Gets the arguments of a process as a string
|
|
68
|
+
* @param pid - The pid of the process whose arguments you want, must be between 0..{@link PID_MAX} inclusive.
|
|
69
|
+
* @param encoding - The encoding to attempt to apply to the arguments. Must be an enumerated value of {@link TextEncoding}.
|
|
70
|
+
* @param nuls - Whether to replace nul bytes with spaces for human consumption.
|
|
71
|
+
* @param skip - The number of leading args to skip past.
|
|
72
|
+
* @param options - The options to use when decoding the process' arguments' bytes into a string.
|
|
73
|
+
* @returns A string representing the arguments of pid, formatted as requested.
|
|
74
|
+
* @throws {@link TypeError} if called with: missing pid, missing encoding argument, invalid number as pid, invalid number as skip, or if `options.fatal` is true and it encounters malformed data while decoding.
|
|
75
|
+
* @throws {@link RangeError} if called with invalid encoding argument or pid outside valid range: 0..{@link PID_MAX} inclusive.
|
|
76
|
+
* @throws {@link SystemError} if the underlying sysctl or parsing fails.
|
|
77
|
+
*/
|
|
78
|
+
as_string(pid: number, encoding: TextEncoding, nuls?: boolean, skip?: number, options?: TextDecoderOptions): string;
|
|
79
|
+
/**
|
|
80
|
+
* Gets the arguments of a process as an array of ArrayBuffers
|
|
81
|
+
* @param pid - The pid of the process whose arguments you want, must be between 0..{@link PID_MAX} inclusive.
|
|
82
|
+
* @returns An array of ArrayBuffers representing the arguments of pid.
|
|
83
|
+
* @throws {@link TypeError} if called with: missing pid, too many arguments, invalid number as pid.
|
|
84
|
+
* @throws {@link RangeError} if called with pid outside valid range: 0..{@link PID_MAX} inclusive.
|
|
85
|
+
* @throws {@link SystemError} if the underlying sysctl or parsing fails.
|
|
86
|
+
*/
|
|
87
|
+
get_argv_and_argc_of_pid(pid: number): Array<ArrayBuffer>;
|
|
88
|
+
/**
|
|
89
|
+
* Gets the arguments of a process as an array of strings
|
|
90
|
+
* @param pid - The pid of the process whose arguments you want, must be between 0..{@link PID_MAX} inclusive.
|
|
91
|
+
* @param encoding - The encoding to attempt to apply to the arguments. Must be an enumerated value of {@link TextEncoding}.
|
|
92
|
+
* @param options - The options to use when decoding the process' arguments' bytes into strings.
|
|
93
|
+
* @returns An array of strings representing the arguments of pid.
|
|
94
|
+
* @throws {@link TypeError} if called with: missing pid, missing encoding argument, too many arguments, invalid number as pid, or if `options.fatal` is true and it encounters malformed data while decoding.
|
|
95
|
+
* @throws {@link RangeError} if called with: invalid encoding argument, pid outside valid range: 0..{@link PID_MAX} inclusive.
|
|
96
|
+
* @throws {@link SystemError} if the underlying sysctl or parsing fails.
|
|
97
|
+
*/
|
|
98
|
+
as_array(pid: number, encoding: TextEncoding, options?: TextDecoderOptions): Array<string>;
|
|
99
|
+
}
|
|
100
|
+
export {};
|
package/dist/types.js
ADDED
package/package.json
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
"getargv": "lib/cli.js"
|
|
4
4
|
},
|
|
5
5
|
"devDependencies": {
|
|
6
|
-
"@types/node": "^18.
|
|
7
|
-
"
|
|
6
|
+
"@types/node": "^18.15.5",
|
|
7
|
+
"typedoc": "^0.23.28",
|
|
8
|
+
"typedoc-plugin-missing-exports": "^1.0.0",
|
|
9
|
+
"typescript": "^5.0.2"
|
|
8
10
|
},
|
|
9
11
|
"os": [
|
|
10
12
|
"darwin"
|
|
@@ -16,7 +18,7 @@
|
|
|
16
18
|
"name": "@camjn/getargv",
|
|
17
19
|
"homepage": "https://getargv.narzt.cam/",
|
|
18
20
|
"author": "Camden Narzt <getargv@narzt.cam>",
|
|
19
|
-
"version": "0.0.
|
|
21
|
+
"version": "0.0.7",
|
|
20
22
|
"description": "This library allows you to query the arguments of other processes on macOS.",
|
|
21
23
|
"main": "dist/binding.js",
|
|
22
24
|
"scripts": {
|
|
@@ -29,6 +31,7 @@
|
|
|
29
31
|
"cli": "node dist/cli.js",
|
|
30
32
|
"preconsole": "npm run build",
|
|
31
33
|
"console": "node --napi-modules -r ./dist/binding.js -e 'const GetArgv = require.cache[Object.keys(require.cache)[0]].exports;' -i",
|
|
34
|
+
"docs": "typedoc --tsconfig $PWD/tsconfig.json lib/types.ts",
|
|
32
35
|
"start": "npm run console"
|
|
33
36
|
},
|
|
34
37
|
"files": [
|