nitropack-nightly 2.11.7-20250317-115902.2cf38327 → 2.11.7-20250317-120939.729315be
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/meta/index.d.mts
CHANGED
package/dist/meta/index.d.ts
CHANGED
package/dist/meta/index.mjs
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
export declare function hash(value: any): any;
|
|
2
|
-
/**
|
|
3
|
-
Source: https://github.com/unjs/ohash/blob/v1/src/object-hash.ts
|
|
4
|
-
Based on https://github.com/puleos/object-hash v3.0.0 (MIT)
|
|
5
|
-
*/
|
|
6
1
|
export declare function serialize(object: any): string;
|
|
2
|
+
export declare function hash(value: any): any;
|
|
@@ -1,179 +1,183 @@
|
|
|
1
1
|
import { digest } from "ohash";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
let objType = "";
|
|
26
|
-
const objectLength = objString.length;
|
|
27
|
-
objType = objectLength < 10 ? "unknown:[" + objString + "]" : objString.slice(8, objectLength - 1);
|
|
28
|
-
objType = objType.toLowerCase();
|
|
29
|
-
let objectNumber = null;
|
|
30
|
-
if ((objectNumber = this.#context.get(object)) === void 0) {
|
|
31
|
-
this.#context.set(object, this.#context.size);
|
|
32
|
-
} else {
|
|
33
|
-
return this.dispatch("[CIRCULAR:" + objectNumber + "]");
|
|
34
|
-
}
|
|
35
|
-
if (typeof Buffer !== "undefined" && Buffer.isBuffer && Buffer.isBuffer(object)) {
|
|
36
|
-
this.write("buffer:");
|
|
37
|
-
return this.write(object.toString("utf8"));
|
|
38
|
-
}
|
|
39
|
-
if (objType !== "object" && objType !== "function" && objType !== "asyncfunction") {
|
|
40
|
-
if (this[objType]) {
|
|
41
|
-
this[objType](object);
|
|
2
|
+
const Hasher = /* @__PURE__ */ (() => {
|
|
3
|
+
class Hasher2 {
|
|
4
|
+
buff = "";
|
|
5
|
+
#context = /* @__PURE__ */ new Map();
|
|
6
|
+
write(str) {
|
|
7
|
+
this.buff += str;
|
|
8
|
+
}
|
|
9
|
+
dispatch(value) {
|
|
10
|
+
const type = value === null ? "null" : typeof value;
|
|
11
|
+
return this[type](value);
|
|
12
|
+
}
|
|
13
|
+
object(object) {
|
|
14
|
+
if (object && typeof object.toJSON === "function") {
|
|
15
|
+
return this.object(object.toJSON());
|
|
16
|
+
}
|
|
17
|
+
const objString = Object.prototype.toString.call(object);
|
|
18
|
+
let objType = "";
|
|
19
|
+
const objectLength = objString.length;
|
|
20
|
+
objType = objectLength < 10 ? "unknown:[" + objString + "]" : objString.slice(8, objectLength - 1);
|
|
21
|
+
objType = objType.toLowerCase();
|
|
22
|
+
let objectNumber = null;
|
|
23
|
+
if ((objectNumber = this.#context.get(object)) === void 0) {
|
|
24
|
+
this.#context.set(object, this.#context.size);
|
|
42
25
|
} else {
|
|
43
|
-
this.
|
|
26
|
+
return this.dispatch("[CIRCULAR:" + objectNumber + "]");
|
|
44
27
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
this.write("object:" + (keys.length + extraKeys.length) + ":");
|
|
49
|
-
const dispatchForKey = (key) => {
|
|
50
|
-
this.dispatch(key);
|
|
51
|
-
this.write(":");
|
|
52
|
-
this.dispatch(object[key]);
|
|
53
|
-
this.write(",");
|
|
54
|
-
};
|
|
55
|
-
for (const key of keys) {
|
|
56
|
-
dispatchForKey(key);
|
|
28
|
+
if (typeof Buffer !== "undefined" && Buffer.isBuffer && Buffer.isBuffer(object)) {
|
|
29
|
+
this.write("buffer:");
|
|
30
|
+
return this.write(object.toString("utf8"));
|
|
57
31
|
}
|
|
58
|
-
|
|
59
|
-
|
|
32
|
+
if (objType !== "object" && objType !== "function" && objType !== "asyncfunction") {
|
|
33
|
+
if (this[objType]) {
|
|
34
|
+
this[objType](object);
|
|
35
|
+
} else {
|
|
36
|
+
this.unknown(object, objType);
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
const keys = Object.keys(object).sort();
|
|
40
|
+
const extraKeys = [];
|
|
41
|
+
this.write("object:" + (keys.length + extraKeys.length) + ":");
|
|
42
|
+
const dispatchForKey = (key) => {
|
|
43
|
+
this.dispatch(key);
|
|
44
|
+
this.write(":");
|
|
45
|
+
this.dispatch(object[key]);
|
|
46
|
+
this.write(",");
|
|
47
|
+
};
|
|
48
|
+
for (const key of keys) {
|
|
49
|
+
dispatchForKey(key);
|
|
50
|
+
}
|
|
51
|
+
for (const key of extraKeys) {
|
|
52
|
+
dispatchForKey(key);
|
|
53
|
+
}
|
|
60
54
|
}
|
|
61
55
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
56
|
+
array(arr, unordered) {
|
|
57
|
+
unordered = unordered === void 0 ? false : unordered;
|
|
58
|
+
this.write("array:" + arr.length + ":");
|
|
59
|
+
if (!unordered || arr.length <= 1) {
|
|
60
|
+
for (const entry of arr) {
|
|
61
|
+
this.dispatch(entry);
|
|
62
|
+
}
|
|
63
|
+
return;
|
|
69
64
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
65
|
+
const contextAdditions = /* @__PURE__ */ new Map();
|
|
66
|
+
const entries = arr.map((entry) => {
|
|
67
|
+
const hasher = new Hasher2();
|
|
68
|
+
hasher.dispatch(entry);
|
|
69
|
+
for (const [key, value] of hasher.#context) {
|
|
70
|
+
contextAdditions.set(key, value);
|
|
71
|
+
}
|
|
72
|
+
return hasher.toString();
|
|
73
|
+
});
|
|
74
|
+
this.#context = contextAdditions;
|
|
75
|
+
entries.sort();
|
|
76
|
+
return this.array(entries, false);
|
|
77
|
+
}
|
|
78
|
+
date(date) {
|
|
79
|
+
return this.write("date:" + date.toJSON());
|
|
80
|
+
}
|
|
81
|
+
symbol(sym) {
|
|
82
|
+
return this.write("symbol:" + sym.toString());
|
|
83
|
+
}
|
|
84
|
+
unknown(value, type) {
|
|
85
|
+
this.write(type);
|
|
86
|
+
if (!value) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
this.write(":");
|
|
90
|
+
if (value && typeof value.entries === "function") {
|
|
91
|
+
return this.array(
|
|
92
|
+
[...value.entries()],
|
|
93
|
+
true
|
|
94
|
+
/* ordered */
|
|
95
|
+
);
|
|
78
96
|
}
|
|
79
|
-
return hasher.toString();
|
|
80
|
-
});
|
|
81
|
-
this.#context = contextAdditions;
|
|
82
|
-
entries.sort();
|
|
83
|
-
return this.array(entries, false);
|
|
84
|
-
}
|
|
85
|
-
date(date) {
|
|
86
|
-
return this.write("date:" + date.toJSON());
|
|
87
|
-
}
|
|
88
|
-
symbol(sym) {
|
|
89
|
-
return this.write("symbol:" + sym.toString());
|
|
90
|
-
}
|
|
91
|
-
unknown(value, type) {
|
|
92
|
-
this.write(type);
|
|
93
|
-
if (!value) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
this.write(":");
|
|
97
|
-
if (value && typeof value.entries === "function") {
|
|
98
|
-
return this.array(
|
|
99
|
-
[...value.entries()],
|
|
100
|
-
true
|
|
101
|
-
/* ordered */
|
|
102
|
-
);
|
|
103
97
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
98
|
+
error(err) {
|
|
99
|
+
return this.write("error:" + err.toString());
|
|
100
|
+
}
|
|
101
|
+
boolean(bool) {
|
|
102
|
+
return this.write("bool:" + bool);
|
|
103
|
+
}
|
|
104
|
+
string(string) {
|
|
105
|
+
this.write("string:" + string.length + ":");
|
|
106
|
+
this.write(string);
|
|
107
|
+
}
|
|
108
|
+
function(fn) {
|
|
109
|
+
this.write("fn:");
|
|
110
|
+
if (isNativeFunction(fn)) {
|
|
111
|
+
this.dispatch("[native]");
|
|
112
|
+
} else {
|
|
113
|
+
this.dispatch(fn.toString());
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
number(number) {
|
|
117
|
+
return this.write("number:" + number);
|
|
118
|
+
}
|
|
119
|
+
null() {
|
|
120
|
+
return this.write("Null");
|
|
121
|
+
}
|
|
122
|
+
undefined() {
|
|
123
|
+
return this.write("Undefined");
|
|
124
|
+
}
|
|
125
|
+
regexp(regex) {
|
|
126
|
+
return this.write("regex:" + regex.toString());
|
|
127
|
+
}
|
|
128
|
+
arraybuffer(arr) {
|
|
129
|
+
this.write("arraybuffer:");
|
|
130
|
+
return this.dispatch(new Uint8Array(arr));
|
|
131
|
+
}
|
|
132
|
+
url(url) {
|
|
133
|
+
return this.write("url:" + url.toString());
|
|
134
|
+
}
|
|
135
|
+
map(map) {
|
|
136
|
+
this.write("map:");
|
|
137
|
+
const arr = [...map];
|
|
138
|
+
return this.array(arr, false);
|
|
139
|
+
}
|
|
140
|
+
set(set) {
|
|
141
|
+
this.write("set:");
|
|
142
|
+
const arr = [...set];
|
|
143
|
+
return this.array(arr, false);
|
|
144
|
+
}
|
|
145
|
+
bigint(number) {
|
|
146
|
+
return this.write("bigint:" + number.toString());
|
|
121
147
|
}
|
|
122
148
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
set(set) {
|
|
148
|
-
this.write("set:");
|
|
149
|
-
const arr = [...set];
|
|
150
|
-
return this.array(arr, false);
|
|
151
|
-
}
|
|
152
|
-
bigint(number) {
|
|
153
|
-
return this.write("bigint:" + number.toString());
|
|
149
|
+
for (const type of [
|
|
150
|
+
"uint8array",
|
|
151
|
+
"uint8clampedarray",
|
|
152
|
+
"unt8array",
|
|
153
|
+
"uint16array",
|
|
154
|
+
"unt16array",
|
|
155
|
+
"uint32array",
|
|
156
|
+
"unt32array",
|
|
157
|
+
"float32array",
|
|
158
|
+
"float64array"
|
|
159
|
+
]) {
|
|
160
|
+
Hasher2.prototype[type] = function(arr) {
|
|
161
|
+
this.write(type + ":");
|
|
162
|
+
return this.array([...arr], false);
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
function isNativeFunction(f) {
|
|
166
|
+
if (typeof f !== "function") {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
return Function.prototype.toString.call(f).slice(
|
|
170
|
+
-15
|
|
171
|
+
/* "[native code] }".length */
|
|
172
|
+
) === "[native code] }";
|
|
154
173
|
}
|
|
174
|
+
return Hasher2;
|
|
175
|
+
})();
|
|
176
|
+
export function serialize(object) {
|
|
177
|
+
const hasher = new Hasher();
|
|
178
|
+
hasher.dispatch(object);
|
|
179
|
+
return hasher.buff;
|
|
155
180
|
}
|
|
156
|
-
|
|
157
|
-
"
|
|
158
|
-
"uint8clampedarray",
|
|
159
|
-
"unt8array",
|
|
160
|
-
"uint16array",
|
|
161
|
-
"unt16array",
|
|
162
|
-
"uint32array",
|
|
163
|
-
"unt32array",
|
|
164
|
-
"float32array",
|
|
165
|
-
"float64array"
|
|
166
|
-
]) {
|
|
167
|
-
Hasher.prototype[type] = function(arr) {
|
|
168
|
-
this.write(type + ":");
|
|
169
|
-
return this.array([...arr], false);
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
const nativeFunc = "[native code] }";
|
|
173
|
-
const nativeFuncLength = nativeFunc.length;
|
|
174
|
-
function isNativeFunction(f) {
|
|
175
|
-
if (typeof f !== "function") {
|
|
176
|
-
return false;
|
|
177
|
-
}
|
|
178
|
-
return Function.prototype.toString.call(f).slice(-nativeFuncLength) === nativeFunc;
|
|
181
|
+
export function hash(value) {
|
|
182
|
+
return digest(typeof value === "string" ? value : serialize(value)).replace(/[-_]/g, "").slice(0, 10);
|
|
179
183
|
}
|
package/package.json
CHANGED