@gjsify/assert 0.3.16 → 0.3.18

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/esm/index.js CHANGED
@@ -1,431 +1 @@
1
- import { AssertionError } from "./assertion-error.js";
2
- import { isDeepEqual, isDeepStrictEqual } from "./deep-equal.js";
3
-
4
- //#region src/index.ts
5
- function innerFail(obj) {
6
- if (obj.message instanceof Error) throw obj.message;
7
- throw new AssertionError({
8
- actual: obj.actual,
9
- expected: obj.expected,
10
- message: obj.message,
11
- operator: obj.operator,
12
- stackStartFn: obj.stackStartFn
13
- });
14
- }
15
- function isPromiseLike(val) {
16
- return val !== null && typeof val === "object" && typeof val.then === "function";
17
- }
18
- function ok(value, message) {
19
- if (!value) {
20
- innerFail({
21
- actual: value,
22
- expected: true,
23
- message,
24
- operator: "==",
25
- stackStartFn: ok
26
- });
27
- }
28
- }
29
- function equal(actual, expected, message) {
30
- if (actual != expected) {
31
- innerFail({
32
- actual,
33
- expected,
34
- message,
35
- operator: "==",
36
- stackStartFn: equal
37
- });
38
- }
39
- }
40
- function notEqual(actual, expected, message) {
41
- if (actual == expected) {
42
- innerFail({
43
- actual,
44
- expected,
45
- message,
46
- operator: "!=",
47
- stackStartFn: notEqual
48
- });
49
- }
50
- }
51
- function strictEqual(actual, expected, message) {
52
- if (!Object.is(actual, expected)) {
53
- innerFail({
54
- actual,
55
- expected,
56
- message,
57
- operator: "strictEqual",
58
- stackStartFn: strictEqual
59
- });
60
- }
61
- }
62
- function notStrictEqual(actual, expected, message) {
63
- if (Object.is(actual, expected)) {
64
- innerFail({
65
- actual,
66
- expected,
67
- message,
68
- operator: "notStrictEqual",
69
- stackStartFn: notStrictEqual
70
- });
71
- }
72
- }
73
- function deepEqual(actual, expected, message) {
74
- if (!isDeepEqual(actual, expected)) {
75
- innerFail({
76
- actual,
77
- expected,
78
- message,
79
- operator: "deepEqual",
80
- stackStartFn: deepEqual
81
- });
82
- }
83
- }
84
- function notDeepEqual(actual, expected, message) {
85
- if (isDeepEqual(actual, expected)) {
86
- innerFail({
87
- actual,
88
- expected,
89
- message,
90
- operator: "notDeepEqual",
91
- stackStartFn: notDeepEqual
92
- });
93
- }
94
- }
95
- function deepStrictEqual(actual, expected, message) {
96
- if (!isDeepStrictEqual(actual, expected)) {
97
- innerFail({
98
- actual,
99
- expected,
100
- message,
101
- operator: "deepStrictEqual",
102
- stackStartFn: deepStrictEqual
103
- });
104
- }
105
- }
106
- function notDeepStrictEqual(actual, expected, message) {
107
- if (isDeepStrictEqual(actual, expected)) {
108
- innerFail({
109
- actual,
110
- expected,
111
- message,
112
- operator: "notDeepStrictEqual",
113
- stackStartFn: notDeepStrictEqual
114
- });
115
- }
116
- }
117
- function getActual(fn) {
118
- const NO_EXCEPTION = Symbol("NO_EXCEPTION");
119
- try {
120
- fn();
121
- } catch (e) {
122
- return e;
123
- }
124
- return NO_EXCEPTION;
125
- }
126
- async function getActualAsync(fn) {
127
- const NO_EXCEPTION = Symbol("NO_EXCEPTION");
128
- try {
129
- if (typeof fn === "function") {
130
- const result = fn();
131
- if (isPromiseLike(result)) {
132
- await result;
133
- }
134
- } else {
135
- await fn;
136
- }
137
- } catch (e) {
138
- return e;
139
- }
140
- return NO_EXCEPTION;
141
- }
142
- function expectedException(actual, expected, message, fn) {
143
- if (expected === undefined) return true;
144
- if (expected instanceof RegExp) {
145
- const str = String(actual);
146
- if (expected.test(str)) return true;
147
- throw new AssertionError({
148
- actual,
149
- expected,
150
- message,
151
- operator: fn.name,
152
- stackStartFn: fn
153
- });
154
- }
155
- if (typeof expected === "function") {
156
- if (expected.prototype !== undefined && actual instanceof expected) {
157
- return true;
158
- }
159
- if (Error.isPrototypeOf(expected)) {
160
- return false;
161
- }
162
- const result = expected.call({}, actual);
163
- if (result !== true) {
164
- throw new AssertionError({
165
- actual,
166
- expected,
167
- message,
168
- operator: fn.name,
169
- stackStartFn: fn
170
- });
171
- }
172
- return true;
173
- }
174
- if (typeof expected === "object" && expected !== null) {
175
- const keys = Object.keys(expected);
176
- for (const key of keys) {
177
- const expectedObj = expected;
178
- const actualObj = actual;
179
- if (typeof actualObj[key] === "string" && expectedObj[key] instanceof RegExp) {
180
- if (!expectedObj[key].test(actualObj[key])) {
181
- throw new AssertionError({
182
- actual,
183
- expected,
184
- message,
185
- operator: fn.name,
186
- stackStartFn: fn
187
- });
188
- }
189
- } else if (!isDeepStrictEqual(actualObj[key], expectedObj[key])) {
190
- throw new AssertionError({
191
- actual,
192
- expected,
193
- message,
194
- operator: fn.name,
195
- stackStartFn: fn
196
- });
197
- }
198
- }
199
- return true;
200
- }
201
- return true;
202
- }
203
- function throws(fn, errorOrMessage, message) {
204
- if (typeof fn !== "function") {
205
- throw new TypeError("The \"fn\" argument must be of type function.");
206
- }
207
- let expected;
208
- if (typeof errorOrMessage === "string") {
209
- message = errorOrMessage;
210
- expected = undefined;
211
- } else {
212
- expected = errorOrMessage;
213
- }
214
- const actual = getActual(fn);
215
- if (typeof actual === "symbol") {
216
- innerFail({
217
- actual: undefined,
218
- expected,
219
- message: message || "Missing expected exception.",
220
- operator: "throws",
221
- stackStartFn: throws
222
- });
223
- }
224
- if (expected !== undefined) {
225
- expectedException(actual, expected, message, throws);
226
- }
227
- }
228
- function doesNotThrow(fn, errorOrMessage, message) {
229
- if (typeof fn !== "function") {
230
- throw new TypeError("The \"fn\" argument must be of type function.");
231
- }
232
- let expected;
233
- if (typeof errorOrMessage === "string") {
234
- message = errorOrMessage;
235
- expected = undefined;
236
- } else {
237
- expected = errorOrMessage;
238
- }
239
- const actual = getActual(fn);
240
- if (typeof actual === "symbol") {
241
- return;
242
- }
243
- if (expected !== undefined && typeof expected === "function" && expected.prototype !== undefined && actual instanceof expected) {
244
- innerFail({
245
- actual,
246
- expected,
247
- message: message || `Got unwanted exception.\n${actual && actual.message ? actual.message : ""}`,
248
- operator: "doesNotThrow",
249
- stackStartFn: doesNotThrow
250
- });
251
- }
252
- if (expected === undefined || typeof expected === "function" && expected.prototype !== undefined && actual instanceof expected) {
253
- innerFail({
254
- actual,
255
- expected,
256
- message: message || `Got unwanted exception.\n${actual && actual.message ? actual.message : ""}`,
257
- operator: "doesNotThrow",
258
- stackStartFn: doesNotThrow
259
- });
260
- }
261
- throw actual;
262
- }
263
- async function rejects(asyncFn, errorOrMessage, message) {
264
- let expected;
265
- if (typeof errorOrMessage === "string") {
266
- message = errorOrMessage;
267
- expected = undefined;
268
- } else {
269
- expected = errorOrMessage;
270
- }
271
- const actual = await getActualAsync(asyncFn);
272
- if (typeof actual === "symbol") {
273
- innerFail({
274
- actual: undefined,
275
- expected,
276
- message: message || "Missing expected rejection.",
277
- operator: "rejects",
278
- stackStartFn: rejects
279
- });
280
- }
281
- if (expected !== undefined) {
282
- expectedException(actual, expected, message, rejects);
283
- }
284
- }
285
- async function doesNotReject(asyncFn, errorOrMessage, message) {
286
- let expected;
287
- if (typeof errorOrMessage === "string") {
288
- message = errorOrMessage;
289
- expected = undefined;
290
- } else {
291
- expected = errorOrMessage;
292
- }
293
- const actual = await getActualAsync(asyncFn);
294
- if (typeof actual !== "symbol") {
295
- innerFail({
296
- actual,
297
- expected,
298
- message: message || `Got unwanted rejection.\n${actual && actual.message ? actual.message : ""}`,
299
- operator: "doesNotReject",
300
- stackStartFn: doesNotReject
301
- });
302
- }
303
- }
304
- function fail(actualOrMessage, expected, message, operator, stackStartFn) {
305
- if (arguments.length === 0 || arguments.length === 1) {
306
- const msg = arguments.length === 0 ? "Failed" : typeof actualOrMessage === "string" ? actualOrMessage : undefined;
307
- if (actualOrMessage instanceof Error) throw actualOrMessage;
308
- throw new AssertionError({
309
- message: msg || "Failed",
310
- operator: "fail",
311
- stackStartFn: fail
312
- });
313
- }
314
- throw new AssertionError({
315
- actual: actualOrMessage,
316
- expected,
317
- message,
318
- operator: operator || "fail",
319
- stackStartFn: stackStartFn || fail
320
- });
321
- }
322
- function ifError(value) {
323
- if (value !== null && value !== undefined) {
324
- let message = "ifError got unwanted exception: ";
325
- if (typeof value === "object" && typeof value.message === "string") {
326
- if (value.message.length === 0 && value.constructor) {
327
- message += value.constructor.name;
328
- } else {
329
- message += value.message;
330
- }
331
- } else {
332
- message += String(value);
333
- }
334
- const err = new AssertionError({
335
- actual: value,
336
- expected: null,
337
- message,
338
- operator: "ifError",
339
- stackStartFn: ifError
340
- });
341
- const origStack = value instanceof Error ? value.stack : undefined;
342
- if (origStack) {
343
- err.origStack = origStack;
344
- }
345
- throw err;
346
- }
347
- }
348
- function match(actual, expected, message) {
349
- if (typeof actual !== "string") {
350
- throw new TypeError("The \"actual\" argument must be of type string.");
351
- }
352
- if (!(expected instanceof RegExp)) {
353
- throw new TypeError("The \"expected\" argument must be an instance of RegExp.");
354
- }
355
- if (!expected.test(actual)) {
356
- innerFail({
357
- actual,
358
- expected,
359
- message: message || `The input did not match the regular expression ${expected}. Input:\n\n'${actual}'\n`,
360
- operator: "match",
361
- stackStartFn: match
362
- });
363
- }
364
- }
365
- function doesNotMatch(actual, expected, message) {
366
- if (typeof actual !== "string") {
367
- throw new TypeError("The \"actual\" argument must be of type string.");
368
- }
369
- if (!(expected instanceof RegExp)) {
370
- throw new TypeError("The \"expected\" argument must be an instance of RegExp.");
371
- }
372
- if (expected.test(actual)) {
373
- innerFail({
374
- actual,
375
- expected,
376
- message: message || `The input was expected to not match the regular expression ${expected}. Input:\n\n'${actual}'\n`,
377
- operator: "doesNotMatch",
378
- stackStartFn: doesNotMatch
379
- });
380
- }
381
- }
382
- const strict = Object.assign(function strict(value, message) {
383
- ok(value, message);
384
- }, {
385
- AssertionError,
386
- ok,
387
- equal: strictEqual,
388
- notEqual: notStrictEqual,
389
- deepEqual: deepStrictEqual,
390
- notDeepEqual: notDeepStrictEqual,
391
- deepStrictEqual,
392
- notDeepStrictEqual,
393
- strictEqual,
394
- notStrictEqual,
395
- throws,
396
- doesNotThrow,
397
- rejects,
398
- doesNotReject,
399
- fail,
400
- ifError,
401
- match,
402
- doesNotMatch,
403
- strict: undefined
404
- });
405
- strict.strict = strict;
406
- const assert = Object.assign(function assert(value, message) {
407
- ok(value, message);
408
- }, {
409
- AssertionError,
410
- ok,
411
- equal,
412
- notEqual,
413
- strictEqual,
414
- notStrictEqual,
415
- deepEqual,
416
- notDeepEqual,
417
- deepStrictEqual,
418
- notDeepStrictEqual,
419
- throws,
420
- doesNotThrow,
421
- rejects,
422
- doesNotReject,
423
- fail,
424
- ifError,
425
- match,
426
- doesNotMatch,
427
- strict
428
- });
429
-
430
- //#endregion
431
- export { AssertionError, deepEqual, deepStrictEqual, assert as default, doesNotMatch, doesNotReject, doesNotThrow, equal, fail, ifError, match, notDeepEqual, notDeepStrictEqual, notEqual, notStrictEqual, ok, rejects, strict, strictEqual, throws };
1
+ import{AssertionError as e}from"./assertion-error.js";import{isDeepEqual as t,isDeepStrictEqual as n}from"./deep-equal.js";function r(t){throw t.message instanceof Error?t.message:new e({actual:t.actual,expected:t.expected,message:t.message,operator:t.operator,stackStartFn:t.stackStartFn})}function i(e){return typeof e==`object`&&!!e&&typeof e.then==`function`}function a(e,t){e||r({actual:e,expected:!0,message:t,operator:`==`,stackStartFn:a})}function o(e,t,n){e!=t&&r({actual:e,expected:t,message:n,operator:`==`,stackStartFn:o})}function s(e,t,n){e==t&&r({actual:e,expected:t,message:n,operator:`!=`,stackStartFn:s})}function c(e,t,n){Object.is(e,t)||r({actual:e,expected:t,message:n,operator:`strictEqual`,stackStartFn:c})}function l(e,t,n){Object.is(e,t)&&r({actual:e,expected:t,message:n,operator:`notStrictEqual`,stackStartFn:l})}function u(e,n,i){t(e,n)||r({actual:e,expected:n,message:i,operator:`deepEqual`,stackStartFn:u})}function d(e,n,i){t(e,n)&&r({actual:e,expected:n,message:i,operator:`notDeepEqual`,stackStartFn:d})}function f(e,t,i){n(e,t)||r({actual:e,expected:t,message:i,operator:`deepStrictEqual`,stackStartFn:f})}function p(e,t,i){n(e,t)&&r({actual:e,expected:t,message:i,operator:`notDeepStrictEqual`,stackStartFn:p})}function m(e){let t=Symbol(`NO_EXCEPTION`);try{e()}catch(e){return e}return t}async function h(e){let t=Symbol(`NO_EXCEPTION`);try{if(typeof e==`function`){let t=e();i(t)&&await t}else await e}catch(e){return e}return t}function g(t,r,i,a){if(r===void 0)return!0;if(r instanceof RegExp){let n=String(t);if(r.test(n))return!0;throw new e({actual:t,expected:r,message:i,operator:a.name,stackStartFn:a})}if(typeof r==`function`){if(r.prototype!==void 0&&t instanceof r)return!0;if(Error.isPrototypeOf(r))return!1;if(r.call({},t)!==!0)throw new e({actual:t,expected:r,message:i,operator:a.name,stackStartFn:a});return!0}if(typeof r==`object`&&r){let o=Object.keys(r);for(let s of o){let o=r,c=t;if(typeof c[s]==`string`&&o[s]instanceof RegExp){if(!o[s].test(c[s]))throw new e({actual:t,expected:r,message:i,operator:a.name,stackStartFn:a})}else if(!n(c[s],o[s]))throw new e({actual:t,expected:r,message:i,operator:a.name,stackStartFn:a})}return!0}return!0}function _(e,t,n){if(typeof e!=`function`)throw TypeError(`The "fn" argument must be of type function.`);let i;typeof t==`string`?(n=t,i=void 0):i=t;let a=m(e);typeof a==`symbol`&&r({actual:void 0,expected:i,message:n||`Missing expected exception.`,operator:`throws`,stackStartFn:_}),i!==void 0&&g(a,i,n,_)}function v(e,t,n){if(typeof e!=`function`)throw TypeError(`The "fn" argument must be of type function.`);let i;typeof t==`string`?(n=t,i=void 0):i=t;let a=m(e);if(typeof a!=`symbol`)throw i!==void 0&&typeof i==`function`&&i.prototype!==void 0&&a instanceof i&&r({actual:a,expected:i,message:n||`Got unwanted exception.\n${a&&a.message?a.message:``}`,operator:`doesNotThrow`,stackStartFn:v}),(i===void 0||typeof i==`function`&&i.prototype!==void 0&&a instanceof i)&&r({actual:a,expected:i,message:n||`Got unwanted exception.\n${a&&a.message?a.message:``}`,operator:`doesNotThrow`,stackStartFn:v}),a}async function y(e,t,n){let i;typeof t==`string`?(n=t,i=void 0):i=t;let a=await h(e);typeof a==`symbol`&&r({actual:void 0,expected:i,message:n||`Missing expected rejection.`,operator:`rejects`,stackStartFn:y}),i!==void 0&&g(a,i,n,y)}async function b(e,t,n){let i;typeof t==`string`?(n=t,i=void 0):i=t;let a=await h(e);typeof a!=`symbol`&&r({actual:a,expected:i,message:n||`Got unwanted rejection.\n${a&&a.message?a.message:``}`,operator:`doesNotReject`,stackStartFn:b})}function x(t,n,r,i,a){if(arguments.length===0||arguments.length===1){let n=arguments.length===0?`Failed`:typeof t==`string`?t:void 0;throw t instanceof Error?t:new e({message:n||`Failed`,operator:`fail`,stackStartFn:x})}throw new e({actual:t,expected:n,message:r,operator:i||`fail`,stackStartFn:a||x})}function S(t){if(t!=null){let n=`ifError got unwanted exception: `;typeof t==`object`&&typeof t.message==`string`?t.message.length===0&&t.constructor?n+=t.constructor.name:n+=t.message:n+=String(t);let r=new e({actual:t,expected:null,message:n,operator:`ifError`,stackStartFn:S}),i=t instanceof Error?t.stack:void 0;throw i&&(r.origStack=i),r}}function C(e,t,n){if(typeof e!=`string`)throw TypeError(`The "actual" argument must be of type string.`);if(!(t instanceof RegExp))throw TypeError(`The "expected" argument must be an instance of RegExp.`);t.test(e)||r({actual:e,expected:t,message:n||`The input did not match the regular expression ${t}. Input:\n\n'${e}'\n`,operator:`match`,stackStartFn:C})}function w(e,t,n){if(typeof e!=`string`)throw TypeError(`The "actual" argument must be of type string.`);if(!(t instanceof RegExp))throw TypeError(`The "expected" argument must be an instance of RegExp.`);t.test(e)&&r({actual:e,expected:t,message:n||`The input was expected to not match the regular expression ${t}. Input:\n\n'${e}'\n`,operator:`doesNotMatch`,stackStartFn:w})}const T=Object.assign(function(e,t){a(e,t)},{AssertionError:e,ok:a,equal:c,notEqual:l,deepEqual:f,notDeepEqual:p,deepStrictEqual:f,notDeepStrictEqual:p,strictEqual:c,notStrictEqual:l,throws:_,doesNotThrow:v,rejects:y,doesNotReject:b,fail:x,ifError:S,match:C,doesNotMatch:w,strict:void 0});T.strict=T;const E=Object.assign(function(e,t){a(e,t)},{AssertionError:e,ok:a,equal:o,notEqual:s,strictEqual:c,notStrictEqual:l,deepEqual:u,notDeepEqual:d,deepStrictEqual:f,notDeepStrictEqual:p,throws:_,doesNotThrow:v,rejects:y,doesNotReject:b,fail:x,ifError:S,match:C,doesNotMatch:w,strict:T});export{e as AssertionError,u as deepEqual,f as deepStrictEqual,E as default,w as doesNotMatch,b as doesNotReject,v as doesNotThrow,o as equal,x as fail,S as ifError,C as match,d as notDeepEqual,p as notDeepStrictEqual,s as notEqual,l as notStrictEqual,a as ok,y as rejects,T as strict,c as strictEqual,_ as throws};
@@ -1,77 +1 @@
1
- //#region src/inspect-fallback.ts
2
- /**
3
- * Minimal value-to-string converter for assertion error messages.
4
- * This avoids depending on util.inspect (which itself depends on @gjsify/deno_std).
5
- * Can be replaced with util.inspect once @gjsify/util is migrated.
6
- */
7
- const MAX_DEPTH = 3;
8
- const MAX_ARRAY_LENGTH = 10;
9
- const MAX_STRING_LENGTH = 128;
10
- function safeInspect(value, depth = MAX_DEPTH) {
11
- if (value === null) return "null";
12
- if (value === undefined) return "undefined";
13
- switch (typeof value) {
14
- case "string":
15
- if (value.length > MAX_STRING_LENGTH) {
16
- return `'${value.slice(0, MAX_STRING_LENGTH)}...'`;
17
- }
18
- return `'${value}'`;
19
- case "number":
20
- case "boolean":
21
- case "bigint": return String(value);
22
- case "symbol": return value.toString();
23
- case "function": return `[Function: ${value.name || "anonymous"}]`;
24
- case "object": return inspectObject(value, depth);
25
- }
26
- return String(value);
27
- }
28
- function inspectObject(obj, depth, seen = new WeakSet()) {
29
- if (seen.has(obj)) return "[Circular]";
30
- seen.add(obj);
31
- if (obj instanceof Date) return obj.toISOString();
32
- if (obj instanceof RegExp) return obj.toString();
33
- if (obj instanceof Error) return `[${obj.constructor.name}: ${obj.message}]`;
34
- if (obj instanceof Map) {
35
- if (depth <= 0) return `Map(${obj.size}) { ... }`;
36
- const entries = [...obj.entries()].slice(0, MAX_ARRAY_LENGTH).map(([k, v]) => `${inspectInner(k, depth - 1, seen)} => ${inspectInner(v, depth - 1, seen)}`);
37
- const suffix = obj.size > MAX_ARRAY_LENGTH ? ", ..." : "";
38
- return `Map(${obj.size}) { ${entries.join(", ")}${suffix} }`;
39
- }
40
- if (obj instanceof Set) {
41
- if (depth <= 0) return `Set(${obj.size}) { ... }`;
42
- const entries = [...obj.values()].slice(0, MAX_ARRAY_LENGTH).map((v) => inspectInner(v, depth - 1, seen));
43
- const suffix = obj.size > MAX_ARRAY_LENGTH ? ", ..." : "";
44
- return `Set(${obj.size}) { ${entries.join(", ")}${suffix} }`;
45
- }
46
- if (ArrayBuffer.isView(obj)) {
47
- const typedName = obj.constructor.name;
48
- const arr = obj instanceof DataView ? new Uint8Array(obj.buffer, obj.byteOffset, obj.byteLength) : obj;
49
- const len = "length" in arr ? arr.length : 0;
50
- const shown = Math.min(len, MAX_ARRAY_LENGTH);
51
- const items = [];
52
- for (let i = 0; i < shown; i++) items.push(String(arr[i]));
53
- const suffix = len > MAX_ARRAY_LENGTH ? ", ..." : "";
54
- return `${typedName}(${len}) [ ${items.join(", ")}${suffix} ]`;
55
- }
56
- if (Array.isArray(obj)) {
57
- if (depth <= 0) return `[ ... ]`;
58
- const shown = obj.slice(0, MAX_ARRAY_LENGTH).map((v) => inspectInner(v, depth - 1, seen));
59
- const suffix = obj.length > MAX_ARRAY_LENGTH ? ", ..." : "";
60
- return `[ ${shown.join(", ")}${suffix} ]`;
61
- }
62
- if (depth <= 0) return "{ ... }";
63
- const keys = Object.keys(obj);
64
- const entries = keys.slice(0, MAX_ARRAY_LENGTH).map((k) => `${k}: ${inspectInner(obj[k], depth - 1, seen)}`);
65
- const suffix = keys.length > MAX_ARRAY_LENGTH ? ", ..." : "";
66
- const prefix = obj.constructor && obj.constructor.name !== "Object" ? `${obj.constructor.name} ` : "";
67
- return `${prefix}{ ${entries.join(", ")}${suffix} }`;
68
- }
69
- function inspectInner(value, depth, seen) {
70
- if (value === null) return "null";
71
- if (value === undefined) return "undefined";
72
- if (typeof value === "object") return inspectObject(value, depth, seen);
73
- return safeInspect(value, depth);
74
- }
75
-
76
- //#endregion
77
- export { safeInspect };
1
+ function e(e,n=3){if(e===null)return`null`;if(e===void 0)return`undefined`;switch(typeof e){case`string`:return e.length>128?`'${e.slice(0,128)}...'`:`'${e}'`;case`number`:case`boolean`:case`bigint`:return String(e);case`symbol`:return e.toString();case`function`:return`[Function: ${e.name||`anonymous`}]`;case`object`:return t(e,n)}return String(e)}function t(e,t,r=new WeakSet){if(r.has(e))return`[Circular]`;if(r.add(e),e instanceof Date)return e.toISOString();if(e instanceof RegExp)return e.toString();if(e instanceof Error)return`[${e.constructor.name}: ${e.message}]`;if(e instanceof Map){if(t<=0)return`Map(${e.size}) { ... }`;let i=[...e.entries()].slice(0,10).map(([e,i])=>`${n(e,t-1,r)} => ${n(i,t-1,r)}`),a=e.size>10?`, ...`:``;return`Map(${e.size}) { ${i.join(`, `)}${a} }`}if(e instanceof Set){if(t<=0)return`Set(${e.size}) { ... }`;let i=[...e.values()].slice(0,10).map(e=>n(e,t-1,r)),a=e.size>10?`, ...`:``;return`Set(${e.size}) { ${i.join(`, `)}${a} }`}if(ArrayBuffer.isView(e)){let t=e.constructor.name,n=e instanceof DataView?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e,r=`length`in n?n.length:0,i=Math.min(r,10),a=[];for(let e=0;e<i;e++)a.push(String(n[e]));let o=r>10?`, ...`:``;return`${t}(${r}) [ ${a.join(`, `)}${o} ]`}if(Array.isArray(e)){if(t<=0)return`[ ... ]`;let i=e.slice(0,10).map(e=>n(e,t-1,r)),a=e.length>10?`, ...`:``;return`[ ${i.join(`, `)}${a} ]`}if(t<=0)return`{ ... }`;let i=Object.keys(e),a=i.slice(0,10).map(i=>`${i}: ${n(e[i],t-1,r)}`),o=i.length>10?`, ...`:``;return`${e.constructor&&e.constructor.name!==`Object`?`${e.constructor.name} `:``}{ ${a.join(`, `)}${o} }`}function n(n,r,i){return n===null?`null`:n===void 0?`undefined`:typeof n==`object`?t(n,r,i):e(n,r)}export{e as safeInspect};
@@ -1,4 +1 @@
1
- import { AssertionError } from "../assertion-error.js";
2
- import { deepStrictEqual, doesNotMatch, doesNotReject, doesNotThrow, fail, ifError, match, notDeepStrictEqual, notStrictEqual, ok, rejects, strict, strictEqual, throws } from "../index.js";
3
-
4
- export { AssertionError, deepStrictEqual as deepEqual, deepStrictEqual, strict as default, doesNotMatch, doesNotReject, doesNotThrow, strictEqual as equal, fail, ifError, match, notDeepStrictEqual as notDeepEqual, notDeepStrictEqual, notStrictEqual as notEqual, notStrictEqual, ok, rejects, strict, strictEqual, throws };
1
+ import{AssertionError as e}from"../assertion-error.js";import{deepStrictEqual as t,doesNotMatch as n,doesNotReject as r,doesNotThrow as i,fail as a,ifError as o,match as s,notDeepStrictEqual as c,notStrictEqual as l,ok as u,rejects as d,strict as f,strictEqual as p,throws as m}from"../index.js";export{e as AssertionError,t as deepEqual,t as deepStrictEqual,f as default,n as doesNotMatch,r as doesNotReject,i as doesNotThrow,p as equal,a as fail,o as ifError,s as match,c as notDeepEqual,c as notDeepStrictEqual,l as notEqual,l as notStrictEqual,u as ok,d as rejects,f as strict,p as strictEqual,m as throws};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/assert",
3
- "version": "0.3.16",
3
+ "version": "0.3.18",
4
4
  "description": "Node.js assert module for Gjs",
5
5
  "type": "module",
6
6
  "module": "lib/esm/index.js",
@@ -35,9 +35,9 @@
35
35
  "assert"
36
36
  ],
37
37
  "devDependencies": {
38
- "@gjsify/cli": "^0.3.16",
39
- "@gjsify/unit": "^0.3.16",
40
- "@types/node": "^25.6.0",
38
+ "@gjsify/cli": "^0.3.18",
39
+ "@gjsify/unit": "^0.3.18",
40
+ "@types/node": "^25.6.2",
41
41
  "typescript": "^6.0.3"
42
42
  }
43
43
  }