@hugoalh/adler32 0.6.1 → 0.6.3

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 CHANGED
@@ -40,7 +40,6 @@ This does not request any runtime permission.
40
40
 
41
41
  - ```ts
42
42
  class Adler32 {
43
- constructor(data?: Adler32AcceptDataType);
44
43
  get freezed(): boolean;
45
44
  freeze(): this;
46
45
  hash(): Uint8Array;
@@ -70,22 +69,20 @@ This does not request any runtime permission.
70
69
  ```
71
70
  - ```powershell
72
71
  adler32 --file $FilePath
73
- <# 🔀 Unordered Positions: `--file`, `$FilePath` #>
74
72
  ```
75
- | **Argument** | **Type** | **Description** |
76
- |:--|:--|:--|
77
- | `file` | `switch` | Whether the resource is from file. |
78
73
  - ```powershell
79
74
  adler32 --stdin
80
75
  ```
81
- | **Argument** | **Type** | **Description** |
82
- |:--|:--|:--|
83
- | `stdin` | `switch` | Whether the resource is from standard stream input. |
76
+
77
+ | **Argument** | **Type** | **Description** |
78
+ |:--|:--|:--|
79
+ | `file` | `switch` | Whether the resource is from file. |
80
+ | `stdin` | `switch` | Whether the resource is from standard stream input. |
84
81
 
85
82
  ## ✍️ Examples
86
83
 
87
84
  - ```ts
88
- new Adler32("Wikipedia").hashHex();
85
+ new Adler32().update("Wikipedia").hashHex();
89
86
  //=> "11E60398"
90
87
  ```
91
88
  - ```powershell
package/cli.js CHANGED
@@ -52,27 +52,20 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
52
52
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
53
53
  });
54
54
  import { constants as fsConstants, open as openFile } from "node:fs/promises";
55
- import { exit, stdin } from "node:process";
55
+ import process from "node:process";
56
56
  import { parseArgs, styleText } from "node:util";
57
57
  import { Adler32 } from "./mod.js";
58
58
  if (!import.meta.main) {
59
59
  throw new Error(`This entrypoint is for command line only!`);
60
60
  }
61
- addEventListener("unhandledrejection", (event) => {
62
- event.preventDefault();
63
- let message;
64
- if (event.reason instanceof Error) {
65
- message = event.reason.message;
66
- if ((event.reason.stack ?? "").length > 0) {
67
- message += `\n${event.reason.stack}`;
68
- }
69
- }
70
- else {
71
- message = String(event.reason);
61
+ process.addListener("uncaughtException", (error) => {
62
+ let message = error.message;
63
+ if ((error.stack ?? "").length > 0) {
64
+ message += `\n${error.stack}`;
72
65
  }
73
66
  console.error(`${styleText(["red"], "ERROR", { validateStream: false })}\t${message}`);
74
- exit(1);
75
- }, { capture: true });
67
+ process.exit(1);
68
+ });
76
69
  const { positionals, values: { file: fromFile = false, stdin: fromStdin = false } } = parseArgs({
77
70
  allowPositionals: true,
78
71
  options: {
@@ -109,7 +102,7 @@ if (fromFile) {
109
102
  }
110
103
  }
111
104
  else if (fromStdin) {
112
- await instance.updateFromStream(stdin);
105
+ await instance.updateFromStream(process.stdin);
113
106
  }
114
107
  else {
115
108
  instance.update(positionals[0]);
package/mod.d.ts CHANGED
@@ -7,9 +7,14 @@ export declare class Adler32 {
7
7
  get [Symbol.toStringTag](): string;
8
8
  /**
9
9
  * Initialize.
10
- * @param {Adler32AcceptDataType} [data] Data. Can append later via the method {@linkcode Adler32.update} and {@linkcode Adler32.updateFromStream}.
11
10
  */
12
- constructor(data?: Adler32AcceptDataType);
11
+ constructor();
12
+ /**
13
+ * Initialize.
14
+ * @param {Adler32AcceptDataType} data Data.
15
+ * @deprecated Append data via the method {@linkcode Adler32.update} or {@linkcode Adler32.updateFromStream} instead.
16
+ */
17
+ constructor(data: Adler32AcceptDataType);
13
18
  /**
14
19
  * Whether the instance is freezed.
15
20
  * @returns {boolean}
package/mod.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["src/mod.ts"],"names":[],"mappings":"AAIA,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"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["src/mod.ts"],"names":[],"mappings":"AAIA,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;;OAEG;;IAEH;;;;OAIG;gBACS,IAAI,EAAE,qBAAqB;IAMvC;;;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
@@ -14,10 +14,6 @@ export class Adler32 {
14
14
  #hashUint8Array = null;
15
15
  #a = 1n;
16
16
  #b = 0n;
17
- /**
18
- * Initialize.
19
- * @param {Adler32AcceptDataType} [data] Data. Can append later via the method {@linkcode Adler32.update} and {@linkcode Adler32.updateFromStream}.
20
- */
21
17
  constructor(data) {
22
18
  if (typeof data !== "undefined") {
23
19
  this.update(data);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hugoalh/adler32",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "description": "A module to get the checksum of the data with algorithm Adler32.",
5
5
  "keywords": [
6
6
  "adler32",