memfs 4.45.0 → 4.46.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.
@@ -1 +1,20 @@
1
- export { inspect, format, inherits, promisify } from 'node:util';
1
+ /**
2
+ * Minimal implementation of Node.js util.inherits function.
3
+ * Sets up prototype inheritance between constructor functions.
4
+ */
5
+ export declare function inherits(ctor: any, superCtor: any): void;
6
+ /**
7
+ * Minimal implementation of Node.js util.promisify function.
8
+ * Converts callback-based functions to Promise-based functions.
9
+ */
10
+ export declare function promisify(fn: Function): Function;
11
+ /**
12
+ * Minimal implementation of Node.js util.inspect function.
13
+ * Converts a value to a string representation for debugging.
14
+ */
15
+ export declare function inspect(value: any): string;
16
+ /**
17
+ * Minimal implementation of Node.js util.format function.
18
+ * Provides printf-style string formatting with basic placeholder support.
19
+ */
20
+ export declare function format(template: string, ...args: any[]): string;
@@ -1,9 +1,112 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.promisify = exports.inherits = exports.format = exports.inspect = void 0;
4
- var node_util_1 = require("node:util");
5
- Object.defineProperty(exports, "inspect", { enumerable: true, get: function () { return node_util_1.inspect; } });
6
- Object.defineProperty(exports, "format", { enumerable: true, get: function () { return node_util_1.format; } });
7
- Object.defineProperty(exports, "inherits", { enumerable: true, get: function () { return node_util_1.inherits; } });
8
- Object.defineProperty(exports, "promisify", { enumerable: true, get: function () { return node_util_1.promisify; } });
3
+ exports.inherits = inherits;
4
+ exports.promisify = promisify;
5
+ exports.inspect = inspect;
6
+ exports.format = format;
7
+ /**
8
+ * Minimal implementation of Node.js util.inherits function.
9
+ * Sets up prototype inheritance between constructor functions.
10
+ */
11
+ function inherits(ctor, superCtor) {
12
+ if (ctor === undefined || ctor === null) {
13
+ throw new TypeError('The constructor to inherit from is not defined');
14
+ }
15
+ if (superCtor === undefined || superCtor === null) {
16
+ throw new TypeError('The super constructor to inherit from is not defined');
17
+ }
18
+ ctor.super_ = superCtor;
19
+ ctor.prototype = Object.create(superCtor.prototype, {
20
+ constructor: {
21
+ value: ctor,
22
+ enumerable: false,
23
+ writable: true,
24
+ configurable: true,
25
+ },
26
+ });
27
+ }
28
+ /**
29
+ * Minimal implementation of Node.js util.promisify function.
30
+ * Converts callback-based functions to Promise-based functions.
31
+ */
32
+ function promisify(fn) {
33
+ if (typeof fn !== 'function') {
34
+ throw new TypeError('The "original" argument must be of type function');
35
+ }
36
+ return function (...args) {
37
+ return new Promise((resolve, reject) => {
38
+ fn.call(this, ...args, (err, result) => {
39
+ if (err) {
40
+ reject(err);
41
+ }
42
+ else {
43
+ resolve(result);
44
+ }
45
+ });
46
+ });
47
+ };
48
+ }
49
+ /**
50
+ * Minimal implementation of Node.js util.inspect function.
51
+ * Converts a value to a string representation for debugging.
52
+ */
53
+ function inspect(value) {
54
+ if (value === null)
55
+ return 'null';
56
+ if (value === undefined)
57
+ return 'undefined';
58
+ if (typeof value === 'string')
59
+ return `'${value}'`;
60
+ if (typeof value === 'number' || typeof value === 'boolean')
61
+ return String(value);
62
+ if (Array.isArray(value)) {
63
+ const items = value.map(item => inspect(item)).join(', ');
64
+ return `[ ${items} ]`;
65
+ }
66
+ if (typeof value === 'object') {
67
+ const entries = Object.entries(value)
68
+ .map(([key, val]) => `${key}: ${inspect(val)}`)
69
+ .join(', ');
70
+ return `{ ${entries} }`;
71
+ }
72
+ return String(value);
73
+ }
74
+ /**
75
+ * Minimal implementation of Node.js util.format function.
76
+ * Provides printf-style string formatting with basic placeholder support.
77
+ */
78
+ function format(template, ...args) {
79
+ if (args.length === 0)
80
+ return template;
81
+ let result = template;
82
+ let argIndex = 0;
83
+ // Replace %s (string), %d (number), %j (JSON) placeholders
84
+ result = result.replace(/%[sdj%]/g, match => {
85
+ if (argIndex >= args.length)
86
+ return match;
87
+ const arg = args[argIndex++];
88
+ switch (match) {
89
+ case '%s':
90
+ return String(arg);
91
+ case '%d':
92
+ return Number(arg).toString();
93
+ case '%j':
94
+ try {
95
+ return JSON.stringify(arg);
96
+ }
97
+ catch {
98
+ return '[Circular]';
99
+ }
100
+ case '%%':
101
+ return '%';
102
+ default:
103
+ return match;
104
+ }
105
+ });
106
+ // Append remaining arguments
107
+ while (argIndex < args.length) {
108
+ result += ' ' + String(args[argIndex++]);
109
+ }
110
+ return result;
111
+ }
9
112
  //# sourceMappingURL=util.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../../../src/vendor/node/util.ts"],"names":[],"mappings":";;;AAAA,uCAAiE;AAAxD,oGAAA,OAAO,OAAA;AAAE,mGAAA,MAAM,OAAA;AAAE,qGAAA,QAAQ,OAAA;AAAE,sGAAA,SAAS,OAAA"}
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../../../src/vendor/node/util.ts"],"names":[],"mappings":";;AAIA,4BAgBC;AAMD,8BAgBC;AAMD,0BAgBC;AAMD,wBAmCC;AAzGD;;;GAGG;AACH,SAAgB,QAAQ,CAAC,IAAS,EAAE,SAAc;IAChD,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QACxC,MAAM,IAAI,SAAS,CAAC,gDAAgD,CAAC,CAAC;IACxE,CAAC;IACD,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QAClD,MAAM,IAAI,SAAS,CAAC,sDAAsD,CAAC,CAAC;IAC9E,CAAC;IACD,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IACxB,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE;QAClD,WAAW,EAAE;YACX,KAAK,EAAE,IAAI;YACX,UAAU,EAAE,KAAK;YACjB,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,IAAI;SACnB;KACF,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,SAAgB,SAAS,CAAC,EAAY;IACpC,IAAI,OAAO,EAAE,KAAK,UAAU,E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;IAC3C,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memfs",
3
- "version": "4.45.0",
3
+ "version": "4.46.0",
4
4
  "description": "In-memory file-system with Node's fs API.",
5
5
  "keywords": [
6
6
  "fs",