utilitas 2001.1.102 → 2001.1.103

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/manifest.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  const manifest = {
2
2
  "name": "utilitas",
3
3
  "description": "Just another common utility for JavaScript.",
4
- "version": "2001.1.102",
4
+ "version": "2001.1.103",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/utilitas",
7
7
  "main": "index.mjs",
package/lib/utilitas.mjs CHANGED
@@ -850,12 +850,14 @@ const getLockKey = key => {
850
850
  };
851
851
 
852
852
  const lock = async (key, options) => {
853
- key = getLockKey(key);
854
- while (new Date().getTime() - parseInt(LOCKS?.[key] || 0)
855
- < (options?.timeout || 1000)) {
853
+ const stdKey = getLockKey(key);
854
+ while (new Date().getTime() < parseInt(LOCKS?.[stdKey] || 0)) {
856
855
  await timeout(options?.checkInterval || 1000);
857
856
  }
858
- return (LOCKS[key] = new Date().getTime());
857
+ return {
858
+ time: LOCKS[stdKey] = new Date().getTime() + (options?.timeout || 1000),
859
+ unlock: () => unlock(key),
860
+ };
859
861
  };
860
862
 
861
863
  export {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "utilitas",
3
3
  "description": "Just another common utility for JavaScript.",
4
- "version": "2001.1.102",
4
+ "version": "2001.1.103",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/utilitas",
7
7
  "main": "index.mjs",