xcraft-core-utils 4.12.1 → 4.13.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.
@@ -28,6 +28,10 @@ class ArrayCollector {
28
28
  this._addByKey(key, data);
29
29
  this.release();
30
30
  }
31
+
32
+ cancel() {
33
+ this.release.cancel();
34
+ }
31
35
  }
32
36
 
33
37
  module.exports = ArrayCollector;
package/lib/files.js CHANGED
@@ -171,7 +171,7 @@ exports.getMimeType = async function (filePath) {
171
171
  const result = magic.detect(filePath, magic.flags | MagicFlags.MAGIC_MIME);
172
172
  let [mime, charset] = result.split(';');
173
173
  mime = mime.trim();
174
- charset = charset.trim().split('=')[1];
174
+ charset = charset ? charset.trim().split('=')[1] : '';
175
175
  return {mime, charset};
176
176
  } finally {
177
177
  FileMagic.close();
package/lib/locks.js CHANGED
@@ -70,31 +70,29 @@ class RecursiveMutex extends Mutex {
70
70
  }
71
71
 
72
72
  class GetMutex {
73
+ #mutexes = new Map();
74
+
73
75
  constructor() {
74
- this._mutexes = {};
75
76
  watt.wrapAll(this, 'lock');
76
77
  }
77
78
 
78
- _cleanupMutex(key) {
79
- if (!this._mutexes[key] || this._mutexes[key].isLocked) {
79
+ #cleanupMutex(key) {
80
+ if (!this.#mutexes.has(key) || this.#mutexes.get(key).isLocked) {
80
81
  return;
81
82
  }
82
- delete this._mutexes[key];
83
+ this.#mutexes.delete(key);
83
84
  }
84
85
 
85
86
  *lock(key, next) {
86
- if (this._mutexes[key]) {
87
- yield this._mutexes[key].lock(next.arg(0));
88
- return;
87
+ if (!this.#mutexes.has(key)) {
88
+ this.#mutexes.set(key, locks.createMutex());
89
89
  }
90
-
91
- this._mutexes[key] = locks.createMutex();
92
- yield this._mutexes[key].lock(next.arg(0));
90
+ yield this.#mutexes.get(key).lock(next.arg(0));
93
91
  }
94
92
 
95
93
  unlock(key) {
96
- this._mutexes[key]?.unlock();
97
- this._cleanupMutex(key);
94
+ this.#mutexes.get(key)?.unlock();
95
+ this.#cleanupMutex(key);
98
96
  }
99
97
  }
100
98
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xcraft-core-utils",
3
- "version": "4.12.1",
3
+ "version": "4.13.0",
4
4
  "description": "Xcraft utils",
5
5
  "main": "index.js",
6
6
  "engines": {