memfs 3.2.3 → 3.2.4

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [3.2.4](https://github.com/streamich/memfs/compare/v3.2.3...v3.2.4) (2021-09-02)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * 🐛 use globalThis defensively ([eed6bbf](https://github.com/streamich/memfs/commit/eed6bbfa2fc310639974ed9e163876ff8253b321))
7
+
1
8
  ## [3.2.3](https://github.com/streamich/memfs/compare/v3.2.2...v3.2.3) (2021-08-31)
2
9
 
3
10
 
@@ -1,4 +1,6 @@
1
- declare class AssertionError extends globalThis.Error {
1
+ /// <reference types="node" />
2
+ declare const g: typeof globalThis | NodeJS.Global;
3
+ declare class AssertionError extends g.Error {
2
4
  generatedMessage: any;
3
5
  name: any;
4
6
  code: any;
@@ -42,6 +42,7 @@ function makeNodeError(Base) {
42
42
  return NodeError;
43
43
  }(Base));
44
44
  }
45
+ var g = typeof globalThis !== 'undefined' ? globalThis : global;
45
46
  var AssertionError = /** @class */ (function (_super) {
46
47
  __extends(AssertionError, _super);
47
48
  function AssertionError(options) {
@@ -66,7 +67,7 @@ var AssertionError = /** @class */ (function (_super) {
66
67
  return _this;
67
68
  }
68
69
  return AssertionError;
69
- }(globalThis.Error));
70
+ }(g.Error));
70
71
  exports.AssertionError = AssertionError;
71
72
  function message(key, args) {
72
73
  assert.strictEqual(typeof key, 'string');
@@ -92,9 +93,9 @@ function E(sym, val) {
92
93
  messages[sym] = typeof val === 'function' ? val : String(val);
93
94
  }
94
95
  exports.E = E;
95
- exports.Error = makeNodeError(globalThis.Error);
96
- exports.TypeError = makeNodeError(globalThis.TypeError);
97
- exports.RangeError = makeNodeError(globalThis.RangeError);
96
+ exports.Error = makeNodeError(g.Error);
97
+ exports.TypeError = makeNodeError(g.TypeError);
98
+ exports.RangeError = makeNodeError(g.RangeError);
98
99
  // To declare an error message, use the E(sym, val) function above. The sym
99
100
  // must be an upper case string. The val can be either a function or a string.
100
101
  // The return value of the function must be a string.
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var _setImmediate;
4
4
  if (typeof setImmediate === 'function')
5
- _setImmediate = setImmediate.bind(globalThis);
5
+ _setImmediate = setImmediate.bind(typeof globalThis !== 'undefined' ? globalThis : global);
6
6
  else
7
- _setImmediate = setTimeout.bind(globalThis);
7
+ _setImmediate = setTimeout.bind(typeof globalThis !== 'undefined' ? globalThis : global);
8
8
  exports.default = _setImmediate;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
5
5
  * only in Node's environment it will "unref" its macro task.
6
6
  */
7
7
  function setTimeoutUnref(callback, time, args) {
8
- var ref = setTimeout.apply(globalThis, arguments);
8
+ var ref = setTimeout.apply(typeof globalThis !== 'undefined' ? globalThis : global, arguments);
9
9
  if (ref && typeof ref === 'object' && typeof ref.unref === 'function')
10
10
  ref.unref();
11
11
  return ref;
package/lib/volume.js CHANGED
@@ -1853,7 +1853,7 @@ var StatWatcher = /** @class */ (function (_super) {
1853
1853
  if (persistent === void 0) { persistent = true; }
1854
1854
  if (interval === void 0) { interval = 5007; }
1855
1855
  this.filename = pathToFilename(path);
1856
- this.setTimeout = persistent ? setTimeout.bind(globalThis) : setTimeoutUnref_1.default;
1856
+ this.setTimeout = persistent ? setTimeout.bind(typeof globalThis !== 'undefined' ? globalThis : global) : setTimeoutUnref_1.default;
1857
1857
  this.interval = interval;
1858
1858
  this.prev = this.vol.statSync(this.filename);
1859
1859
  this.loop();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memfs",
3
- "version": "3.2.3",
3
+ "version": "3.2.4",
4
4
  "description": "In-memory file-system with Node's fs API.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",