@hugoalh/adler32 0.5.1 → 0.6.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.
- package/README.md +22 -0
- package/_dnt.polyfills.d.ts +111 -0
- package/_dnt.polyfills.d.ts.map +1 -0
- package/_dnt.polyfills.js +141 -0
- package/_dnt.shims.d.ts +12 -0
- package/_dnt.shims.d.ts.map +1 -0
- package/_dnt.shims.js +70 -0
- package/cli.d.ts +3 -0
- package/cli.d.ts.map +1 -0
- package/cli.js +102 -0
- package/deps/jsr.io/@std/cli/1.0.32/parse_args.d.ts +343 -0
- package/deps/jsr.io/@std/cli/1.0.32/parse_args.d.ts.map +1 -0
- package/deps/jsr.io/@std/cli/1.0.32/parse_args.js +372 -0
- package/mod.d.ts +1 -0
- package/mod.d.ts.map +1 -1
- package/mod.js +5 -3
- package/package.json +14 -2
package/README.md
CHANGED
|
@@ -40,6 +40,7 @@ This does not request any runtime permission.
|
|
|
40
40
|
| **Name** | **Path** | **Description** |
|
|
41
41
|
|:--|:--|:--|
|
|
42
42
|
| `.` | `./mod.ts` | Default. |
|
|
43
|
+
| `./cli` | `./cli.ts` | CLI. |
|
|
43
44
|
|
|
44
45
|
> [!NOTE]
|
|
45
46
|
> - Different runtimes have vary support for the sources and entrypoints, visit the runtime documentation for more information.
|
|
@@ -76,9 +77,30 @@ This does not request any runtime permission.
|
|
|
76
77
|
> - [Deno CLI `deno doc`](https://docs.deno.com/runtime/reference/cli/doc/)
|
|
77
78
|
> - [JSR](https://jsr.io/@hugoalh/adler32)
|
|
78
79
|
|
|
80
|
+
## 🧩 CLIs
|
|
81
|
+
|
|
82
|
+
- ```powershell
|
|
83
|
+
adler32 $Context
|
|
84
|
+
```
|
|
85
|
+
- ```powershell
|
|
86
|
+
adler32 --file $FilePath
|
|
87
|
+
<# 🔀 Unordered Positions: `--file`, `$FilePath` #>
|
|
88
|
+
```
|
|
89
|
+
- ```powershell
|
|
90
|
+
adler32 --stdin
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
| **Argument** | **Type** | **Description** |
|
|
94
|
+
|:--|:--|:--|
|
|
95
|
+
| `file` | `switch` | Whether the resource is from file. |
|
|
96
|
+
| `stdin` | `switch` | Whether the resource is from standard stream input. |
|
|
97
|
+
|
|
79
98
|
## ✍️ Examples
|
|
80
99
|
|
|
81
100
|
- ```ts
|
|
82
101
|
new Adler32("Wikipedia").hashHex();
|
|
83
102
|
//=> "11E60398"
|
|
84
103
|
```
|
|
104
|
+
- ```powershell
|
|
105
|
+
adler32 'Wikipedia'
|
|
106
|
+
```
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Based on [import-meta-ponyfill](https://github.com/gaubee/import-meta-ponyfill),
|
|
3
|
+
* but instead of using npm to install additional dependencies,
|
|
4
|
+
* this approach manually consolidates cjs/mjs/d.ts into a single file.
|
|
5
|
+
*
|
|
6
|
+
* Note that this code might be imported multiple times
|
|
7
|
+
* (for example, both dnt.test.polyfills.ts and dnt.polyfills.ts contain this code;
|
|
8
|
+
* or Node.js might dynamically clear the cache and then force a require).
|
|
9
|
+
* Therefore, it's important to avoid redundant writes to global objects.
|
|
10
|
+
* Additionally, consider that commonjs is used alongside esm,
|
|
11
|
+
* so the two ponyfill functions are stored independently in two separate global objects.
|
|
12
|
+
*/
|
|
13
|
+
import { createRequire } from "node:module";
|
|
14
|
+
import { type URL } from "node:url";
|
|
15
|
+
declare global {
|
|
16
|
+
interface ImportMeta {
|
|
17
|
+
/** A string representation of the fully qualified module URL. When the
|
|
18
|
+
* module is loaded locally, the value will be a file URL (e.g.
|
|
19
|
+
* `file:///path/module.ts`).
|
|
20
|
+
*
|
|
21
|
+
* You can also parse the string as a URL to determine more information about
|
|
22
|
+
* how the current module was loaded. For example to determine if a module was
|
|
23
|
+
* local or not:
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* const url = new URL(import.meta.url);
|
|
27
|
+
* if (url.protocol === "file:") {
|
|
28
|
+
* console.log("this module was loaded locally");
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
url: string;
|
|
33
|
+
/**
|
|
34
|
+
* A function that returns resolved specifier as if it would be imported
|
|
35
|
+
* using `import(specifier)`.
|
|
36
|
+
*
|
|
37
|
+
* ```ts
|
|
38
|
+
* console.log(import.meta.resolve("./foo.js"));
|
|
39
|
+
* // file:///dev/foo.js
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @param specifier The module specifier to resolve relative to `parent`.
|
|
43
|
+
* @param parent The absolute parent module URL to resolve from.
|
|
44
|
+
* @returns The absolute (`file:`) URL string for the resolved module.
|
|
45
|
+
*/
|
|
46
|
+
resolve(specifier: string, parent?: string | URL | undefined): string;
|
|
47
|
+
/** A flag that indicates if the current module is the main module that was
|
|
48
|
+
* called when starting the program under Deno.
|
|
49
|
+
*
|
|
50
|
+
* ```ts
|
|
51
|
+
* if (import.meta.main) {
|
|
52
|
+
* // this was loaded as the main module, maybe do some bootstrapping
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
main: boolean;
|
|
57
|
+
/** The absolute path of the current module.
|
|
58
|
+
*
|
|
59
|
+
* This property is only provided for local modules (ie. using `file://` URLs).
|
|
60
|
+
*
|
|
61
|
+
* Example:
|
|
62
|
+
* ```
|
|
63
|
+
* // Unix
|
|
64
|
+
* console.log(import.meta.filename); // /home/alice/my_module.ts
|
|
65
|
+
*
|
|
66
|
+
* // Windows
|
|
67
|
+
* console.log(import.meta.filename); // C:\alice\my_module.ts
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
filename: string;
|
|
71
|
+
/** The absolute path of the directory containing the current module.
|
|
72
|
+
*
|
|
73
|
+
* This property is only provided for local modules (ie. using `file://` URLs).
|
|
74
|
+
*
|
|
75
|
+
* * Example:
|
|
76
|
+
* ```
|
|
77
|
+
* // Unix
|
|
78
|
+
* console.log(import.meta.dirname); // /home/alice
|
|
79
|
+
*
|
|
80
|
+
* // Windows
|
|
81
|
+
* console.log(import.meta.dirname); // C:\alice
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
dirname: string;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
type NodeRequest = ReturnType<typeof createRequire>;
|
|
88
|
+
type NodeModule = NonNullable<NodeRequest["main"]>;
|
|
89
|
+
interface ImportMetaPonyfillCommonjs {
|
|
90
|
+
(require: NodeRequest, module: NodeModule): ImportMeta;
|
|
91
|
+
}
|
|
92
|
+
interface ImportMetaPonyfillEsmodule {
|
|
93
|
+
(importMeta: ImportMeta): ImportMeta;
|
|
94
|
+
}
|
|
95
|
+
interface ImportMetaPonyfill extends ImportMetaPonyfillCommonjs, ImportMetaPonyfillEsmodule {
|
|
96
|
+
}
|
|
97
|
+
export declare let import_meta_ponyfill_commonjs: ImportMetaPonyfillCommonjs;
|
|
98
|
+
export declare let import_meta_ponyfill_esmodule: ImportMetaPonyfillEsmodule;
|
|
99
|
+
export declare let import_meta_ponyfill: ImportMetaPonyfill;
|
|
100
|
+
declare global {
|
|
101
|
+
interface Object {
|
|
102
|
+
/**
|
|
103
|
+
* Determines whether an object has a property with the specified name.
|
|
104
|
+
* @param o An object.
|
|
105
|
+
* @param v A property name.
|
|
106
|
+
*/
|
|
107
|
+
hasOwn(o: object, v: PropertyKey): boolean;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
export {};
|
|
111
|
+
//# sourceMappingURL=_dnt.polyfills.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_dnt.polyfills.d.ts","sourceRoot":"","sources":["src/_dnt.polyfills.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAgC,KAAK,GAAG,EAAE,MAAM,UAAU,CAAC;AAGlE,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,UAAU;QAClB;;;;;;;;;;;;;;WAcG;QACH,GAAG,EAAE,MAAM,CAAC;QACZ;;;;;;;;;;;;WAYG;QACH,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS,GAAG,MAAM,CAAC;QACtE;;;;;;;;WAQG;QACH,IAAI,EAAE,OAAO,CAAC;QAEd;;;;;;;;;;;;WAYG;QACH,QAAQ,EAAE,MAAM,CAAC;QAEjB;;;;;;;;;;;;WAYG;QACH,OAAO,EAAE,MAAM,CAAC;KACjB;CACF;AAED,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACpD,KAAK,UAAU,GAAG,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;AACnD,UAAU,0BAA0B;IAClC,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC;CACxD;AACD,UAAU,0BAA0B;IAClC,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAAC;CACtC;AACD,UAAU,kBACR,SAAQ,0BAA0B,EAAE,0BAA0B;CAC/D;AAiBD,eAAO,IAAI,6BAA6B,EA2BnC,0BAA0B,CAAC;AAMhC,eAAO,IAAI,6BAA6B,EA4DnC,0BAA0B,CAAC;AAMhC,eAAO,IAAI,oBAAoB,EAoB1B,kBAAkB,CAAC;AAgBxB,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd;;;;WAIG;QACH,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC;KAC5C;CACF;AAED,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Based on [import-meta-ponyfill](https://github.com/gaubee/import-meta-ponyfill),
|
|
3
|
+
* but instead of using npm to install additional dependencies,
|
|
4
|
+
* this approach manually consolidates cjs/mjs/d.ts into a single file.
|
|
5
|
+
*
|
|
6
|
+
* Note that this code might be imported multiple times
|
|
7
|
+
* (for example, both dnt.test.polyfills.ts and dnt.polyfills.ts contain this code;
|
|
8
|
+
* or Node.js might dynamically clear the cache and then force a require).
|
|
9
|
+
* Therefore, it's important to avoid redundant writes to global objects.
|
|
10
|
+
* Additionally, consider that commonjs is used alongside esm,
|
|
11
|
+
* so the two ponyfill functions are stored independently in two separate global objects.
|
|
12
|
+
*/
|
|
13
|
+
//@ts-ignore
|
|
14
|
+
import { createRequire } from "node:module";
|
|
15
|
+
//@ts-ignore
|
|
16
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
17
|
+
//@ts-ignore
|
|
18
|
+
import { dirname } from "node:path";
|
|
19
|
+
const defineGlobalPonyfill = (symbolFor, fn) => {
|
|
20
|
+
if (!Reflect.has(globalThis, Symbol.for(symbolFor))) {
|
|
21
|
+
Object.defineProperty(globalThis, Symbol.for(symbolFor), {
|
|
22
|
+
configurable: true,
|
|
23
|
+
get() {
|
|
24
|
+
return fn;
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
export let import_meta_ponyfill_commonjs = (Reflect.get(globalThis, Symbol.for("import-meta-ponyfill-commonjs")) ??
|
|
30
|
+
(() => {
|
|
31
|
+
const moduleImportMetaWM = new WeakMap();
|
|
32
|
+
return (require, module) => {
|
|
33
|
+
let importMetaCache = moduleImportMetaWM.get(module);
|
|
34
|
+
if (importMetaCache == null) {
|
|
35
|
+
const importMeta = Object.assign(Object.create(null), {
|
|
36
|
+
url: pathToFileURL(module.filename).href,
|
|
37
|
+
main: require.main == module,
|
|
38
|
+
resolve: (specifier, parentURL = importMeta.url) => {
|
|
39
|
+
return pathToFileURL((importMeta.url === parentURL
|
|
40
|
+
? require
|
|
41
|
+
: createRequire(parentURL))
|
|
42
|
+
.resolve(specifier)).href;
|
|
43
|
+
},
|
|
44
|
+
filename: module.filename,
|
|
45
|
+
dirname: module.path,
|
|
46
|
+
});
|
|
47
|
+
moduleImportMetaWM.set(module, importMeta);
|
|
48
|
+
importMetaCache = importMeta;
|
|
49
|
+
}
|
|
50
|
+
return importMetaCache;
|
|
51
|
+
};
|
|
52
|
+
})());
|
|
53
|
+
defineGlobalPonyfill("import-meta-ponyfill-commonjs", import_meta_ponyfill_commonjs);
|
|
54
|
+
export let import_meta_ponyfill_esmodule = (Reflect.get(globalThis, Symbol.for("import-meta-ponyfill-esmodule")) ??
|
|
55
|
+
((importMeta) => {
|
|
56
|
+
const resolveFunStr = String(importMeta.resolve);
|
|
57
|
+
const shimWs = new WeakSet();
|
|
58
|
+
//@ts-ignore
|
|
59
|
+
const mainUrl = ("file:///" + process.argv[1].replace(/\\/g, "/"))
|
|
60
|
+
.replace(/\/{3,}/, "///");
|
|
61
|
+
const commonShim = (importMeta) => {
|
|
62
|
+
if (typeof importMeta.main !== "boolean") {
|
|
63
|
+
importMeta.main = importMeta.url === mainUrl;
|
|
64
|
+
}
|
|
65
|
+
if (typeof importMeta.filename !== "string") {
|
|
66
|
+
importMeta.filename = fileURLToPath(importMeta.url);
|
|
67
|
+
importMeta.dirname = dirname(importMeta.filename);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
if (
|
|
71
|
+
// v16.2.0+, v14.18.0+: Add support for WHATWG URL object to parentURL parameter.
|
|
72
|
+
resolveFunStr === "undefined" ||
|
|
73
|
+
// v20.0.0+, v18.19.0+"" This API now returns a string synchronously instead of a Promise.
|
|
74
|
+
resolveFunStr.startsWith("async")
|
|
75
|
+
// enable by --experimental-import-meta-resolve flag
|
|
76
|
+
) {
|
|
77
|
+
import_meta_ponyfill_esmodule = (importMeta) => {
|
|
78
|
+
if (!shimWs.has(importMeta)) {
|
|
79
|
+
shimWs.add(importMeta);
|
|
80
|
+
const importMetaUrlRequire = {
|
|
81
|
+
url: importMeta.url,
|
|
82
|
+
require: createRequire(importMeta.url),
|
|
83
|
+
};
|
|
84
|
+
importMeta.resolve = function resolve(specifier, parentURL = importMeta.url) {
|
|
85
|
+
return pathToFileURL((importMetaUrlRequire.url === parentURL
|
|
86
|
+
? importMetaUrlRequire.require
|
|
87
|
+
: createRequire(parentURL)).resolve(specifier)).href;
|
|
88
|
+
};
|
|
89
|
+
commonShim(importMeta);
|
|
90
|
+
}
|
|
91
|
+
return importMeta;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
/// native support
|
|
96
|
+
import_meta_ponyfill_esmodule = (importMeta) => {
|
|
97
|
+
if (!shimWs.has(importMeta)) {
|
|
98
|
+
shimWs.add(importMeta);
|
|
99
|
+
commonShim(importMeta);
|
|
100
|
+
}
|
|
101
|
+
return importMeta;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return import_meta_ponyfill_esmodule(importMeta);
|
|
105
|
+
}));
|
|
106
|
+
defineGlobalPonyfill("import-meta-ponyfill-esmodule", import_meta_ponyfill_esmodule);
|
|
107
|
+
export let import_meta_ponyfill = ((...args) => {
|
|
108
|
+
const _MODULE = (() => {
|
|
109
|
+
if (typeof require === "function" && typeof module === "object") {
|
|
110
|
+
return "commonjs";
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
// eval("typeof import.meta");
|
|
114
|
+
return "esmodule";
|
|
115
|
+
}
|
|
116
|
+
})();
|
|
117
|
+
if (_MODULE === "commonjs") {
|
|
118
|
+
//@ts-ignore
|
|
119
|
+
import_meta_ponyfill = (r, m) => import_meta_ponyfill_commonjs(r, m);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
//@ts-ignore
|
|
123
|
+
import_meta_ponyfill = (im) => import_meta_ponyfill_esmodule(im);
|
|
124
|
+
}
|
|
125
|
+
//@ts-ignore
|
|
126
|
+
return import_meta_ponyfill(...args);
|
|
127
|
+
});
|
|
128
|
+
// https://github.com/tc39/proposal-accessible-object-hasownproperty/blob/main/polyfill.js
|
|
129
|
+
if (!Object.hasOwn) {
|
|
130
|
+
Object.defineProperty(Object, "hasOwn", {
|
|
131
|
+
value: function (object, property) {
|
|
132
|
+
if (object == null) {
|
|
133
|
+
throw new TypeError("Cannot convert undefined or null to object");
|
|
134
|
+
}
|
|
135
|
+
return Object.prototype.hasOwnProperty.call(Object(object), property);
|
|
136
|
+
},
|
|
137
|
+
configurable: true,
|
|
138
|
+
enumerable: false,
|
|
139
|
+
writable: true,
|
|
140
|
+
});
|
|
141
|
+
}
|
package/_dnt.shims.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { Deno } from "@deno/shim-deno";
|
|
2
|
+
export { alert, confirm, prompt } from "@deno/shim-prompts";
|
|
3
|
+
export { setInterval, setTimeout } from "@deno/shim-timers";
|
|
4
|
+
export declare const dntGlobalThis: Omit<typeof globalThis, "Deno" | "alert" | "confirm" | "prompt" | "setInterval" | "setTimeout"> & {
|
|
5
|
+
Deno: any;
|
|
6
|
+
alert: any;
|
|
7
|
+
confirm: any;
|
|
8
|
+
prompt: any;
|
|
9
|
+
setInterval: any;
|
|
10
|
+
setTimeout: any;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=_dnt.shims.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_dnt.shims.d.ts","sourceRoot":"","sources":["src/_dnt.shims.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAU5D,eAAO,MAAM,aAAa;;;;;;;CAA2C,CAAC"}
|
package/_dnt.shims.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Deno } from "@deno/shim-deno";
|
|
2
|
+
export { Deno } from "@deno/shim-deno";
|
|
3
|
+
import { alert, confirm, prompt } from "@deno/shim-prompts";
|
|
4
|
+
export { alert, confirm, prompt } from "@deno/shim-prompts";
|
|
5
|
+
import { setInterval, setTimeout } from "@deno/shim-timers";
|
|
6
|
+
export { setInterval, setTimeout } from "@deno/shim-timers";
|
|
7
|
+
const dntGlobals = {
|
|
8
|
+
Deno,
|
|
9
|
+
alert,
|
|
10
|
+
confirm,
|
|
11
|
+
prompt,
|
|
12
|
+
setInterval,
|
|
13
|
+
setTimeout,
|
|
14
|
+
};
|
|
15
|
+
export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
|
|
16
|
+
function createMergeProxy(baseObj, extObj) {
|
|
17
|
+
return new Proxy(baseObj, {
|
|
18
|
+
get(_target, prop, _receiver) {
|
|
19
|
+
if (prop in extObj) {
|
|
20
|
+
return extObj[prop];
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
return baseObj[prop];
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
set(_target, prop, value) {
|
|
27
|
+
if (prop in extObj) {
|
|
28
|
+
delete extObj[prop];
|
|
29
|
+
}
|
|
30
|
+
baseObj[prop] = value;
|
|
31
|
+
return true;
|
|
32
|
+
},
|
|
33
|
+
deleteProperty(_target, prop) {
|
|
34
|
+
let success = false;
|
|
35
|
+
if (prop in extObj) {
|
|
36
|
+
delete extObj[prop];
|
|
37
|
+
success = true;
|
|
38
|
+
}
|
|
39
|
+
if (prop in baseObj) {
|
|
40
|
+
delete baseObj[prop];
|
|
41
|
+
success = true;
|
|
42
|
+
}
|
|
43
|
+
return success;
|
|
44
|
+
},
|
|
45
|
+
ownKeys(_target) {
|
|
46
|
+
const baseKeys = Reflect.ownKeys(baseObj);
|
|
47
|
+
const extKeys = Reflect.ownKeys(extObj);
|
|
48
|
+
const extKeysSet = new Set(extKeys);
|
|
49
|
+
return [...baseKeys.filter((k) => !extKeysSet.has(k)), ...extKeys];
|
|
50
|
+
},
|
|
51
|
+
defineProperty(_target, prop, desc) {
|
|
52
|
+
if (prop in extObj) {
|
|
53
|
+
delete extObj[prop];
|
|
54
|
+
}
|
|
55
|
+
Reflect.defineProperty(baseObj, prop, desc);
|
|
56
|
+
return true;
|
|
57
|
+
},
|
|
58
|
+
getOwnPropertyDescriptor(_target, prop) {
|
|
59
|
+
if (prop in extObj) {
|
|
60
|
+
return Reflect.getOwnPropertyDescriptor(extObj, prop);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
return Reflect.getOwnPropertyDescriptor(baseObj, prop);
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
has(_target, prop) {
|
|
67
|
+
return prop in extObj || prop in baseObj;
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|
package/cli.d.ts
ADDED
package/cli.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["src/cli.ts"],"names":[],"mappings":";AACA,OAAO,qBAAqB,CAAC;AAC7B,OAAO,qBAAqB,CAAC"}
|
package/cli.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import "./_dnt.polyfills.js";
|
|
3
|
+
import * as dntShim from "./_dnt.shims.js";
|
|
4
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
5
|
+
if (value !== null && value !== void 0) {
|
|
6
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
7
|
+
var dispose, inner;
|
|
8
|
+
if (async) {
|
|
9
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
10
|
+
dispose = value[Symbol.asyncDispose];
|
|
11
|
+
}
|
|
12
|
+
if (dispose === void 0) {
|
|
13
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
14
|
+
dispose = value[Symbol.dispose];
|
|
15
|
+
if (async) inner = dispose;
|
|
16
|
+
}
|
|
17
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
18
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
19
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
20
|
+
}
|
|
21
|
+
else if (async) {
|
|
22
|
+
env.stack.push({ async: true });
|
|
23
|
+
}
|
|
24
|
+
return value;
|
|
25
|
+
};
|
|
26
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
27
|
+
return function (env) {
|
|
28
|
+
function fail(e) {
|
|
29
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
30
|
+
env.hasError = true;
|
|
31
|
+
}
|
|
32
|
+
var r, s = 0;
|
|
33
|
+
function next() {
|
|
34
|
+
while (r = env.stack.pop()) {
|
|
35
|
+
try {
|
|
36
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
37
|
+
if (r.dispose) {
|
|
38
|
+
var result = r.dispose.call(r.value);
|
|
39
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
40
|
+
}
|
|
41
|
+
else s |= 1;
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
fail(e);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
48
|
+
if (env.hasError) throw env.error;
|
|
49
|
+
}
|
|
50
|
+
return next();
|
|
51
|
+
};
|
|
52
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
53
|
+
var e = new Error(message);
|
|
54
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
55
|
+
});
|
|
56
|
+
import { parseArgs } from "./deps/jsr.io/@std/cli/1.0.32/parse_args.js";
|
|
57
|
+
import { Adler32 } from "./mod.js";
|
|
58
|
+
if (!globalThis[Symbol.for("import-meta-ponyfill-esmodule")](import.meta).main) {
|
|
59
|
+
throw new Error(`This entrypoint is for command line only!`);
|
|
60
|
+
}
|
|
61
|
+
const args = parseArgs(dntShim.Deno.args, {
|
|
62
|
+
boolean: [
|
|
63
|
+
"file",
|
|
64
|
+
"stdin"
|
|
65
|
+
]
|
|
66
|
+
});
|
|
67
|
+
const fromFile = args.file;
|
|
68
|
+
const fromStdin = args.stdin;
|
|
69
|
+
const argsValues = args._.map((value) => {
|
|
70
|
+
return String(value);
|
|
71
|
+
});
|
|
72
|
+
if (fromFile && fromStdin) {
|
|
73
|
+
throw new SyntaxError(`Unable to request resource from file and stdin together!`);
|
|
74
|
+
}
|
|
75
|
+
const expectArgumentsLength = fromStdin ? 0 : 1;
|
|
76
|
+
if (argsValues.length !== expectArgumentsLength) {
|
|
77
|
+
throw new SyntaxError(`Invalid arguments length! Expect: ${expectArgumentsLength}, Current: ${argsValues.length}.`);
|
|
78
|
+
}
|
|
79
|
+
const instance = new Adler32();
|
|
80
|
+
if (fromFile) {
|
|
81
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
82
|
+
try {
|
|
83
|
+
const file = __addDisposableResource(env_1, await dntShim.Deno.open(argsValues[0]), true);
|
|
84
|
+
await instance.updateFromStream(file.readable);
|
|
85
|
+
}
|
|
86
|
+
catch (e_1) {
|
|
87
|
+
env_1.error = e_1;
|
|
88
|
+
env_1.hasError = true;
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
91
|
+
const result_1 = __disposeResources(env_1);
|
|
92
|
+
if (result_1)
|
|
93
|
+
await result_1;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
else if (fromStdin) {
|
|
97
|
+
await instance.updateFromStream(dntShim.Deno.stdin.readable);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
instance.update(argsValues[0]);
|
|
101
|
+
}
|
|
102
|
+
console.log(instance.hashHex());
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command line arguments parser based on
|
|
3
|
+
* {@link https://github.com/minimistjs/minimist | minimist}.
|
|
4
|
+
*
|
|
5
|
+
* See {@linkcode parseArgs} for more information.
|
|
6
|
+
*
|
|
7
|
+
* @example Usage
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { parseArgs } from "@std/cli/parse-args";
|
|
10
|
+
* import { assertEquals } from "@std/assert/equals";
|
|
11
|
+
*
|
|
12
|
+
* // For proper use, one should use `parseArgs(Deno.args)`
|
|
13
|
+
* assertEquals(parseArgs(["--foo", "--bar=baz", "./quux.txt"]), {
|
|
14
|
+
* foo: true,
|
|
15
|
+
* bar: "baz",
|
|
16
|
+
* _: ["./quux.txt"],
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @example `string` and `boolean` options
|
|
21
|
+
*
|
|
22
|
+
* Use `string` and `boolean` options to specify the type of the argument.
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { parseArgs } from "@std/cli/parse-args";
|
|
26
|
+
* import { assertEquals } from "@std/assert/equals";
|
|
27
|
+
*
|
|
28
|
+
* const args = parseArgs(["--foo", "--bar", "baz"], {
|
|
29
|
+
* boolean: ["foo"],
|
|
30
|
+
* string: ["bar"],
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* assertEquals(args, { foo: true, bar: "baz", _: [] });
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example `collect` option
|
|
37
|
+
*
|
|
38
|
+
* `collect` option tells the parser to treat the option as an array. All
|
|
39
|
+
* values will be collected into one array. If a non-collectable option is used
|
|
40
|
+
* multiple times, the last value is used.
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* import { parseArgs } from "@std/cli/parse-args";
|
|
44
|
+
* import { assertEquals } from "@std/assert/equals";
|
|
45
|
+
*
|
|
46
|
+
* const args = parseArgs(["--foo", "bar", "--foo", "baz"], {
|
|
47
|
+
* collect: ["foo"],
|
|
48
|
+
* });
|
|
49
|
+
*
|
|
50
|
+
* assertEquals(args, { foo: ["bar", "baz"], _: [] });
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @example `negatable` option
|
|
54
|
+
*
|
|
55
|
+
* `negatable` option tells the parser to treat the option can be negated by
|
|
56
|
+
* prefixing them with `--no-`, like `--no-config`.
|
|
57
|
+
*
|
|
58
|
+
* ```ts
|
|
59
|
+
* import { parseArgs } from "@std/cli/parse-args";
|
|
60
|
+
* import { assertEquals } from "@std/assert/equals";
|
|
61
|
+
*
|
|
62
|
+
* const args = parseArgs(["--no-foo"], {
|
|
63
|
+
* boolean: ["foo"],
|
|
64
|
+
* negatable: ["foo"],
|
|
65
|
+
* });
|
|
66
|
+
*
|
|
67
|
+
* assertEquals(args, { foo: false, _: [] });
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @module
|
|
71
|
+
*/
|
|
72
|
+
/** Combines recursively all intersection types and returns a new single type.
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
type Id<TRecord> = TRecord extends Record<string, unknown> ? TRecord extends infer InferredRecord ? {
|
|
76
|
+
[Key in keyof InferredRecord]: Id<InferredRecord[Key]>;
|
|
77
|
+
} : never : TRecord;
|
|
78
|
+
/** Converts a union type `A | B | C` into an intersection type `A & B & C`.
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
type UnionToIntersection<TValue> = (TValue extends unknown ? (args: TValue) => unknown : never) extends (args: infer R) => unknown ? R extends Record<string, unknown> ? R : never : never;
|
|
82
|
+
/** @internal */
|
|
83
|
+
type BooleanType = boolean | string | undefined;
|
|
84
|
+
/** @internal */
|
|
85
|
+
type StringType = string | undefined;
|
|
86
|
+
/** @internal */
|
|
87
|
+
type ArgType = StringType | BooleanType;
|
|
88
|
+
/** @internal */
|
|
89
|
+
type Collectable = string | undefined;
|
|
90
|
+
/** @internal */
|
|
91
|
+
type Negatable = string | undefined;
|
|
92
|
+
type UseTypes<TBooleans extends BooleanType, TStrings extends StringType, TCollectable extends Collectable> = undefined extends ((false extends TBooleans ? undefined : TBooleans) & TCollectable & TStrings) ? false : true;
|
|
93
|
+
/**
|
|
94
|
+
* Creates a record with all available flags with the corresponding type and
|
|
95
|
+
* default type.
|
|
96
|
+
* @internal
|
|
97
|
+
*/
|
|
98
|
+
type Values<TBooleans extends BooleanType, TStrings extends StringType, TCollectable extends Collectable, TNegatable extends Negatable, TDefault extends Record<string, unknown> | undefined, TAliases extends Aliases | undefined> = UseTypes<TBooleans, TStrings, TCollectable> extends true ? Record<string, unknown> & AddAliases<SpreadDefaults<CollectValues<TStrings, string, TCollectable, TNegatable> & RecursiveRequired<CollectValues<TBooleans, boolean, TCollectable>> & CollectUnknownValues<TBooleans, TStrings, TCollectable, TNegatable>, DedotRecord<TDefault>>, TAliases> : Record<string, any>;
|
|
99
|
+
/** @internal */
|
|
100
|
+
type Aliases<TArgNames = string, TAliasNames extends string = string> = Partial<Record<Extract<TArgNames, string>, TAliasNames | ReadonlyArray<TAliasNames>>>;
|
|
101
|
+
type AddAliases<TArgs, TAliases extends Aliases | undefined> = {
|
|
102
|
+
[TArgName in keyof TArgs as AliasNames<TArgName, TAliases>]: TArgs[TArgName];
|
|
103
|
+
};
|
|
104
|
+
type AliasNames<TArgName, TAliases extends Aliases | undefined> = TArgName extends keyof TAliases ? string extends TAliases[TArgName] ? TArgName : TAliases[TArgName] extends string ? TArgName | TAliases[TArgName] : TAliases[TArgName] extends Array<string> ? TArgName | TAliases[TArgName][number] : TArgName : TArgName;
|
|
105
|
+
/**
|
|
106
|
+
* Spreads all default values of Record `TDefaults` into Record `TArgs`
|
|
107
|
+
* and makes default values required.
|
|
108
|
+
*
|
|
109
|
+
* **Example:**
|
|
110
|
+
* `SpreadValues<{ foo?: boolean, bar?: number }, { foo: number }>`
|
|
111
|
+
*
|
|
112
|
+
* **Result:** `{ foo: boolean | number, bar?: number }`
|
|
113
|
+
*/
|
|
114
|
+
type SpreadDefaults<TArgs, TDefaults> = TDefaults extends undefined ? TArgs : TArgs extends Record<string, unknown> ? Omit<TArgs, keyof TDefaults> & {
|
|
115
|
+
[Default in keyof TDefaults]: Default extends keyof TArgs ? (TArgs[Default] & TDefaults[Default] | TDefaults[Default]) extends Record<string, unknown> ? NonNullable<SpreadDefaults<TArgs[Default], TDefaults[Default]>> : TDefaults[Default] | NonNullable<TArgs[Default]> : unknown;
|
|
116
|
+
} : never;
|
|
117
|
+
/**
|
|
118
|
+
* Defines the Record for the `default` option to add
|
|
119
|
+
* auto-suggestion support for IDE's.
|
|
120
|
+
* @internal
|
|
121
|
+
*/
|
|
122
|
+
type Defaults<TBooleans extends BooleanType, TStrings extends StringType> = Id<UnionToIntersection<Record<string, unknown> & MapTypes<TStrings, unknown> & MapTypes<TBooleans, unknown> & MapDefaults<TBooleans> & MapDefaults<TStrings>>>;
|
|
123
|
+
type MapDefaults<TArgNames extends ArgType> = Partial<Record<TArgNames extends string ? TArgNames : string, unknown>>;
|
|
124
|
+
type RecursiveRequired<TRecord> = TRecord extends Record<string, unknown> ? {
|
|
125
|
+
[Key in keyof TRecord]-?: RecursiveRequired<TRecord[Key]>;
|
|
126
|
+
} : TRecord;
|
|
127
|
+
/** Same as `MapTypes` but also supports collectable options. */
|
|
128
|
+
type CollectValues<TArgNames extends ArgType, TType, TCollectable extends Collectable, TNegatable extends Negatable = undefined> = UnionToIntersection<Extract<TArgNames, TCollectable> extends string ? (Exclude<TArgNames, TCollectable> extends never ? Record<never, never> : MapTypes<Exclude<TArgNames, TCollectable>, TType, TNegatable>) & (Extract<TArgNames, TCollectable> extends never ? Record<never, never> : RecursiveRequired<MapTypes<Extract<TArgNames, TCollectable>, Array<TType>, TNegatable>>) : MapTypes<TArgNames, TType, TNegatable>>;
|
|
129
|
+
/** Same as `Record` but also supports dotted and negatable options. */
|
|
130
|
+
type MapTypes<TArgNames extends ArgType, TType, TNegatable extends Negatable = undefined> = undefined extends TArgNames ? Record<never, never> : TArgNames extends `${infer Name}.${infer Rest}` ? {
|
|
131
|
+
[Key in Name]?: MapTypes<Rest, TType, TNegatable extends `${Name}.${infer Negate}` ? Negate : undefined>;
|
|
132
|
+
} : TArgNames extends string ? Partial<Record<TArgNames, TNegatable extends TArgNames ? TType | false : TType>> : Record<never, never>;
|
|
133
|
+
type CollectUnknownValues<TBooleans extends BooleanType, TStrings extends StringType, TCollectable extends Collectable, TNegatable extends Negatable> = UnionToIntersection<TCollectable extends TBooleans & TStrings ? Record<never, never> : DedotRecord<Record<Exclude<Extract<Exclude<TCollectable, TNegatable>, string>, Extract<TStrings | TBooleans, string>>, Array<unknown>> & Record<Exclude<Extract<Extract<TCollectable, TNegatable>, string>, Extract<TStrings | TBooleans, string>>, Array<unknown> | false>>>;
|
|
134
|
+
/** Converts `{ "foo.bar.baz": unknown }` into `{ foo: { bar: { baz: unknown } } }`. */
|
|
135
|
+
type DedotRecord<TRecord> = Record<string, unknown> extends TRecord ? TRecord : TRecord extends Record<string, unknown> ? UnionToIntersection<ValueOf<{
|
|
136
|
+
[Key in keyof TRecord]: Key extends string ? Dedot<Key, TRecord[Key]> : never;
|
|
137
|
+
}>> : TRecord;
|
|
138
|
+
type Dedot<TKey extends string, TValue> = TKey extends `${infer Name}.${infer Rest}` ? {
|
|
139
|
+
[Key in Name]: Dedot<Rest, TValue>;
|
|
140
|
+
} : {
|
|
141
|
+
[Key in TKey]: TValue;
|
|
142
|
+
};
|
|
143
|
+
type ValueOf<TValue> = TValue[keyof TValue];
|
|
144
|
+
/** The value returned from {@linkcode parseArgs}. */
|
|
145
|
+
export type Args<TArgs extends Record<string, unknown> = Record<string, any>, TDoubleDash extends boolean | undefined = undefined> = Id<TArgs & {
|
|
146
|
+
/** Contains all the arguments that didn't have an option associated with
|
|
147
|
+
* them. */
|
|
148
|
+
_: Array<string | number>;
|
|
149
|
+
} & (boolean extends TDoubleDash ? DoubleDash : true extends TDoubleDash ? Required<DoubleDash> : Record<never, never>)>;
|
|
150
|
+
/** @internal */
|
|
151
|
+
type DoubleDash = {
|
|
152
|
+
/** Contains all the arguments that appear after the double dash: "--". */
|
|
153
|
+
"--"?: Array<string>;
|
|
154
|
+
};
|
|
155
|
+
/** Options for {@linkcode parseArgs}. */
|
|
156
|
+
export interface ParseOptions<TBooleans extends BooleanType = BooleanType, TStrings extends StringType = StringType, TCollectable extends Collectable = Collectable, TNegatable extends Negatable = Negatable, TDefault extends Record<string, unknown> | undefined = Record<string, unknown> | undefined, TAliases extends Aliases | undefined = Aliases | undefined, TDoubleDash extends boolean | undefined = boolean | undefined> {
|
|
157
|
+
/**
|
|
158
|
+
* When `true`, populate the result `_` with everything before the `--` and
|
|
159
|
+
* the result `['--']` with everything after the `--`.
|
|
160
|
+
*
|
|
161
|
+
* @default {false}
|
|
162
|
+
*
|
|
163
|
+
* @example Double dash option is false
|
|
164
|
+
* ```ts
|
|
165
|
+
* // $ deno run example.ts -- a arg1
|
|
166
|
+
* import { parseArgs } from "@std/cli/parse-args";
|
|
167
|
+
* const args = parseArgs(Deno.args, { "--": false }); // args equals { _: [ "a", "arg1" ] }
|
|
168
|
+
* ```
|
|
169
|
+
*
|
|
170
|
+
* @example Double dash option is true
|
|
171
|
+
* ```ts
|
|
172
|
+
* // $ deno run example.ts -- a arg1
|
|
173
|
+
* import { parseArgs } from "@std/cli/parse-args";
|
|
174
|
+
* const args = parseArgs(Deno.args, { "--": true }); // args equals { _: [], --: [ "a", "arg1" ] }
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
"--"?: TDoubleDash;
|
|
178
|
+
/**
|
|
179
|
+
* An object mapping string names to strings or arrays of string argument
|
|
180
|
+
* names to use as aliases.
|
|
181
|
+
*
|
|
182
|
+
* @default {{}}
|
|
183
|
+
*/
|
|
184
|
+
alias?: TAliases;
|
|
185
|
+
/**
|
|
186
|
+
* A boolean, string or array of strings to always treat as booleans. If
|
|
187
|
+
* `true` will treat all double hyphenated arguments without equal signs as
|
|
188
|
+
* `boolean` (e.g. affects `--foo`, not `-f` or `--foo=bar`).
|
|
189
|
+
* All `boolean` arguments will be set to `false` by default.
|
|
190
|
+
*
|
|
191
|
+
* @default {false}
|
|
192
|
+
*/
|
|
193
|
+
boolean?: TBooleans | ReadonlyArray<Extract<TBooleans, string>>;
|
|
194
|
+
/**
|
|
195
|
+
* An object mapping string argument names to default values.
|
|
196
|
+
*
|
|
197
|
+
* @default {{}}
|
|
198
|
+
*/
|
|
199
|
+
default?: TDefault & Defaults<TBooleans, TStrings>;
|
|
200
|
+
/**
|
|
201
|
+
* When `true`, populate the result `_` with everything after the first
|
|
202
|
+
* non-option.
|
|
203
|
+
*
|
|
204
|
+
* @default {false}
|
|
205
|
+
*/
|
|
206
|
+
stopEarly?: boolean;
|
|
207
|
+
/**
|
|
208
|
+
* A string or array of strings argument names to always treat as strings.
|
|
209
|
+
*
|
|
210
|
+
* @default {[]}
|
|
211
|
+
*/
|
|
212
|
+
string?: TStrings | ReadonlyArray<Extract<TStrings, string>>;
|
|
213
|
+
/**
|
|
214
|
+
* A string or array of strings argument names to always treat as arrays.
|
|
215
|
+
* Collectable options can be used multiple times. All values will be
|
|
216
|
+
* collected into one array. If a non-collectable option is used multiple
|
|
217
|
+
* times, the last value is used.
|
|
218
|
+
*
|
|
219
|
+
* @default {[]}
|
|
220
|
+
*/
|
|
221
|
+
collect?: TCollectable | ReadonlyArray<Extract<TCollectable, string>>;
|
|
222
|
+
/**
|
|
223
|
+
* A string or array of strings argument names which can be negated
|
|
224
|
+
* by prefixing them with `--no-`, like `--no-config`.
|
|
225
|
+
*
|
|
226
|
+
* @default {[]}
|
|
227
|
+
*/
|
|
228
|
+
negatable?: TNegatable | ReadonlyArray<Extract<TNegatable, string>>;
|
|
229
|
+
/**
|
|
230
|
+
* A function which is invoked with a command line parameter not defined in
|
|
231
|
+
* the `options` configuration object. If the function returns `false`, the
|
|
232
|
+
* unknown option is not added to `parsedArgs`.
|
|
233
|
+
*
|
|
234
|
+
* @default {unknown}
|
|
235
|
+
*/
|
|
236
|
+
unknown?: (arg: string, key?: string, value?: unknown) => unknown;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Take a set of command line arguments, optionally with a set of options, and
|
|
240
|
+
* return an object representing the flags found in the passed arguments.
|
|
241
|
+
*
|
|
242
|
+
* By default, any arguments starting with `-` or `--` are considered boolean
|
|
243
|
+
* flags. If the argument name is followed by an equal sign (`=`) it is
|
|
244
|
+
* considered a key-value pair. Any arguments which could not be parsed are
|
|
245
|
+
* available in the `_` property of the returned object.
|
|
246
|
+
*
|
|
247
|
+
* By default, this module tries to determine the type of all arguments
|
|
248
|
+
* automatically and the return type of this function will have an index
|
|
249
|
+
* signature with `any` as value (`{ [x: string]: any }`).
|
|
250
|
+
*
|
|
251
|
+
* If the `string`, `boolean` or `collect` option is set, the return value of
|
|
252
|
+
* this function will be fully typed and the index signature of the return
|
|
253
|
+
* type will change to `{ [x: string]: unknown }`.
|
|
254
|
+
*
|
|
255
|
+
* Any arguments after `'--'` will not be parsed and will end up in `parsedArgs._`.
|
|
256
|
+
*
|
|
257
|
+
* Numeric-looking arguments will be returned as numbers unless `options.string`
|
|
258
|
+
* or `options.boolean` is set for that argument name.
|
|
259
|
+
*
|
|
260
|
+
* See {@linkcode ParseOptions} for more information.
|
|
261
|
+
*
|
|
262
|
+
* @param args An array of command line arguments.
|
|
263
|
+
* @param options Options for the parse function.
|
|
264
|
+
*
|
|
265
|
+
* @typeParam TArgs Type of result.
|
|
266
|
+
* @typeParam TDoubleDash Used by `TArgs` for the result.
|
|
267
|
+
* @typeParam TBooleans Used by `TArgs` for the result.
|
|
268
|
+
* @typeParam TStrings Used by `TArgs` for the result.
|
|
269
|
+
* @typeParam TCollectable Used by `TArgs` for the result.
|
|
270
|
+
* @typeParam TNegatable Used by `TArgs` for the result.
|
|
271
|
+
* @typeParam TDefaults Used by `TArgs` for the result.
|
|
272
|
+
* @typeParam TAliases Used by `TArgs` for the result.
|
|
273
|
+
* @typeParam TAliasArgNames Used by `TArgs` for the result.
|
|
274
|
+
* @typeParam TAliasNames Used by `TArgs` for the result.
|
|
275
|
+
*
|
|
276
|
+
* @return The parsed arguments.
|
|
277
|
+
*
|
|
278
|
+
* @example Usage
|
|
279
|
+
* ```ts
|
|
280
|
+
* import { parseArgs } from "@std/cli/parse-args";
|
|
281
|
+
* import { assertEquals } from "@std/assert/equals";
|
|
282
|
+
*
|
|
283
|
+
* // For proper use, one should use `parseArgs(Deno.args)`
|
|
284
|
+
* assertEquals(parseArgs(["--foo", "--bar=baz", "./quux.txt"]), {
|
|
285
|
+
* foo: true,
|
|
286
|
+
* bar: "baz",
|
|
287
|
+
* _: ["./quux.txt"],
|
|
288
|
+
* });
|
|
289
|
+
* ```
|
|
290
|
+
*
|
|
291
|
+
* @example `string` and `boolean` options
|
|
292
|
+
*
|
|
293
|
+
* Use `string` and `boolean` options to specify the type of the argument.
|
|
294
|
+
*
|
|
295
|
+
* ```ts
|
|
296
|
+
* import { parseArgs } from "@std/cli/parse-args";
|
|
297
|
+
* import { assertEquals } from "@std/assert/equals";
|
|
298
|
+
*
|
|
299
|
+
* const args = parseArgs(["--foo", "--bar", "baz"], {
|
|
300
|
+
* boolean: ["foo"],
|
|
301
|
+
* string: ["bar"],
|
|
302
|
+
* });
|
|
303
|
+
*
|
|
304
|
+
* assertEquals(args, { foo: true, bar: "baz", _: [] });
|
|
305
|
+
* ```
|
|
306
|
+
*
|
|
307
|
+
* @example `collect` option
|
|
308
|
+
*
|
|
309
|
+
* `collect` option tells the parser to treat the option as an array. All
|
|
310
|
+
* values will be collected into one array. If a non-collectable option is used
|
|
311
|
+
* multiple times, the last value is used.
|
|
312
|
+
*
|
|
313
|
+
* ```ts
|
|
314
|
+
* import { parseArgs } from "@std/cli/parse-args";
|
|
315
|
+
* import { assertEquals } from "@std/assert/equals";
|
|
316
|
+
*
|
|
317
|
+
* const args = parseArgs(["--foo", "bar", "--foo", "baz"], {
|
|
318
|
+
* collect: ["foo"],
|
|
319
|
+
* });
|
|
320
|
+
*
|
|
321
|
+
* assertEquals(args, { foo: ["bar", "baz"], _: [] });
|
|
322
|
+
* ```
|
|
323
|
+
*
|
|
324
|
+
* @example `negatable` option
|
|
325
|
+
*
|
|
326
|
+
* `negatable` option tells the parser to treat the option can be negated by
|
|
327
|
+
* prefixing them with `--no-`, like `--no-config`.
|
|
328
|
+
*
|
|
329
|
+
* ```ts
|
|
330
|
+
* import { parseArgs } from "@std/cli/parse-args";
|
|
331
|
+
* import { assertEquals } from "@std/assert/equals";
|
|
332
|
+
*
|
|
333
|
+
* const args = parseArgs(["--no-foo"], {
|
|
334
|
+
* boolean: ["foo"],
|
|
335
|
+
* negatable: ["foo"],
|
|
336
|
+
* });
|
|
337
|
+
*
|
|
338
|
+
* assertEquals(args, { foo: false, _: [] });
|
|
339
|
+
* ```
|
|
340
|
+
*/
|
|
341
|
+
export declare function parseArgs<TArgs extends Values<TBooleans, TStrings, TCollectable, TNegatable, TDefaults, TAliases>, TDoubleDash extends boolean | undefined = undefined, TBooleans extends BooleanType = undefined, TStrings extends StringType = undefined, TCollectable extends Collectable = undefined, TNegatable extends Negatable = undefined, TDefaults extends Record<string, unknown> | undefined = undefined, TAliases extends Aliases<TAliasArgNames, TAliasNames> | undefined = undefined, TAliasArgNames extends string = string, TAliasNames extends string = string>(args: readonly string[], options?: ParseOptions<TBooleans, TStrings, TCollectable, TNegatable, TDefaults, TAliases, TDoubleDash>): Args<TArgs, TDoubleDash>;
|
|
342
|
+
export {};
|
|
343
|
+
//# sourceMappingURL=parse_args.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse_args.d.ts","sourceRoot":"","sources":["../../../../../src/deps/jsr.io/@std/cli/1.0.32/parse_args.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AAEH;;GAEG;AACH,KAAK,EAAE,CAAC,OAAO,IAAI,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACtD,OA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,SAAS,WAAW,GAAG,SAAS,EAC5C,UAAU,SAAS,SAAS,GAAG,SAAS,EACxC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAAG,SAAS,EACjE,QAAQ,SAAS,OAAO,CAAC,cAAc,EAAE,WAAW,CAAC,GAAG,SAAS,GAAG,SAAS,EAC7E,cAAc,SAAS,MAAM,GAAG,MAAM,EACtC,WAAW,SAAS,MAAM,GAAG,MAAM,EAEnC,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,CAAC,EAAE,YAAY,CACpB,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,SAAS,EACT,QAAQ,EACR,WAAW,CACZ,GACA,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,CA8Q1B"}
|
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
// Copyright 2018-2026 the Deno authors. MIT license.
|
|
2
|
+
// This module is browser compatible.
|
|
3
|
+
const FLAG_REGEXP = /^(?:-(?:(?<doubleDash>-)(?<negated>no-)?)?)(?<key>.+?)(?:=(?<value>.*))?$/s;
|
|
4
|
+
const LETTER_REGEXP = /[A-Za-z]/;
|
|
5
|
+
const NUMBER_REGEXP = /-?\d+(\.\d*)?(e-?\d+)?$/;
|
|
6
|
+
const HYPHEN_REGEXP = /^(-|--)[^-]/;
|
|
7
|
+
const VALUE_REGEXP = /=(?<value>.+)/;
|
|
8
|
+
const FLAG_NAME_REGEXP = /^--[^=]+$/;
|
|
9
|
+
const SPECIAL_CHAR_REGEXP = /\W/;
|
|
10
|
+
const NON_WHITESPACE_REGEXP = /\S/;
|
|
11
|
+
function isNumber(string) {
|
|
12
|
+
return NON_WHITESPACE_REGEXP.test(string) && Number.isFinite(Number(string));
|
|
13
|
+
}
|
|
14
|
+
function isConstructorOrProto(obj, key) {
|
|
15
|
+
return (key === "constructor" && typeof obj[key] === "function") ||
|
|
16
|
+
key === "__proto__";
|
|
17
|
+
}
|
|
18
|
+
function setNested(object, keys, value, collect = false) {
|
|
19
|
+
keys = [...keys];
|
|
20
|
+
const key = keys.pop();
|
|
21
|
+
for (const k of keys) {
|
|
22
|
+
if (isConstructorOrProto(object, k))
|
|
23
|
+
return;
|
|
24
|
+
object = (object[k] ??= {});
|
|
25
|
+
}
|
|
26
|
+
if (isConstructorOrProto(object, key))
|
|
27
|
+
return;
|
|
28
|
+
if (collect) {
|
|
29
|
+
const v = object[key];
|
|
30
|
+
if (Array.isArray(v)) {
|
|
31
|
+
v.push(value);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
value = v ? [v, value] : [value];
|
|
35
|
+
}
|
|
36
|
+
object[key] = value;
|
|
37
|
+
}
|
|
38
|
+
function hasNested(object, keys) {
|
|
39
|
+
for (const key of keys) {
|
|
40
|
+
const value = object[key];
|
|
41
|
+
if (!Object.hasOwn(object, key))
|
|
42
|
+
return false;
|
|
43
|
+
object = value;
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
function aliasIsBoolean(aliasMap, booleanSet, key) {
|
|
48
|
+
const set = aliasMap.get(key);
|
|
49
|
+
if (set === undefined)
|
|
50
|
+
return false;
|
|
51
|
+
for (const alias of set)
|
|
52
|
+
if (booleanSet.has(alias))
|
|
53
|
+
return true;
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
function isBooleanString(value) {
|
|
57
|
+
return value === "true" || value === "false";
|
|
58
|
+
}
|
|
59
|
+
function parseBooleanString(value) {
|
|
60
|
+
return value !== "false";
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Take a set of command line arguments, optionally with a set of options, and
|
|
64
|
+
* return an object representing the flags found in the passed arguments.
|
|
65
|
+
*
|
|
66
|
+
* By default, any arguments starting with `-` or `--` are considered boolean
|
|
67
|
+
* flags. If the argument name is followed by an equal sign (`=`) it is
|
|
68
|
+
* considered a key-value pair. Any arguments which could not be parsed are
|
|
69
|
+
* available in the `_` property of the returned object.
|
|
70
|
+
*
|
|
71
|
+
* By default, this module tries to determine the type of all arguments
|
|
72
|
+
* automatically and the return type of this function will have an index
|
|
73
|
+
* signature with `any` as value (`{ [x: string]: any }`).
|
|
74
|
+
*
|
|
75
|
+
* If the `string`, `boolean` or `collect` option is set, the return value of
|
|
76
|
+
* this function will be fully typed and the index signature of the return
|
|
77
|
+
* type will change to `{ [x: string]: unknown }`.
|
|
78
|
+
*
|
|
79
|
+
* Any arguments after `'--'` will not be parsed and will end up in `parsedArgs._`.
|
|
80
|
+
*
|
|
81
|
+
* Numeric-looking arguments will be returned as numbers unless `options.string`
|
|
82
|
+
* or `options.boolean` is set for that argument name.
|
|
83
|
+
*
|
|
84
|
+
* See {@linkcode ParseOptions} for more information.
|
|
85
|
+
*
|
|
86
|
+
* @param args An array of command line arguments.
|
|
87
|
+
* @param options Options for the parse function.
|
|
88
|
+
*
|
|
89
|
+
* @typeParam TArgs Type of result.
|
|
90
|
+
* @typeParam TDoubleDash Used by `TArgs` for the result.
|
|
91
|
+
* @typeParam TBooleans Used by `TArgs` for the result.
|
|
92
|
+
* @typeParam TStrings Used by `TArgs` for the result.
|
|
93
|
+
* @typeParam TCollectable Used by `TArgs` for the result.
|
|
94
|
+
* @typeParam TNegatable Used by `TArgs` for the result.
|
|
95
|
+
* @typeParam TDefaults Used by `TArgs` for the result.
|
|
96
|
+
* @typeParam TAliases Used by `TArgs` for the result.
|
|
97
|
+
* @typeParam TAliasArgNames Used by `TArgs` for the result.
|
|
98
|
+
* @typeParam TAliasNames Used by `TArgs` for the result.
|
|
99
|
+
*
|
|
100
|
+
* @return The parsed arguments.
|
|
101
|
+
*
|
|
102
|
+
* @example Usage
|
|
103
|
+
* ```ts
|
|
104
|
+
* import { parseArgs } from "@std/cli/parse-args";
|
|
105
|
+
* import { assertEquals } from "@std/assert/equals";
|
|
106
|
+
*
|
|
107
|
+
* // For proper use, one should use `parseArgs(Deno.args)`
|
|
108
|
+
* assertEquals(parseArgs(["--foo", "--bar=baz", "./quux.txt"]), {
|
|
109
|
+
* foo: true,
|
|
110
|
+
* bar: "baz",
|
|
111
|
+
* _: ["./quux.txt"],
|
|
112
|
+
* });
|
|
113
|
+
* ```
|
|
114
|
+
*
|
|
115
|
+
* @example `string` and `boolean` options
|
|
116
|
+
*
|
|
117
|
+
* Use `string` and `boolean` options to specify the type of the argument.
|
|
118
|
+
*
|
|
119
|
+
* ```ts
|
|
120
|
+
* import { parseArgs } from "@std/cli/parse-args";
|
|
121
|
+
* import { assertEquals } from "@std/assert/equals";
|
|
122
|
+
*
|
|
123
|
+
* const args = parseArgs(["--foo", "--bar", "baz"], {
|
|
124
|
+
* boolean: ["foo"],
|
|
125
|
+
* string: ["bar"],
|
|
126
|
+
* });
|
|
127
|
+
*
|
|
128
|
+
* assertEquals(args, { foo: true, bar: "baz", _: [] });
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* @example `collect` option
|
|
132
|
+
*
|
|
133
|
+
* `collect` option tells the parser to treat the option as an array. All
|
|
134
|
+
* values will be collected into one array. If a non-collectable option is used
|
|
135
|
+
* multiple times, the last value is used.
|
|
136
|
+
*
|
|
137
|
+
* ```ts
|
|
138
|
+
* import { parseArgs } from "@std/cli/parse-args";
|
|
139
|
+
* import { assertEquals } from "@std/assert/equals";
|
|
140
|
+
*
|
|
141
|
+
* const args = parseArgs(["--foo", "bar", "--foo", "baz"], {
|
|
142
|
+
* collect: ["foo"],
|
|
143
|
+
* });
|
|
144
|
+
*
|
|
145
|
+
* assertEquals(args, { foo: ["bar", "baz"], _: [] });
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
* @example `negatable` option
|
|
149
|
+
*
|
|
150
|
+
* `negatable` option tells the parser to treat the option can be negated by
|
|
151
|
+
* prefixing them with `--no-`, like `--no-config`.
|
|
152
|
+
*
|
|
153
|
+
* ```ts
|
|
154
|
+
* import { parseArgs } from "@std/cli/parse-args";
|
|
155
|
+
* import { assertEquals } from "@std/assert/equals";
|
|
156
|
+
*
|
|
157
|
+
* const args = parseArgs(["--no-foo"], {
|
|
158
|
+
* boolean: ["foo"],
|
|
159
|
+
* negatable: ["foo"],
|
|
160
|
+
* });
|
|
161
|
+
*
|
|
162
|
+
* assertEquals(args, { foo: false, _: [] });
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
export function parseArgs(args, options) {
|
|
166
|
+
const { "--": doubleDash = false, alias = {}, boolean = false, default: defaults = {}, stopEarly = false, string = [], collect = [], negatable = [], unknown: unknownFn = (i) => i, } = options ?? {};
|
|
167
|
+
const aliasMap = new Map();
|
|
168
|
+
const booleanSet = new Set();
|
|
169
|
+
const stringSet = new Set();
|
|
170
|
+
const collectSet = new Set();
|
|
171
|
+
const negatableSet = new Set();
|
|
172
|
+
let allBools = false;
|
|
173
|
+
if (alias) {
|
|
174
|
+
for (const [key, value] of Object.entries(alias)) {
|
|
175
|
+
if (value === undefined) {
|
|
176
|
+
throw new TypeError("Alias value must be defined");
|
|
177
|
+
}
|
|
178
|
+
const aliases = Array.isArray(value) ? value : [value];
|
|
179
|
+
aliasMap.set(key, new Set(aliases));
|
|
180
|
+
aliases.forEach((alias) => aliasMap.set(alias, new Set([key, ...aliases.filter((it) => it !== alias)])));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (boolean) {
|
|
184
|
+
if (typeof boolean === "boolean") {
|
|
185
|
+
allBools = boolean;
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
const booleanArgs = Array.isArray(boolean) ? boolean : [boolean];
|
|
189
|
+
for (const key of booleanArgs.filter(Boolean)) {
|
|
190
|
+
booleanSet.add(key);
|
|
191
|
+
aliasMap.get(key)?.forEach((al) => {
|
|
192
|
+
booleanSet.add(al);
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (string) {
|
|
198
|
+
const stringArgs = Array.isArray(string) ? string : [string];
|
|
199
|
+
for (const key of stringArgs.filter(Boolean)) {
|
|
200
|
+
stringSet.add(key);
|
|
201
|
+
aliasMap.get(key)?.forEach((al) => stringSet.add(al));
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (collect) {
|
|
205
|
+
const collectArgs = Array.isArray(collect) ? collect : [collect];
|
|
206
|
+
for (const key of collectArgs.filter(Boolean)) {
|
|
207
|
+
collectSet.add(key);
|
|
208
|
+
aliasMap.get(key)?.forEach((al) => collectSet.add(al));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (negatable) {
|
|
212
|
+
const negatableArgs = Array.isArray(negatable) ? negatable : [negatable];
|
|
213
|
+
for (const key of negatableArgs.filter(Boolean)) {
|
|
214
|
+
negatableSet.add(key);
|
|
215
|
+
aliasMap.get(key)?.forEach((alias) => negatableSet.add(alias));
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
const argv = { _: [] };
|
|
219
|
+
function setArgument(key, value, arg, collect) {
|
|
220
|
+
if (!booleanSet.has(key) &&
|
|
221
|
+
!stringSet.has(key) &&
|
|
222
|
+
!aliasMap.has(key) &&
|
|
223
|
+
!collectSet.has(key) &&
|
|
224
|
+
!(allBools && FLAG_NAME_REGEXP.test(arg)) &&
|
|
225
|
+
unknownFn?.(arg, key, value) === false) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
if (typeof value === "string" && !stringSet.has(key)) {
|
|
229
|
+
value = isNumber(value) ? Number(value) : value;
|
|
230
|
+
}
|
|
231
|
+
const collectable = collect && collectSet.has(key);
|
|
232
|
+
setNested(argv, key.split("."), value, collectable);
|
|
233
|
+
aliasMap.get(key)?.forEach((key) => {
|
|
234
|
+
setNested(argv, key.split("."), value, collectable);
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
let notFlags = [];
|
|
238
|
+
// all args after "--" are not parsed
|
|
239
|
+
const index = args.indexOf("--");
|
|
240
|
+
if (index !== -1) {
|
|
241
|
+
notFlags = args.slice(index + 1);
|
|
242
|
+
args = args.slice(0, index);
|
|
243
|
+
}
|
|
244
|
+
argsLoop: for (let i = 0; i < args.length; i++) {
|
|
245
|
+
const arg = args[i];
|
|
246
|
+
const groups = arg.match(FLAG_REGEXP)?.groups;
|
|
247
|
+
if (groups) {
|
|
248
|
+
const { doubleDash, negated } = groups;
|
|
249
|
+
let key = groups.key;
|
|
250
|
+
let value = groups.value;
|
|
251
|
+
if (doubleDash) {
|
|
252
|
+
if (value != null) {
|
|
253
|
+
if (booleanSet.has(key))
|
|
254
|
+
value = parseBooleanString(value);
|
|
255
|
+
setArgument(key, value, arg, true);
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
if (negated) {
|
|
259
|
+
if (negatableSet.has(key)) {
|
|
260
|
+
setArgument(key, false, arg, false);
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
key = `no-${key}`;
|
|
264
|
+
}
|
|
265
|
+
const next = args[i + 1];
|
|
266
|
+
if (next) {
|
|
267
|
+
if (!booleanSet.has(key) &&
|
|
268
|
+
!allBools &&
|
|
269
|
+
!next.startsWith("-") &&
|
|
270
|
+
(!aliasMap.has(key) || !aliasIsBoolean(aliasMap, booleanSet, key))) {
|
|
271
|
+
value = next;
|
|
272
|
+
i++;
|
|
273
|
+
setArgument(key, value, arg, true);
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
if (isBooleanString(next)) {
|
|
277
|
+
value = parseBooleanString(next);
|
|
278
|
+
i++;
|
|
279
|
+
setArgument(key, value, arg, true);
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
value = stringSet.has(key) ? "" : true;
|
|
284
|
+
setArgument(key, value, arg, true);
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
const letters = arg.slice(1, -1).split("");
|
|
288
|
+
for (const [j, letter] of letters.entries()) {
|
|
289
|
+
const next = arg.slice(j + 2);
|
|
290
|
+
if (next === "-") {
|
|
291
|
+
setArgument(letter, next, arg, true);
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
if (next === "=") {
|
|
295
|
+
setArgument(letter, "", arg, true);
|
|
296
|
+
continue argsLoop;
|
|
297
|
+
}
|
|
298
|
+
if (LETTER_REGEXP.test(letter)) {
|
|
299
|
+
const groups = VALUE_REGEXP.exec(next)?.groups;
|
|
300
|
+
if (groups) {
|
|
301
|
+
setArgument(letter, groups.value, arg, true);
|
|
302
|
+
continue argsLoop;
|
|
303
|
+
}
|
|
304
|
+
if (NUMBER_REGEXP.test(next)) {
|
|
305
|
+
setArgument(letter, next, arg, true);
|
|
306
|
+
continue argsLoop;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
if (letters[j + 1]?.match(SPECIAL_CHAR_REGEXP)) {
|
|
310
|
+
setArgument(letter, arg.slice(j + 2), arg, true);
|
|
311
|
+
continue argsLoop;
|
|
312
|
+
}
|
|
313
|
+
setArgument(letter, stringSet.has(letter) ? "" : true, arg, true);
|
|
314
|
+
}
|
|
315
|
+
key = arg.slice(-1);
|
|
316
|
+
if (key === "-")
|
|
317
|
+
continue;
|
|
318
|
+
const nextArg = args[i + 1];
|
|
319
|
+
if (nextArg) {
|
|
320
|
+
if (!HYPHEN_REGEXP.test(nextArg) &&
|
|
321
|
+
!booleanSet.has(key) &&
|
|
322
|
+
(!aliasMap.has(key) || !aliasIsBoolean(aliasMap, booleanSet, key))) {
|
|
323
|
+
setArgument(key, nextArg, arg, true);
|
|
324
|
+
i++;
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
if (isBooleanString(nextArg)) {
|
|
328
|
+
const value = parseBooleanString(nextArg);
|
|
329
|
+
setArgument(key, value, arg, true);
|
|
330
|
+
i++;
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
setArgument(key, stringSet.has(key) ? "" : true, arg, true);
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
if (unknownFn?.(arg) !== false) {
|
|
338
|
+
argv._.push(stringSet.has("_") || !isNumber(arg) ? arg : Number(arg));
|
|
339
|
+
}
|
|
340
|
+
if (stopEarly) {
|
|
341
|
+
argv._.push(...args.slice(i + 1));
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
for (const [key, value] of Object.entries(defaults)) {
|
|
346
|
+
const keys = key.split(".");
|
|
347
|
+
if (!hasNested(argv, keys)) {
|
|
348
|
+
setNested(argv, keys, value);
|
|
349
|
+
aliasMap.get(key)?.forEach((key) => setNested(argv, key.split("."), value));
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
for (const key of booleanSet.keys()) {
|
|
353
|
+
const keys = key.split(".");
|
|
354
|
+
if (!hasNested(argv, keys)) {
|
|
355
|
+
const value = collectSet.has(key) ? [] : false;
|
|
356
|
+
setNested(argv, keys, value);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
for (const key of stringSet.keys()) {
|
|
360
|
+
const keys = key.split(".");
|
|
361
|
+
if (!hasNested(argv, keys) && collectSet.has(key)) {
|
|
362
|
+
setNested(argv, keys, []);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
if (doubleDash) {
|
|
366
|
+
argv["--"] = notFlags;
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
argv._.push(...notFlags);
|
|
370
|
+
}
|
|
371
|
+
return argv;
|
|
372
|
+
}
|
package/mod.d.ts
CHANGED
package/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["src/mod.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAK7B,MAAM,MAAM,qBAAqB,GAC9B,MAAM,GACN,cAAc,GACd,UAAU,GACV,WAAW,GACX,WAAW,CAAC;AACf;;GAEG;AACH,qBAAa,OAAO;;IACnB,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAEjC;IAMD;;;OAGG;gBACS,IAAI,CAAC,EAAE,qBAAqB;IAKxC;;;OAGG;IACH,IAAI,OAAO,IAAI,OAAO,CAErB;IACD;;;OAGG;IACH,MAAM,IAAI,IAAI;IAId;;;OAGG;IACH,IAAI,IAAI,UAAU;IAIlB;;;OAGG;IACH,OAAO,IAAI,MAAM;IAUjB;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE,qBAAqB,GAAG,IAAI;IAazC;;;;OAIG;IACG,gBAAgB,CAAC,MAAM,EAAE,cAAc,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAMpF;AACD,eAAe,OAAO,CAAC"}
|
package/mod.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "./_dnt.polyfills.js";
|
|
1
2
|
if (typeof Uint8Array.fromHex === "undefined") {
|
|
2
3
|
//deno-lint-ignore hugoalh/no-import-dynamic -- Polyfill.
|
|
3
4
|
await import("es-arraybuffer-base64/Uint8Array.fromHex/auto");
|
|
@@ -52,10 +53,11 @@ export class Adler32 {
|
|
|
52
53
|
*/
|
|
53
54
|
hashHex() {
|
|
54
55
|
if (this.#hashHex === null) {
|
|
55
|
-
|
|
56
|
-
if (
|
|
57
|
-
throw new Error(`Unexpected hash hex result \`${
|
|
56
|
+
const result = (this.#b * 65536n + this.#a).toString(16).toUpperCase().padStart(8, "0");
|
|
57
|
+
if (result.length !== 8) {
|
|
58
|
+
throw new Error(`Unexpected hash hex result \`${result}\`! Please submit a bug report.`);
|
|
58
59
|
}
|
|
60
|
+
this.#hashHex = result;
|
|
59
61
|
}
|
|
60
62
|
return this.#hashHex;
|
|
61
63
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hugoalh/adler32",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "A module to get the checksum of the data with algorithm Adler32.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adler32",
|
|
@@ -13,9 +13,18 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"author": "hugoalh",
|
|
15
15
|
"type": "module",
|
|
16
|
+
"bin": {
|
|
17
|
+
"adler32": "./cli.js"
|
|
18
|
+
},
|
|
16
19
|
"main": "./mod.js",
|
|
17
20
|
"module": "./mod.js",
|
|
18
21
|
"exports": {
|
|
22
|
+
"./cli": {
|
|
23
|
+
"import": {
|
|
24
|
+
"types": "./cli.d.ts",
|
|
25
|
+
"default": "./cli.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
19
28
|
".": {
|
|
20
29
|
"import": {
|
|
21
30
|
"types": "./mod.d.ts",
|
|
@@ -29,7 +38,10 @@
|
|
|
29
38
|
"url": "git+https://github.com/hugoalh/adler32-es.git"
|
|
30
39
|
},
|
|
31
40
|
"dependencies": {
|
|
32
|
-
"es-arraybuffer-base64": "^1.1.2"
|
|
41
|
+
"es-arraybuffer-base64": "^1.1.2",
|
|
42
|
+
"@deno/shim-deno": "^0.19.2",
|
|
43
|
+
"@deno/shim-prompts": "^0.1.1",
|
|
44
|
+
"@deno/shim-timers": "^0.1.0"
|
|
33
45
|
},
|
|
34
46
|
"devDependencies": {
|
|
35
47
|
"@types/node": "^24.5.0"
|