better-lock 2.0.0-beta → 2.0.3

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.
Files changed (36) hide show
  1. package/.idea/markdown.xml +9 -0
  2. package/README.md +51 -53
  3. package/dist/better_lock.d.ts +7 -4
  4. package/dist/better_lock.js +4 -1
  5. package/dist/better_lock.js.map +1 -1
  6. package/dist/errors.js +3 -1
  7. package/dist/errors.js.map +1 -1
  8. package/docs/.nojekyll +1 -0
  9. package/docs/assets/highlight.css +92 -0
  10. package/docs/assets/icons.css +1043 -0
  11. package/docs/assets/icons.png +0 -0
  12. package/docs/assets/icons@2x.png +0 -0
  13. package/docs/assets/main.js +52 -0
  14. package/docs/assets/search.js +1 -0
  15. package/docs/assets/style.css +1414 -0
  16. package/docs/assets/widgets.png +0 -0
  17. package/docs/assets/widgets@2x.png +0 -0
  18. package/docs/classes/BetterLockError.html +5 -0
  19. package/docs/classes/BetterLockExecutionTimeoutError.html +5 -0
  20. package/docs/classes/BetterLockInternalError.html +5 -0
  21. package/docs/classes/BetterLockInvalidArgumentError.html +5 -0
  22. package/docs/classes/BetterLockJobAbortedError.html +5 -0
  23. package/docs/classes/BetterLockQueueOverflowError.html +5 -0
  24. package/docs/classes/BetterLockWaitTimeoutError.html +5 -0
  25. package/docs/classes/_internal_.BetterLock.html +92 -0
  26. package/docs/classes/_internal_.KeyQueue.html +8 -0
  27. package/docs/classes/_internal_.LockJob.html +28 -0
  28. package/docs/index.html +211 -0
  29. package/docs/interfaces/BetterLockJobOptions.html +9 -0
  30. package/docs/interfaces/BetterLockOptions.html +21 -0
  31. package/docs/modules/_internal_.__home_panta_dev_pantas_better_lock_src_errors_.html +1 -0
  32. package/docs/modules/_internal_.html +7 -0
  33. package/docs/modules.html +5 -0
  34. package/package.json +10 -6
  35. package/src/better_lock.ts +7 -4
  36. package/src/errors.ts +3 -2
@@ -0,0 +1,211 @@
1
+ <!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>better-lock</title><meta name="description" content="Documentation for better-lock"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><script async src="assets/search.js" id="search-script"></script></head><body><script>document.body.classList.add(localStorage.getItem("tsd-theme") || "os")</script><header><div class="tsd-page-toolbar"><div class="container"><div class="table-wrap"><div class="table-cell" id="tsd-search" data-base="."><div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption">Search</label><input type="text" id="tsd-search-field"/></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="index.html" class="title">better-lock</a></div><div class="table-cell" id="tsd-widgets"><div id="tsd-filter"><a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a><div class="tsd-filter-group"><div class="tsd-select" id="tsd-filter-visibility"><span class="tsd-select-label">All</span><ul class="tsd-select-list"><li data-value="public">Public</li><li data-value="protected">Public/Protected</li><li data-value="private" class="selected">All</li></ul></div> <input type="checkbox" id="tsd-filter-inherited" checked/><label class="tsd-widget" for="tsd-filter-inherited">Inherited</label></div></div><a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a></div></div></div></div><div class="tsd-page-title"><div class="container"><h1>better-lock </h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><div class="tsd-panel tsd-typography">
2
+ <a href="#better-lock" id="better-lock" style="color: inherit; text-decoration: none;">
3
+ <h1>Better Lock</h1>
4
+ </a>
5
+ <p>A (better) node.js lock library.</p>
6
+ <p><img src="https://travis-ci.org/panta82/better-lock.svg?branch=master" alt="Travis tests"></p>
7
+
8
+ <a href="#features" id="features" style="color: inherit; text-decoration: none;">
9
+ <h3>Features</h3>
10
+ </a>
11
+ <ul>
12
+ <li>Typescript-ready</li>
13
+ <li>Named and keyed locks</li>
14
+ <li>Queue and execution timeouts</li>
15
+ <li>Queue size limit</li>
16
+ <li>Lock on multiple keys</li>
17
+ <li>Extended stack traces</li>
18
+ <li>Promise and callback interface</li>
19
+ <li>JSDoc annotations</li>
20
+ <li>Good error messages</li>
21
+ <li>Unit tests, good code coverage</li>
22
+ <li>No dependencies</li>
23
+ </ul>
24
+
25
+ <a href="#installation" id="installation" style="color: inherit; text-decoration: none;">
26
+ <h3>Installation</h3>
27
+ </a>
28
+ <pre><code class="language-bash"><span class="hl-0">npm install --save better-lock</span><br/><span class="hl-1"># or</span><br/><span class="hl-0">yarn add better-lock</span>
29
+ </code></pre>
30
+
31
+ <a href="#usage-examples" id="usage-examples" style="color: inherit; text-decoration: none;">
32
+ <h3>Usage examples</h3>
33
+ </a>
34
+
35
+ <a href="#minimal-example" id="minimal-example" style="color: inherit; text-decoration: none;">
36
+ <h5>Minimal example</h5>
37
+ </a>
38
+ <pre><code class="language-javascript"><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-3">lock</span><span class="hl-0"> = </span><span class="hl-2">new</span><span class="hl-0"> </span><span class="hl-4">BetterLock</span><span class="hl-0">();</span><br/><br/><span class="hl-5">try</span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-3">res</span><span class="hl-0"> = </span><span class="hl-5">await</span><span class="hl-0"> </span><span class="hl-6">lock</span><span class="hl-0">.</span><span class="hl-4">acquire</span><span class="hl-0">(</span><span class="hl-2">async</span><span class="hl-0"> () </span><span class="hl-2">=&gt;</span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-1">// Inside the lock. It will stay closed until the promise you return resolves or rejects.</span><br/><span class="hl-0"> </span><span class="hl-5">await</span><span class="hl-0"> </span><span class="hl-4">doSomeAsyncTask</span><span class="hl-0">();</span><br/><span class="hl-0"> </span><span class="hl-5">return</span><span class="hl-0"> </span><span class="hl-7">&#39;my result&#39;</span><span class="hl-0">;</span><br/><span class="hl-0"> });</span><br/><br/><span class="hl-0"> </span><span class="hl-1">// Outside the lock. You will get whatever the promise chain has returned.</span><br/><span class="hl-0"> </span><span class="hl-6">console</span><span class="hl-0">.</span><span class="hl-4">log</span><span class="hl-0">(</span><span class="hl-6">res</span><span class="hl-0">); </span><span class="hl-1">// &quot;my result&quot;</span><br/><span class="hl-0">}</span><br/><span class="hl-5">catch</span><span class="hl-0"> (</span><span class="hl-6">err</span><span class="hl-0">) {</span><br/><span class="hl-0"> </span><span class="hl-1">// Either your or BetterLock&#39;s error</span><br/><span class="hl-0">}</span>
39
+ </code></pre>
40
+
41
+ <a href="#advanced-example" id="advanced-example" style="color: inherit; text-decoration: none;">
42
+ <h5>Advanced example</h5>
43
+ </a>
44
+ <pre><code class="language-typescript"><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-3">lock</span><span class="hl-0"> = </span><span class="hl-2">new</span><span class="hl-0"> </span><span class="hl-4">BetterLock</span><span class="hl-0">({</span><br/><span class="hl-0"> </span><span class="hl-6">name:</span><span class="hl-0"> </span><span class="hl-7">&#39;FileLock&#39;</span><span class="hl-0">, </span><span class="hl-1">// To be used in error reporting and logging</span><br/><span class="hl-0"> </span><span class="hl-6">log:</span><span class="hl-0"> </span><span class="hl-6">winstonLogger</span><span class="hl-0">.</span><span class="hl-6">debug</span><span class="hl-0">, </span><span class="hl-1">// Give it your logger with appropeiate level</span><br/><span class="hl-0"> </span><span class="hl-6">wait_timeout:</span><span class="hl-0"> </span><span class="hl-8">1000</span><span class="hl-0"> * </span><span class="hl-8">30</span><span class="hl-0">, </span><span class="hl-1">// Max 30 sec wait in queue</span><br/><span class="hl-0"> </span><span class="hl-6">execution_timeout:</span><span class="hl-0"> </span><span class="hl-8">1000</span><span class="hl-0"> * </span><span class="hl-8">60</span><span class="hl-0"> * </span><span class="hl-8">5</span><span class="hl-0">, </span><span class="hl-1">// Time out after 5 minutes</span><br/><span class="hl-0"> </span><span class="hl-6">queue_size:</span><span class="hl-0"> </span><span class="hl-8">1</span><span class="hl-0">, </span><span class="hl-1">// At most one pending job</span><br/><span class="hl-0">});</span><br/><br/><span class="hl-2">async</span><span class="hl-0"> </span><span class="hl-2">function</span><span class="hl-0"> </span><span class="hl-4">processFile</span><span class="hl-0">(</span><span class="hl-6">filename</span><span class="hl-0">) {</span><br/><span class="hl-0"> </span><span class="hl-5">try</span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-3">result</span><span class="hl-0"> = </span><span class="hl-5">await</span><span class="hl-0"> </span><span class="hl-6">lock</span><span class="hl-0">.</span><span class="hl-4">acquire</span><span class="hl-0">(</span><span class="hl-6">filename</span><span class="hl-0">, </span><span class="hl-2">async</span><span class="hl-0"> () </span><span class="hl-2">=&gt;</span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-3">appended</span><span class="hl-0"> = </span><span class="hl-5">await</span><span class="hl-0"> </span><span class="hl-4">appendToFile</span><span class="hl-0">(</span><span class="hl-6">filename</span><span class="hl-0">);</span><br/><span class="hl-0"> </span><span class="hl-5">return</span><span class="hl-0"> </span><span class="hl-4">updateDb</span><span class="hl-0">(</span><span class="hl-6">appended</span><span class="hl-0">);</span><br/><span class="hl-0"> });</span><br/><span class="hl-0"> </span><span class="hl-5">return</span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-6">status:</span><span class="hl-0"> </span><span class="hl-2">true</span><span class="hl-0">,</span><br/><span class="hl-0"> </span><span class="hl-6">result</span><br/><span class="hl-0"> };</span><br/><span class="hl-0"> }</span><br/><span class="hl-0"> </span><span class="hl-5">catch</span><span class="hl-0"> (</span><span class="hl-6">err</span><span class="hl-0">) {</span><br/><span class="hl-0"> </span><span class="hl-5">if</span><span class="hl-0"> (</span><span class="hl-6">err</span><span class="hl-0"> </span><span class="hl-2">instanceof</span><span class="hl-0"> </span><span class="hl-9">BetterLock</span><span class="hl-0">.</span><span class="hl-9">QueueOverflowError</span><span class="hl-0">) {</span><br/><span class="hl-0"> </span><span class="hl-1">// The job was discarded</span><br/><span class="hl-0"> </span><span class="hl-5">return</span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-6">status:</span><span class="hl-0"> </span><span class="hl-2">false</span><br/><span class="hl-0"> };</span><br/><span class="hl-0"> }</span><br/><br/><span class="hl-0"> </span><span class="hl-5">if</span><span class="hl-0"> (</span><span class="hl-6">err</span><span class="hl-0"> </span><span class="hl-2">instanceof</span><span class="hl-0"> </span><span class="hl-9">BetterLock</span><span class="hl-0">.</span><span class="hl-9">ExecutionTimeoutError</span><span class="hl-0">) {</span><br/><span class="hl-0"> </span><span class="hl-6">winstonLogger</span><span class="hl-0">.</span><span class="hl-4">warn</span><span class="hl-0">(</span><span class="hl-7">&#39;Potential swallowed callback! Stack trace to the entry site:&#39;</span><span class="hl-0">, </span><span class="hl-6">err</span><span class="hl-0">.</span><span class="hl-6">stack</span><span class="hl-0">);</span><br/><span class="hl-0"> }</span><br/><span class="hl-0"> </span><span class="hl-5">throw</span><span class="hl-0"> </span><span class="hl-6">err</span><span class="hl-0">;</span><br/><span class="hl-0"> }</span><br/><span class="hl-0">}</span><br/>
45
+ </code></pre>
46
+
47
+ <a href="#locking-on-multiple-keys" id="locking-on-multiple-keys" style="color: inherit; text-decoration: none;">
48
+ <h5>Locking on multiple keys</h5>
49
+ </a>
50
+ <pre><code class="language-javascript"><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-3">userLock</span><span class="hl-0"> = </span><span class="hl-2">new</span><span class="hl-0"> </span><span class="hl-4">BetterLock</span><span class="hl-0">({</span><br/><span class="hl-0"> </span><span class="hl-6">name:</span><span class="hl-0"> </span><span class="hl-7">&#39;User lock&#39;</span><span class="hl-0">,</span><br/><span class="hl-0"> </span><span class="hl-6">executionTimeout:</span><span class="hl-0"> </span><span class="hl-8">1000</span><span class="hl-0"> * </span><span class="hl-8">60</span><span class="hl-0"> * </span><span class="hl-8">60</span><span class="hl-0">, </span><span class="hl-1">// Note you can also use camelCase</span><br/><span class="hl-0">});</span><br/><br/><span class="hl-2">function</span><span class="hl-0"> </span><span class="hl-4">transferBetweenUsers</span><span class="hl-0">(</span><span class="hl-6">fromId</span><span class="hl-0">, </span><span class="hl-6">toId</span><span class="hl-0">, </span><span class="hl-6">amount</span><span class="hl-0">) {</span><br/><span class="hl-0"> </span><span class="hl-6">userLock</span><span class="hl-0">.</span><span class="hl-4">acquire</span><span class="hl-0">([</span><span class="hl-6">fromId</span><span class="hl-0">, </span><span class="hl-6">toId</span><span class="hl-0">], () </span><span class="hl-2">=&gt;</span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-5">return</span><span class="hl-0"> </span><span class="hl-9">Promise</span><span class="hl-0">.</span><span class="hl-4">all</span><span class="hl-0">([</span><br/><span class="hl-0"> </span><span class="hl-6">User</span><span class="hl-0">.</span><span class="hl-4">get</span><span class="hl-0">(</span><span class="hl-6">fromId</span><span class="hl-0">),</span><br/><span class="hl-0"> </span><span class="hl-6">User</span><span class="hl-0">.</span><span class="hl-4">get</span><span class="hl-0">(</span><span class="hl-6">toId</span><span class="hl-0">),</span><br/><span class="hl-0"> ]).</span><span class="hl-4">then</span><span class="hl-0">(([</span><span class="hl-6">fromUser</span><span class="hl-0">, </span><span class="hl-6">toUser</span><span class="hl-0">]) </span><span class="hl-2">=&gt;</span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-6">fromUser</span><span class="hl-0">.</span><span class="hl-6">amount</span><span class="hl-0"> -= </span><span class="hl-6">amount</span><span class="hl-0">;</span><br/><span class="hl-0"> </span><span class="hl-6">toUser</span><span class="hl-0">.</span><span class="hl-6">amount</span><span class="hl-0"> += </span><span class="hl-6">amount</span><span class="hl-0">;</span><br/><span class="hl-0"> </span><span class="hl-5">return</span><span class="hl-0"> </span><span class="hl-9">Promise</span><span class="hl-0">.</span><span class="hl-4">all</span><span class="hl-0">([</span><br/><span class="hl-0"> </span><span class="hl-6">user1</span><span class="hl-0">.</span><span class="hl-4">save</span><span class="hl-0">(),</span><br/><span class="hl-0"> </span><span class="hl-6">user2</span><span class="hl-0">.</span><span class="hl-4">save</span><span class="hl-0">(),</span><br/><span class="hl-0"> ]);</span><br/><span class="hl-0"> });</span><br/><span class="hl-0"> }).</span><span class="hl-4">then</span><span class="hl-0">(() </span><span class="hl-2">=&gt;</span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-6">console</span><span class="hl-0">.</span><span class="hl-4">log</span><span class="hl-0">(</span><span class="hl-7">&#39;Transfer completed&#39;</span><span class="hl-0">);</span><br/><span class="hl-0"> });</span><br/><span class="hl-0">}</span>
51
+ </code></pre>
52
+
53
+ <a href="#using-callback-interface" id="using-callback-interface" style="color: inherit; text-decoration: none;">
54
+ <h5>Using callback interface</h5>
55
+ </a>
56
+ <pre><code class="language-javascript"><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-3">BetterLock</span><span class="hl-0"> = </span><span class="hl-4">require</span><span class="hl-0">(</span><span class="hl-7">&#39;better-lock&#39;</span><span class="hl-0">);</span><br/><br/><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-3">lock</span><span class="hl-0"> = </span><span class="hl-2">new</span><span class="hl-0"> </span><span class="hl-4">BetterLock</span><span class="hl-0">();</span><br/><span class="hl-1">//...</span><br/><span class="hl-6">lock</span><span class="hl-0">.</span><span class="hl-4">acquire</span><span class="hl-0">(</span><span class="hl-6">done</span><span class="hl-0"> </span><span class="hl-2">=&gt;</span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-1">// Inside the lock</span><br/><span class="hl-0"> </span><span class="hl-4">doMyAsyncStuffHere</span><span class="hl-0">((</span><span class="hl-6">err</span><span class="hl-0">) </span><span class="hl-2">=&gt;</span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-1">// Call done when done</span><br/><span class="hl-0"> </span><span class="hl-4">done</span><span class="hl-0">(</span><span class="hl-6">err</span><span class="hl-0">);</span><br/><span class="hl-0"> });</span><br/><span class="hl-0">}, (</span><span class="hl-6">err</span><span class="hl-0">, </span><span class="hl-6">result</span><span class="hl-0">) </span><span class="hl-2">=&gt;</span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-1">// Outside the lock</span><br/><span class="hl-0"> </span><span class="hl-5">if</span><span class="hl-0"> (</span><span class="hl-6">err</span><span class="hl-0">) {</span><br/><span class="hl-0"> </span><span class="hl-1">// Either your or BetterLock&#39;s error</span><br/><span class="hl-0"> </span><span class="hl-6">console</span><span class="hl-0">.</span><span class="hl-4">error</span><span class="hl-0">(</span><span class="hl-6">err</span><span class="hl-0">);</span><br/><span class="hl-0"> }</span><br/><span class="hl-0">});</span>
57
+ </code></pre>
58
+ <p>You can see a bunch more usage examples in the spec file, <a href="spec/better_lock.spec.js">here</a>;</p>
59
+
60
+ <a href="#api" id="api" style="color: inherit; text-decoration: none;">
61
+ <h3>API</h3>
62
+ </a>
63
+ <ul>
64
+ <li><p><code>new BetterLock(options)</code><br>Create a new instance of <code>BetterLock</code>. Options should match interface <code>BetterLockOptions</code>. See below for details.</p>
65
+ </li>
66
+ <li><p><code>BetterLock.acquire([key], executor, [callback], [jobOptions])</code><br>The main method you&#39;ll want to call. For each <code>key</code>, given <code>executor</code> will be called only one at a time. If you don&#39;t provide <code>callback</code>, it will return a promise that will be resolved with whatever <code>executor</code> returns.</p>
67
+ <ul>
68
+ <li><code>key</code>: Arbitrary string under which to lock. It allows you to use the same lock instance for multiple parallel concerns. Eg. this might be a database record id or filename.</li>
69
+ <li><code>executor</code>: Function that will be called within the lock. This function should have one of two forms.<ol>
70
+ <li><em>Without arguments</em>, in which case it should return a promise. Lock will remain locked until the promise resolves.</li>
71
+ <li><em>With single <code>done</code></em> argument. In this case, the executor should call <code>done(err, res)</code> once it is done. Arguments passed to done will be passed to the callback of the lock.</li>
72
+ </ol>
73
+ </li>
74
+ <li><code>callback</code>: Optional callback that will be called once executor exits. Results from executor (resolved/rejected value or arguments given to <code>done</code>) will be passed along. This can be used in addition to the returned promise.</li>
75
+ <li><code>jobOptions</code>: An object that should match interface <code>BetterLockJobOptions</code>. A subset of main options that will serve as overrides for this particular job (for example, timeout settings).</li>
76
+ </ul>
77
+ </li>
78
+ <li><p><code>BetterLock.canAcquire([key])</code><br>Returns true if given key can be acquired.</p>
79
+ </li>
80
+ <li><p><code>BetterLock.abort([key])</code><br>Abort all jobs for a given key (or from the default job queue, if no key is given). Job executors will not be called. Callbacks will be called with <code>JobAbortedError</code>. Currently executing job will not be interrupted.</p>
81
+ </li>
82
+ <li><p><code>BetterLock.abortAll()</code><br>Abort all jobs for all keys. This is suitable to be called during shutdown of your app.</p>
83
+ </li>
84
+ </ul>
85
+
86
+ <a href="#options" id="options" style="color: inherit; text-decoration: none;">
87
+ <h3>Options</h3>
88
+ </a>
89
+ <p>All available options can be seen <a href="src/options.ts">here</a>.</p>
90
+ <p><code>BetterLockOptions</code> are provided when you construct a lock instance. A subset of options given in <code>LockJobOptions</code> can be provided when you call <code>lock.acquire</code>, as the last argument.</p>
91
+ <p>Example:</p>
92
+ <pre><code class="language-javascript"><span class="hl-6">lock</span><span class="hl-0">.</span><span class="hl-4">acquire</span><span class="hl-0">(</span><span class="hl-6">executor</span><span class="hl-0">, </span><span class="hl-6">callback</span><span class="hl-0">, {</span><br/><span class="hl-0"> </span><span class="hl-6">wait_timeout:</span><span class="hl-0"> </span><span class="hl-8">1000</span><br/><span class="hl-0">});</span>
93
+ </code></pre>
94
+ <p>Most commonly used options are:</p>
95
+ <ul>
96
+ <li><p><code>wait_timeout</code><br>How long can jobs wait in queue before timing out (ms). Null to disable timeout.</p>
97
+ </li>
98
+ <li><p><code>execution_timeout</code><br>How long can a job be executing before timing out (ms). Null to disable timeout.
99
+ If you do that, though, and you have a swallowed callback, the lock can remain locked permanently.</p>
100
+ </li>
101
+ <li><p><code>queue_size</code><br>Max queue size for waiting jobs.</p>
102
+ </li>
103
+ </ul>
104
+ <p>Default options are a static member <code>DEFAULT_OPTIONS</code> on the <code>BetterLock</code> class. That can be seen <a href="src/better_lock.ts">here</a>. During runtime, you can change the defaults like this:</p>
105
+ <pre><code class="language-javascript"><span class="hl-5">import</span><span class="hl-0"> </span><span class="hl-6">BetterLock</span><span class="hl-0"> </span><span class="hl-5">from</span><span class="hl-0"> </span><span class="hl-7">&#39;better-lock&#39;</span><span class="hl-0">;</span><br/><br/><span class="hl-6">BetterLock</span><span class="hl-0">.</span><span class="hl-3">DEFAULT_OPTIONS</span><span class="hl-0">.</span><span class="hl-6">wait_timeout</span><span class="hl-0"> = </span><span class="hl-8">1000</span><span class="hl-0">;</span>
106
+ </code></pre>
107
+
108
+ <a href="#when-to-use" id="when-to-use" style="color: inherit; text-decoration: none;">
109
+ <h3>When to use</h3>
110
+ </a>
111
+ <p>This library is a good fit if:</p>
112
+ <ul>
113
+ <li>You need a local lock in your node.js application.</li>
114
+ <li>You have some advanced needs, like multiple keys per lock, timeouts, aborting...</li>
115
+ <li>You like good error messages, with full stack traces.</li>
116
+ <li>You like good types, either through typescript or JSDoc comments</li>
117
+ </ul>
118
+ <p>The library is not a good fit if:</p>
119
+ <ul>
120
+ <li><p><strong>You need lock reentrancy.</strong><br>There is no good solution for this in node.js that I know of. And this library doesn&#39;t offer any.</p>
121
+ </li>
122
+ <li><p><strong>You need a shared lock between different nodes</strong><br>This library is a single process only. If you need to coordinate multiple apps or services, you need a different library.</p>
123
+ </li>
124
+ </ul>
125
+
126
+ <a href="#change-log" id="change-log" style="color: inherit; text-decoration: none;">
127
+ <h3>Change log</h3>
128
+ </a>
129
+
130
+ <a href="#200-20210530" id="200-20210530" style="color: inherit; text-decoration: none;">
131
+ <h4><strong>2.0.0</strong> (<em>2021/05/30</em>)</h4>
132
+ </a>
133
+ <p>Major update. The entire library was rewritten in typescript, so you should now get typings in most editors. We also had to switch tests from mocha + chai to jest (easier ts integration).</p>
134
+ <p>The API and features have remained largely the same, just a bit of a refresh.</p>
135
+ <p>Non-breaking and internal changes:</p>
136
+ <ul>
137
+ <li>We now export all error names as a type script type. A few other types as well.</li>
138
+ <li>Errors now have <code>name</code> parameter, which matches these names.</li>
139
+ </ul>
140
+ <p>Breaking changes:</p>
141
+ <ul>
142
+ <li><p>You can no longer use camel case versions of external-facing objects. Eg. you can no longer pass <code>waitTimeout</code> instead of <code>wait_timeout</code>. In retrospect, this was a pretty flaky API to maintain.</p>
143
+ </li>
144
+ <li><p>Internal <code>LockJob</code> class is no longer exported.</p>
145
+ </li>
146
+ <li><p>Also, errors no longer expose internal <code>LockJob</code> instances (<code>err.job</code>). We now instead provide the most important fields from the job (<code>id</code> and <code>keys</code>).</p>
147
+ </li>
148
+ <li><p>Error names have been renamed to have <code>BetterLock</code> prefix. Eg. <code>WaitTimeoutError</code> -&gt; <code>BetterLockWaitTimeoutError</code>. This will influence <code>err.name</code> and <code>err.message</code> parameters. The idea here is, if you see <code>BetterLock</code> error in the wild, you will know what generated it.</p>
149
+ </li>
150
+ <li><p>We have renamed <code>BetterLock.BetterLockError</code> to <code>BetterLock.BaseError</code> and <code>BetterLock.BetterLockInternalError</code> to <code>BetterLock.InternalError</code> to better match the naming scheme.</p>
151
+ </li>
152
+ <li><p>Since Options are no longer a class but interface, we are no longer exporting them under <code>BetterLock.Options</code>. You can do <code>import {BetterLockOptions} from &#39;better-lock&#39;;</code> to get the typescript type.</p>
153
+ </li>
154
+ </ul>
155
+
156
+ <a href="#101-20190128" id="101-20190128" style="color: inherit; text-decoration: none;">
157
+ <h4><strong>1.0.1</strong> (<em>2019/01/28</em>)</h4>
158
+ </a>
159
+ <p>Handle empty key list</p>
160
+
161
+ <a href="#100-20190128" id="100-20190128" style="color: inherit; text-decoration: none;">
162
+ <h4><strong>1.0.0</strong> (<em>2019/01/28</em>)</h4>
163
+ </a>
164
+ <p>Major version bump.</p>
165
+ <ul>
166
+ <li>Added multi-key locks and refactored a bunch of internals.</li>
167
+ <li>Removed <code>OVERFLOW_STRATEGIES</code> and related options, which is mostly the reason for the major version bump. The library should otherwise work the same.</li>
168
+ </ul>
169
+
170
+ <a href="#031-20181001" id="031-20181001" style="color: inherit; text-decoration: none;">
171
+ <h4><strong>0.3.1</strong> (<em>2018/10/01</em>)</h4>
172
+ </a>
173
+ <p>Updated CI to use the current node versions (0.8 &amp; 0.10). Older node versions should continue to work, but are no longer tested. Also, README updates.</p>
174
+
175
+ <a href="#030-20181001" id="030-20181001" style="color: inherit; text-decoration: none;">
176
+ <h4><strong>0.3.0</strong> (<em>2018/10/01</em>)</h4>
177
+ </a>
178
+ <p>Can abort jobs waiting in queue.</p>
179
+
180
+ <a href="#021-20180927" id="021-20180927" style="color: inherit; text-decoration: none;">
181
+ <h4><strong>0.2.1</strong> (<em>2018/09/27</em>)</h4>
182
+ </a>
183
+ <ul>
184
+ <li>Better and customizable Promise detection.</li>
185
+ <li>Restored DEFAULT_OPTIONS.</li>
186
+ </ul>
187
+
188
+ <a href="#020-20180927" id="020-20180927" style="color: inherit; text-decoration: none;">
189
+ <h4><strong>0.2.0</strong> (<em>2018/09/27</em>)</h4>
190
+ </a>
191
+ <p>Code reformat, better pattern for loading options. No feature upgrades.</p>
192
+
193
+ <a href="#011-20180604" id="011-20180604" style="color: inherit; text-decoration: none;">
194
+ <h4><strong>0.1.1</strong> (<em>2018/06/04</em>)</h4>
195
+ </a>
196
+ <p>You can now use a Number as job name</p>
197
+
198
+ <a href="#development" id="development" style="color: inherit; text-decoration: none;">
199
+ <h3>Development</h3>
200
+ </a>
201
+ <p>Fork, then git clone. The project is already set up with a WebStorm project, if that&#39;s your cup of tee.</p>
202
+ <p>To run tests, with coverage:</p>
203
+ <pre><code><span class="hl-6">npm</span><span class="hl-0"> </span><span class="hl-6">run</span><span class="hl-0"> </span><span class="hl-6">test</span>
204
+ </code></pre>
205
+ <p>If you want to contribute, create a branch off master, do your work and then make a pull request against master. Unit tests would be appreciated.</p>
206
+
207
+ <a href="#license" id="license" style="color: inherit; text-decoration: none;">
208
+ <h2>License</h2>
209
+ </a>
210
+ <p><a href="./LICENSE">MIT</a></p>
211
+ </div></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class="current"><a href="modules.html">Exports</a></li><li class=" tsd-kind-namespace"><a href="modules/_internal_.html">&lt;internal&gt;</a></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul><li class="tsd-kind-reference"><a href="modules.html#default" class="tsd-kind-icon">default</a></li><li class="tsd-kind-class"><a href="classes/BetterLockError.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Error</a></li><li class="tsd-kind-class"><a href="classes/BetterLockExecutionTimeoutError.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Execution<wbr/>Timeout<wbr/>Error</a></li><li class="tsd-kind-class"><a href="classes/BetterLockInternalError.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Internal<wbr/>Error</a></li><li class="tsd-kind-class"><a href="classes/BetterLockInvalidArgumentError.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Invalid<wbr/>Argument<wbr/>Error</a></li><li class="tsd-kind-class"><a href="classes/BetterLockJobAbortedError.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Job<wbr/>Aborted<wbr/>Error</a></li><li class="tsd-kind-class"><a href="classes/BetterLockQueueOverflowError.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Queue<wbr/>Overflow<wbr/>Error</a></li><li class="tsd-kind-class"><a href="classes/BetterLockWaitTimeoutError.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Wait<wbr/>Timeout<wbr/>Error</a></li><li class="tsd-kind-interface"><a href="interfaces/BetterLockJobOptions.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Job<wbr/>Options</a></li><li class="tsd-kind-interface"><a href="interfaces/BetterLockOptions.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Options</a></li><li class="tsd-kind-type-alias"><a href="modules.html#BetterLockErrorName" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Error<wbr/>Name</a></li><li class="tsd-kind-type-alias tsd-has-type-parameter"><a href="modules.html#BetterLockExecutor" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Executor</a></li><li class="tsd-kind-type-alias"><a href="modules.html#BetterLockKey" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Key</a></li><li class="tsd-kind-variable"><a href="modules.html#BetterLock" class="tsd-kind-icon">Better<wbr/>Lock</a></li></ul></nav></div></div></div><footer class="with-border-bottom"><div class="container"><h2>Legend</h2><div class="tsd-legend-group"><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li><li class="tsd-kind-method tsd-parent-kind-interface"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li><li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited property</span></li></ul></div><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="container tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div><script src="assets/main.js"></script></body></html>
@@ -0,0 +1,9 @@
1
+ <!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>BetterLockJobOptions | better-lock</title><meta name="description" content="Documentation for better-lock"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script async src="../assets/search.js" id="search-script"></script></head><body><script>document.body.classList.add(localStorage.getItem("tsd-theme") || "os")</script><header><div class="tsd-page-toolbar"><div class="container"><div class="table-wrap"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption">Search</label><input type="text" id="tsd-search-field"/></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">better-lock</a></div><div class="table-cell" id="tsd-widgets"><div id="tsd-filter"><a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a><div class="tsd-filter-group"><div class="tsd-select" id="tsd-filter-visibility"><span class="tsd-select-label">All</span><ul class="tsd-select-list"><li data-value="public">Public</li><li data-value="protected">Public/Protected</li><li data-value="private" class="selected">All</li></ul></div> <input type="checkbox" id="tsd-filter-inherited" checked/><label class="tsd-widget" for="tsd-filter-inherited">Inherited</label></div></div><a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a></div></div></div></div><div class="tsd-page-title"><div class="container"><ul class="tsd-breadcrumb"><li><a href="../modules.html">better-lock</a></li><li><a href="BetterLockJobOptions.html">BetterLockJobOptions</a></li></ul><h1>Interface BetterLockJobOptions </h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><div class="lead">
2
+ <p>Options that apply on LockJob</p>
3
+ </div></div></section><section class="tsd-panel tsd-hierarchy"><h3>Hierarchy</h3><ul class="tsd-hierarchy"><li><span class="target">BetterLockJobOptions</span><ul class="tsd-hierarchy"><li><a href="BetterLockOptions.html" class="tsd-signature-type" data-tsd-kind="Interface">BetterLockOptions</a></li></ul></li></ul></section><section class="tsd-panel-group tsd-index-group"><h2>Index</h2><section class="tsd-panel tsd-index-panel"><div class="tsd-index-content"><section class="tsd-index-section "><h3>Properties</h3><ul class="tsd-index-list"><li class="tsd-kind-property tsd-parent-kind-interface"><a href="BetterLockJobOptions.html#execution_timeout" class="tsd-kind-icon">execution_<wbr/>timeout</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="BetterLockJobOptions.html#extend_stack_traces" class="tsd-kind-icon">extend_<wbr/>stack_<wbr/>traces</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="BetterLockJobOptions.html#wait_timeout" class="tsd-kind-icon">wait_<wbr/>timeout</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Properties</h2><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="execution_timeout" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagOptional">Optional</span> execution_<wbr/>timeout<a href="#execution_timeout" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">execution_<wbr/>timeout<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/panta82/better-lock/blob/769de55/src/options.ts#L13">options.ts:13</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
4
+ <p>How long can a job be executing before timing out. Null to disable timeout. Overrides BetterLockOptions value.</p>
5
+ </div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="extend_stack_traces" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagOptional">Optional</span> extend_<wbr/>stack_<wbr/>traces<a href="#extend_stack_traces" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">extend_<wbr/>stack_<wbr/>traces<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/panta82/better-lock/blob/769de55/src/options.ts#L18">options.ts:18</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
6
+ <p>In any error produced by BetterLock, extend the stack trace to include incoming trace. Overrides BetterLockOptions value.</p>
7
+ </div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="wait_timeout" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagOptional">Optional</span> wait_<wbr/>timeout<a href="#wait_timeout" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">wait_<wbr/>timeout<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/panta82/better-lock/blob/769de55/src/options.ts#L8">options.ts:8</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
8
+ <p>How long can jobs wait in queue before timing out. Overrides BetterLockOptions value.</p>
9
+ </div></div></section></section></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class=""><a href="../modules.html">Exports</a></li><li class=" tsd-kind-namespace"><a href="../modules/_internal_.html">&lt;internal&gt;</a></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul><li class="current tsd-kind-interface"><a href="BetterLockJobOptions.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Job<wbr/>Options</a><ul><li class="tsd-kind-property tsd-parent-kind-interface"><a href="BetterLockJobOptions.html#execution_timeout" class="tsd-kind-icon">execution_<wbr/>timeout</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="BetterLockJobOptions.html#extend_stack_traces" class="tsd-kind-icon">extend_<wbr/>stack_<wbr/>traces</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="BetterLockJobOptions.html#wait_timeout" class="tsd-kind-icon">wait_<wbr/>timeout</a></li></ul></li></ul></nav></div></div></div><footer class="with-border-bottom"><div class="container"><h2>Legend</h2><div class="tsd-legend-group"><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li><li class="tsd-kind-method tsd-parent-kind-interface"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li><li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited property</span></li></ul></div><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="container tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div><script src="../assets/main.js"></script></body></html>
@@ -0,0 +1,21 @@
1
+ <!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>BetterLockOptions | better-lock</title><meta name="description" content="Documentation for better-lock"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script async src="../assets/search.js" id="search-script"></script></head><body><script>document.body.classList.add(localStorage.getItem("tsd-theme") || "os")</script><header><div class="tsd-page-toolbar"><div class="container"><div class="table-wrap"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption">Search</label><input type="text" id="tsd-search-field"/></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">better-lock</a></div><div class="table-cell" id="tsd-widgets"><div id="tsd-filter"><a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a><div class="tsd-filter-group"><div class="tsd-select" id="tsd-filter-visibility"><span class="tsd-select-label">All</span><ul class="tsd-select-list"><li data-value="public">Public</li><li data-value="protected">Public/Protected</li><li data-value="private" class="selected">All</li></ul></div> <input type="checkbox" id="tsd-filter-inherited" checked/><label class="tsd-widget" for="tsd-filter-inherited">Inherited</label></div></div><a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a></div></div></div></div><div class="tsd-page-title"><div class="container"><ul class="tsd-breadcrumb"><li><a href="../modules.html">better-lock</a></li><li><a href="BetterLockOptions.html">BetterLockOptions</a></li></ul><h1>Interface BetterLockOptions </h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><div class="lead">
2
+ <p>Options that apply on BetterLock instance</p>
3
+ </div></div></section><section class="tsd-panel tsd-hierarchy"><h3>Hierarchy</h3><ul class="tsd-hierarchy"><li><a href="BetterLockJobOptions.html" class="tsd-signature-type" data-tsd-kind="Interface">BetterLockJobOptions</a><ul class="tsd-hierarchy"><li><span class="target">BetterLockOptions</span></li></ul></li></ul></section><section class="tsd-panel-group tsd-index-group"><h2>Index</h2><section class="tsd-panel tsd-index-panel"><div class="tsd-index-content"><section class="tsd-index-section "><h3>Properties</h3><ul class="tsd-index-list"><li class="tsd-kind-property tsd-parent-kind-interface tsd-is-overwrite"><a href="BetterLockOptions.html#execution_timeout" class="tsd-kind-icon">execution_<wbr/>timeout</a></li><li class="tsd-kind-property tsd-parent-kind-interface tsd-is-overwrite"><a href="BetterLockOptions.html#extend_stack_traces" class="tsd-kind-icon">extend_<wbr/>stack_<wbr/>traces</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="BetterLockOptions.html#log" class="tsd-kind-icon">log</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="BetterLockOptions.html#name" class="tsd-kind-icon">name</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="BetterLockOptions.html#queue_size" class="tsd-kind-icon">queue_<wbr/>size</a></li><li class="tsd-kind-property tsd-parent-kind-interface tsd-is-overwrite"><a href="BetterLockOptions.html#wait_timeout" class="tsd-kind-icon">wait_<wbr/>timeout</a></li></ul></section><section class="tsd-index-section "><h3>Methods</h3><ul class="tsd-index-list"><li class="tsd-kind-method tsd-parent-kind-interface"><a href="BetterLockOptions.html#promise_tester" class="tsd-kind-icon">promise_<wbr/>tester</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Properties</h2><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface tsd-is-overwrite"><a id="execution_timeout" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagOptional">Optional</span> execution_<wbr/>timeout<a href="#execution_timeout" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">execution_<wbr/>timeout<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span></div><aside class="tsd-sources"><p>Overrides <a href="BetterLockJobOptions.html">BetterLockJobOptions</a>.<a href="BetterLockJobOptions.html#execution_timeout">execution_timeout</a></p><ul><li>Defined in <a href="https://github.com/panta82/better-lock/blob/769de55/src/options.ts#L34">options.ts:34</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
4
+ <p>How long can a job be executing before timing out. Null to disable timeout.
5
+ If you do that, though, and you have a swallowed callback, the lock can remain locked permanently.</p>
6
+ </div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface tsd-is-overwrite"><a id="extend_stack_traces" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagOptional">Optional</span> extend_<wbr/>stack_<wbr/>traces<a href="#extend_stack_traces" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">extend_<wbr/>stack_<wbr/>traces<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span></div><aside class="tsd-sources"><p>Overrides <a href="BetterLockJobOptions.html">BetterLockJobOptions</a>.<a href="BetterLockJobOptions.html#extend_stack_traces">extend_stack_traces</a></p><ul><li>Defined in <a href="https://github.com/panta82/better-lock/blob/769de55/src/options.ts#L55">options.ts:55</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
7
+ <p>In any error produced by BetterLock, extend the stack trace to include incoming trace.
8
+ Defaults to true.</p>
9
+ </div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="log" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagOptional">Optional</span> log<a href="#log" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">log<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">(</span>msg<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">)</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/panta82/better-lock/blob/769de55/src/options.ts#L49">options.ts:49</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
10
+ <p>Whether to log the internal actions. Set to true to use console.log. Alternatively, provide your own function</p>
11
+ </div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="name" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagOptional">Optional</span> name<a href="#name" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">name<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">string</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/panta82/better-lock/blob/769de55/src/options.ts#L44">options.ts:44</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
12
+ <p>Lock name. This will be written in all logs and error messages, to help you distinguish between different locks</p>
13
+ </div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="queue_size" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagOptional">Optional</span> queue_<wbr/>size<a href="#queue_size" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">queue_<wbr/>size<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/panta82/better-lock/blob/769de55/src/options.ts#L39">options.ts:39</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
14
+ <p>Max queue size for waiting jobs.</p>
15
+ </div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface tsd-is-overwrite"><a id="wait_timeout" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagOptional">Optional</span> wait_<wbr/>timeout<a href="#wait_timeout" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">wait_<wbr/>timeout<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span></div><aside class="tsd-sources"><p>Overrides <a href="BetterLockJobOptions.html">BetterLockJobOptions</a>.<a href="BetterLockJobOptions.html#wait_timeout">wait_timeout</a></p><ul><li>Defined in <a href="https://github.com/panta82/better-lock/blob/769de55/src/options.ts#L28">options.ts:28</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
16
+ <p>How long can jobs wait in queue before timing out. Null to disable timeout.</p>
17
+ </div></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Methods</h2><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="promise_tester" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagOptional">Optional</span> promise_<wbr/>tester<a href="#promise_tester" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface"><li class="tsd-signature tsd-kind-icon">promise_<wbr/>tester<span class="tsd-signature-symbol">(</span>maybePromise<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/panta82/better-lock/blob/769de55/src/options.ts#L62">options.ts:62</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
18
+ <p>Function that detects whether value returned by executor is a promise.
19
+ This will ducktype-sniff the returned value. Depending on your Promise library of choice,
20
+ you might want to tighten or loosen this bit.</p>
21
+ </div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>maybePromise: <span class="tsd-signature-type">any</span></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4></li></ul></section></section></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class=""><a href="../modules.html">Exports</a></li><li class=" tsd-kind-namespace"><a href="../modules/_internal_.html">&lt;internal&gt;</a></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul><li class="current tsd-kind-interface"><a href="BetterLockOptions.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Options</a><ul><li class="tsd-kind-property tsd-parent-kind-interface tsd-is-overwrite"><a href="BetterLockOptions.html#execution_timeout" class="tsd-kind-icon">execution_<wbr/>timeout</a></li><li class="tsd-kind-property tsd-parent-kind-interface tsd-is-overwrite"><a href="BetterLockOptions.html#extend_stack_traces" class="tsd-kind-icon">extend_<wbr/>stack_<wbr/>traces</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="BetterLockOptions.html#log" class="tsd-kind-icon">log</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="BetterLockOptions.html#name" class="tsd-kind-icon">name</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="BetterLockOptions.html#queue_size" class="tsd-kind-icon">queue_<wbr/>size</a></li><li class="tsd-kind-property tsd-parent-kind-interface tsd-is-overwrite"><a href="BetterLockOptions.html#wait_timeout" class="tsd-kind-icon">wait_<wbr/>timeout</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="BetterLockOptions.html#promise_tester" class="tsd-kind-icon">promise_<wbr/>tester</a></li></ul></li></ul></nav></div></div></div><footer class="with-border-bottom"><div class="container"><h2>Legend</h2><div class="tsd-legend-group"><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li><li class="tsd-kind-method tsd-parent-kind-interface"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li><li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited property</span></li></ul></div><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="container tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div><script src="../assets/main.js"></script></body></html>
@@ -0,0 +1 @@
1
+ <!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>&quot;/home/panta/dev/pantas/better-lock/src/errors&quot; | better-lock</title><meta name="description" content="Documentation for better-lock"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script async src="../assets/search.js" id="search-script"></script></head><body><script>document.body.classList.add(localStorage.getItem("tsd-theme") || "os")</script><header><div class="tsd-page-toolbar"><div class="container"><div class="table-wrap"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption">Search</label><input type="text" id="tsd-search-field"/></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">better-lock</a></div><div class="table-cell" id="tsd-widgets"><div id="tsd-filter"><a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a><div class="tsd-filter-group"><div class="tsd-select" id="tsd-filter-visibility"><span class="tsd-select-label">All</span><ul class="tsd-select-list"><li data-value="public">Public</li><li data-value="protected">Public/Protected</li><li data-value="private" class="selected">All</li></ul></div> <input type="checkbox" id="tsd-filter-inherited" checked/><label class="tsd-widget" for="tsd-filter-inherited">Inherited</label></div></div><a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a></div></div></div></div><div class="tsd-page-title"><div class="container"><ul class="tsd-breadcrumb"><li><a href="../modules.html">better-lock</a></li><li><a href="_internal_.html">&lt;internal&gt;</a></li><li><a href="_internal_.__home_panta_dev_pantas_better_lock_src_errors_.html">&quot;/home/panta/dev/pantas/better-lock/src/errors&quot;</a></li></ul><h1>Namespace &quot;/home/panta/dev/pantas/better-lock/src/errors&quot; </h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel-group tsd-index-group"><h2>Index</h2><section class="tsd-panel tsd-index-panel"><div class="tsd-index-content"><section class="tsd-index-section "><h3>References</h3><ul class="tsd-index-list"><li class="tsd-kind-reference tsd-parent-kind-namespace"><a href="_internal_.__home_panta_dev_pantas_better_lock_src_errors_.html#BetterLockError" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Error</a></li><li class="tsd-kind-reference tsd-parent-kind-namespace"><a href="_internal_.__home_panta_dev_pantas_better_lock_src_errors_.html#BetterLockExecutionTimeoutError" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Execution<wbr/>Timeout<wbr/>Error</a></li><li class="tsd-kind-reference tsd-parent-kind-namespace"><a href="_internal_.__home_panta_dev_pantas_better_lock_src_errors_.html#BetterLockInternalError" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Internal<wbr/>Error</a></li><li class="tsd-kind-reference tsd-parent-kind-namespace"><a href="_internal_.__home_panta_dev_pantas_better_lock_src_errors_.html#BetterLockInvalidArgumentError" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Invalid<wbr/>Argument<wbr/>Error</a></li><li class="tsd-kind-reference tsd-parent-kind-namespace"><a href="_internal_.__home_panta_dev_pantas_better_lock_src_errors_.html#BetterLockJobAbortedError" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Job<wbr/>Aborted<wbr/>Error</a></li><li class="tsd-kind-reference tsd-parent-kind-namespace"><a href="_internal_.__home_panta_dev_pantas_better_lock_src_errors_.html#BetterLockQueueOverflowError" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Queue<wbr/>Overflow<wbr/>Error</a></li><li class="tsd-kind-reference tsd-parent-kind-namespace"><a href="_internal_.__home_panta_dev_pantas_better_lock_src_errors_.html#BetterLockWaitTimeoutError" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Wait<wbr/>Timeout<wbr/>Error</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>References</h2><section class="tsd-panel tsd-member tsd-kind-reference tsd-parent-kind-namespace"><a id="BetterLockError" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Better<wbr/>Lock<wbr/>Error<a href="#BetterLockError" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3>Re-exports <a href="../classes/BetterLockError.html">BetterLockError</a></section><section class="tsd-panel tsd-member tsd-kind-reference tsd-parent-kind-namespace"><a id="BetterLockExecutionTimeoutError" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Better<wbr/>Lock<wbr/>Execution<wbr/>Timeout<wbr/>Error<a href="#BetterLockExecutionTimeoutError" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3>Re-exports <a href="../classes/BetterLockExecutionTimeoutError.html">BetterLockExecutionTimeoutError</a></section><section class="tsd-panel tsd-member tsd-kind-reference tsd-parent-kind-namespace"><a id="BetterLockInternalError" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Better<wbr/>Lock<wbr/>Internal<wbr/>Error<a href="#BetterLockInternalError" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3>Re-exports <a href="../classes/BetterLockInternalError.html">BetterLockInternalError</a></section><section class="tsd-panel tsd-member tsd-kind-reference tsd-parent-kind-namespace"><a id="BetterLockInvalidArgumentError" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Better<wbr/>Lock<wbr/>Invalid<wbr/>Argument<wbr/>Error<a href="#BetterLockInvalidArgumentError" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3>Re-exports <a href="../classes/BetterLockInvalidArgumentError.html">BetterLockInvalidArgumentError</a></section><section class="tsd-panel tsd-member tsd-kind-reference tsd-parent-kind-namespace"><a id="BetterLockJobAbortedError" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Better<wbr/>Lock<wbr/>Job<wbr/>Aborted<wbr/>Error<a href="#BetterLockJobAbortedError" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3>Re-exports <a href="../classes/BetterLockJobAbortedError.html">BetterLockJobAbortedError</a></section><section class="tsd-panel tsd-member tsd-kind-reference tsd-parent-kind-namespace"><a id="BetterLockQueueOverflowError" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Better<wbr/>Lock<wbr/>Queue<wbr/>Overflow<wbr/>Error<a href="#BetterLockQueueOverflowError" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3>Re-exports <a href="../classes/BetterLockQueueOverflowError.html">BetterLockQueueOverflowError</a></section><section class="tsd-panel tsd-member tsd-kind-reference tsd-parent-kind-namespace"><a id="BetterLockWaitTimeoutError" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Better<wbr/>Lock<wbr/>Wait<wbr/>Timeout<wbr/>Error<a href="#BetterLockWaitTimeoutError" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3>Re-exports <a href="../classes/BetterLockWaitTimeoutError.html">BetterLockWaitTimeoutError</a></section></section></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class=""><a href="../modules.html">Exports</a></li><li class="current tsd-kind-namespace"><a href="_internal_.html">&lt;internal&gt;</a><ul><li class="current tsd-kind-namespace tsd-parent-kind-namespace"><a href="_internal_.__home_panta_dev_pantas_better_lock_src_errors_.html">&quot;/home/panta/dev/pantas/better-<wbr/>lock/src/errors&quot;</a></li></ul></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul><li class="tsd-kind-reference tsd-parent-kind-namespace"><a href="_internal_.__home_panta_dev_pantas_better_lock_src_errors_.html#BetterLockError" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Error</a></li><li class="tsd-kind-reference tsd-parent-kind-namespace"><a href="_internal_.__home_panta_dev_pantas_better_lock_src_errors_.html#BetterLockExecutionTimeoutError" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Execution<wbr/>Timeout<wbr/>Error</a></li><li class="tsd-kind-reference tsd-parent-kind-namespace"><a href="_internal_.__home_panta_dev_pantas_better_lock_src_errors_.html#BetterLockInternalError" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Internal<wbr/>Error</a></li><li class="tsd-kind-reference tsd-parent-kind-namespace"><a href="_internal_.__home_panta_dev_pantas_better_lock_src_errors_.html#BetterLockInvalidArgumentError" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Invalid<wbr/>Argument<wbr/>Error</a></li><li class="tsd-kind-reference tsd-parent-kind-namespace"><a href="_internal_.__home_panta_dev_pantas_better_lock_src_errors_.html#BetterLockJobAbortedError" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Job<wbr/>Aborted<wbr/>Error</a></li><li class="tsd-kind-reference tsd-parent-kind-namespace"><a href="_internal_.__home_panta_dev_pantas_better_lock_src_errors_.html#BetterLockQueueOverflowError" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Queue<wbr/>Overflow<wbr/>Error</a></li><li class="tsd-kind-reference tsd-parent-kind-namespace"><a href="_internal_.__home_panta_dev_pantas_better_lock_src_errors_.html#BetterLockWaitTimeoutError" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Wait<wbr/>Timeout<wbr/>Error</a></li></ul></nav></div></div></div><footer class="with-border-bottom"><div class="container"><h2>Legend</h2><div class="tsd-legend-group"><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li><li class="tsd-kind-method tsd-parent-kind-interface"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li><li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited property</span></li></ul></div><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="container tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div><script src="../assets/main.js"></script></body></html>
@@ -0,0 +1,7 @@
1
+ <!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>&lt;internal&gt; | better-lock</title><meta name="description" content="Documentation for better-lock"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script async src="../assets/search.js" id="search-script"></script></head><body><script>document.body.classList.add(localStorage.getItem("tsd-theme") || "os")</script><header><div class="tsd-page-toolbar"><div class="container"><div class="table-wrap"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption">Search</label><input type="text" id="tsd-search-field"/></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">better-lock</a></div><div class="table-cell" id="tsd-widgets"><div id="tsd-filter"><a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a><div class="tsd-filter-group"><div class="tsd-select" id="tsd-filter-visibility"><span class="tsd-select-label">All</span><ul class="tsd-select-list"><li data-value="public">Public</li><li data-value="protected">Public/Protected</li><li data-value="private" class="selected">All</li></ul></div> <input type="checkbox" id="tsd-filter-inherited" checked/><label class="tsd-widget" for="tsd-filter-inherited">Inherited</label></div></div><a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a></div></div></div></div><div class="tsd-page-title"><div class="container"><ul class="tsd-breadcrumb"><li><a href="../modules.html">better-lock</a></li><li><a href="_internal_.html">&lt;internal&gt;</a></li></ul><h1>Namespace &lt;internal&gt; </h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel-group tsd-index-group"><h2>Index</h2><section class="tsd-panel tsd-index-panel"><div class="tsd-index-content"><section class="tsd-index-section "><h3>Namespaces</h3><ul class="tsd-index-list"><li class="tsd-kind-namespace tsd-parent-kind-namespace"><a href="_internal_.__home_panta_dev_pantas_better_lock_src_errors_.html" class="tsd-kind-icon">&quot;/home/panta/dev/pantas/better-<wbr/>lock/src/errors&quot;</a></li></ul></section><section class="tsd-index-section "><h3>Classes</h3><ul class="tsd-index-list"><li class="tsd-kind-class tsd-parent-kind-namespace"><a href="../classes/_internal_.BetterLock.html" class="tsd-kind-icon">Better<wbr/>Lock</a></li><li class="tsd-kind-class tsd-parent-kind-namespace"><a href="../classes/_internal_.KeyQueue.html" class="tsd-kind-icon">Key<wbr/>Queue</a></li><li class="tsd-kind-class tsd-parent-kind-namespace tsd-has-type-parameter"><a href="../classes/_internal_.LockJob.html" class="tsd-kind-icon">Lock<wbr/>Job</a></li></ul></section><section class="tsd-index-section "><h3>Type aliases</h3><ul class="tsd-index-list"><li class="tsd-kind-type-alias tsd-parent-kind-namespace tsd-has-type-parameter"><a href="_internal_.html#ICallback" class="tsd-kind-icon">ICallback</a></li><li class="tsd-kind-type-alias tsd-parent-kind-namespace tsd-has-type-parameter"><a href="_internal_.html#ICallbackExecutor" class="tsd-kind-icon">ICallback<wbr/>Executor</a></li><li class="tsd-kind-type-alias tsd-parent-kind-namespace"><a href="_internal_.html#IErrorExports" class="tsd-kind-icon">IError<wbr/>Exports</a></li><li class="tsd-kind-type-alias tsd-parent-kind-namespace tsd-has-type-parameter"><a href="_internal_.html#IPromiseExecutor" class="tsd-kind-icon">IPromise<wbr/>Executor</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Type aliases</h2><section class="tsd-panel tsd-member tsd-kind-type-alias tsd-parent-kind-namespace tsd-has-type-parameter"><a id="ICallback" class="tsd-anchor"></a><h3 class="tsd-anchor-link">ICallback<a href="#ICallback" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">ICallback<span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">TResult</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type" data-tsd-kind="Type parameter">TResult</span><span class="tsd-signature-symbol"> extends </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol"> ? </span><span class="tsd-signature-symbol">(</span>err<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Error</span>, <span class="tsd-signature-symbol">...</span>result<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">TResult</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol"> : </span><span class="tsd-signature-symbol">(</span>err<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Error</span>, result<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">TResult</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type">void</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/panta82/better-lock/blob/769de55/src/types.ts#L14">types.ts:14</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
2
+ <p>User-supplied callback. We support a &quot;canonical&quot; callback, with just error and result,
3
+ but also old-school callbacks, with varargs return values.</p>
4
+ </div></div><h4 class="tsd-type-parameters-title">Type parameters</h4><ul class="tsd-type-parameters"><li><h4>TResult</h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-type-alias tsd-parent-kind-namespace tsd-has-type-parameter"><a id="ICallbackExecutor" class="tsd-anchor"></a><h3 class="tsd-anchor-link">ICallback<wbr/>Executor<a href="#ICallbackExecutor" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">ICallback<wbr/>Executor<span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">TResult</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">(</span>lockDone<span class="tsd-signature-symbol">: </span><a href="_internal_.html#ICallback" class="tsd-signature-type" data-tsd-kind="Type alias">ICallback</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">TResult</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type">void</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/panta82/better-lock/blob/769de55/src/types.ts#L22">types.ts:22</a></li></ul></aside><h4 class="tsd-type-parameters-title">Type parameters</h4><ul class="tsd-type-parameters"><li><h4>TResult</h4></li></ul><div class="tsd-type-declaration"><h4>Type declaration</h4><ul class="tsd-parameters"><li class="tsd-parameter-signature"><ul class="tsd-signatures tsd-kind-type-literal tsd-parent-kind-type-alias"><li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">(</span>lockDone<span class="tsd-signature-symbol">: </span><a href="_internal_.html#ICallback" class="tsd-signature-type" data-tsd-kind="Type alias">ICallback</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">TResult</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><div class="tsd-comment tsd-typography"><div class="lead">
5
+ <p>Function that user will supply as the thing that will be running inside lock.
6
+ It can either accept a done() function, or return a promise.</p>
7
+ </div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>lockDone: <a href="_internal_.html#ICallback" class="tsd-signature-type" data-tsd-kind="Type alias">ICallback</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">TResult</span><span class="tsd-signature-symbol">&gt;</span></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></li></ul></div></section><section class="tsd-panel tsd-member tsd-kind-type-alias tsd-parent-kind-namespace"><a id="IErrorExports" class="tsd-anchor"></a><h3 class="tsd-anchor-link">IError<wbr/>Exports<a href="#IErrorExports" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">IError<wbr/>Exports<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">typeof </span><a href="_internal_.__home_panta_dev_pantas_better_lock_src_errors_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&quot;/home/panta/dev/pantas/better-lock/src/errors&quot;</a></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/panta82/better-lock/blob/769de55/src/types.ts#L3">types.ts:3</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-kind-type-alias tsd-parent-kind-namespace tsd-has-type-parameter"><a id="IPromiseExecutor" class="tsd-anchor"></a><h3 class="tsd-anchor-link">IPromise<wbr/>Executor<a href="#IPromiseExecutor" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">IPromise<wbr/>Executor<span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">TResult</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">TResult</span><span class="tsd-signature-symbol">&gt;</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/panta82/better-lock/blob/769de55/src/types.ts#L23">types.ts:23</a></li></ul></aside><h4 class="tsd-type-parameters-title">Type parameters</h4><ul class="tsd-type-parameters"><li><h4>TResult</h4></li></ul><div class="tsd-type-declaration"><h4>Type declaration</h4><ul class="tsd-parameters"><li class="tsd-parameter-signature"><ul class="tsd-signatures tsd-kind-type-literal tsd-parent-kind-type-alias"><li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">TResult</span><span class="tsd-signature-symbol">&gt;</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">TResult</span><span class="tsd-signature-symbol">&gt;</span></h4></li></ul></li></ul></div></section></section></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class=""><a href="../modules.html">Exports</a></li><li class="current tsd-kind-namespace"><a href="_internal_.html">&lt;internal&gt;</a><ul><li class=" tsd-kind-namespace tsd-parent-kind-namespace"><a href="_internal_.__home_panta_dev_pantas_better_lock_src_errors_.html">&quot;/home/panta/dev/pantas/better-<wbr/>lock/src/errors&quot;</a></li></ul></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul><li class="tsd-kind-class tsd-parent-kind-namespace"><a href="../classes/_internal_.BetterLock.html" class="tsd-kind-icon">Better<wbr/>Lock</a></li><li class="tsd-kind-class tsd-parent-kind-namespace"><a href="../classes/_internal_.KeyQueue.html" class="tsd-kind-icon">Key<wbr/>Queue</a></li><li class="tsd-kind-class tsd-parent-kind-namespace tsd-has-type-parameter"><a href="../classes/_internal_.LockJob.html" class="tsd-kind-icon">Lock<wbr/>Job</a></li><li class="tsd-kind-type-alias tsd-parent-kind-namespace tsd-has-type-parameter"><a href="_internal_.html#ICallback" class="tsd-kind-icon">ICallback</a></li><li class="tsd-kind-type-alias tsd-parent-kind-namespace tsd-has-type-parameter"><a href="_internal_.html#ICallbackExecutor" class="tsd-kind-icon">ICallback<wbr/>Executor</a></li><li class="tsd-kind-type-alias tsd-parent-kind-namespace"><a href="_internal_.html#IErrorExports" class="tsd-kind-icon">IError<wbr/>Exports</a></li><li class="tsd-kind-type-alias tsd-parent-kind-namespace tsd-has-type-parameter"><a href="_internal_.html#IPromiseExecutor" class="tsd-kind-icon">IPromise<wbr/>Executor</a></li></ul></nav></div></div></div><footer class="with-border-bottom"><div class="container"><h2>Legend</h2><div class="tsd-legend-group"><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li><li class="tsd-kind-method tsd-parent-kind-interface"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li><li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited property</span></li></ul></div><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="container tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div><script src="../assets/main.js"></script></body></html>
@@ -0,0 +1,5 @@
1
+ <!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>better-lock</title><meta name="description" content="Documentation for better-lock"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><script async src="assets/search.js" id="search-script"></script></head><body><script>document.body.classList.add(localStorage.getItem("tsd-theme") || "os")</script><header><div class="tsd-page-toolbar"><div class="container"><div class="table-wrap"><div class="table-cell" id="tsd-search" data-base="."><div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption">Search</label><input type="text" id="tsd-search-field"/></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="index.html" class="title">better-lock</a></div><div class="table-cell" id="tsd-widgets"><div id="tsd-filter"><a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a><div class="tsd-filter-group"><div class="tsd-select" id="tsd-filter-visibility"><span class="tsd-select-label">All</span><ul class="tsd-select-list"><li data-value="public">Public</li><li data-value="protected">Public/Protected</li><li data-value="private" class="selected">All</li></ul></div> <input type="checkbox" id="tsd-filter-inherited" checked/><label class="tsd-widget" for="tsd-filter-inherited">Inherited</label></div></div><a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a></div></div></div></div><div class="tsd-page-title"><div class="container"><h1>better-lock </h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel-group tsd-index-group"><h2>Index</h2><section class="tsd-panel tsd-index-panel"><div class="tsd-index-content"><section class="tsd-index-section "><h3>References</h3><ul class="tsd-index-list"><li class="tsd-kind-reference"><a href="modules.html#default" class="tsd-kind-icon">default</a></li></ul></section><section class="tsd-index-section "><h3>Namespaces</h3><ul class="tsd-index-list"><li class="tsd-kind-namespace"><a href="modules/_internal_.html" class="tsd-kind-icon">&lt;internal&gt;</a></li></ul></section><section class="tsd-index-section "><h3>Classes</h3><ul class="tsd-index-list"><li class="tsd-kind-class"><a href="classes/BetterLockError.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Error</a></li><li class="tsd-kind-class"><a href="classes/BetterLockExecutionTimeoutError.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Execution<wbr/>Timeout<wbr/>Error</a></li><li class="tsd-kind-class"><a href="classes/BetterLockInternalError.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Internal<wbr/>Error</a></li><li class="tsd-kind-class"><a href="classes/BetterLockInvalidArgumentError.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Invalid<wbr/>Argument<wbr/>Error</a></li><li class="tsd-kind-class"><a href="classes/BetterLockJobAbortedError.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Job<wbr/>Aborted<wbr/>Error</a></li><li class="tsd-kind-class"><a href="classes/BetterLockQueueOverflowError.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Queue<wbr/>Overflow<wbr/>Error</a></li><li class="tsd-kind-class"><a href="classes/BetterLockWaitTimeoutError.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Wait<wbr/>Timeout<wbr/>Error</a></li></ul></section><section class="tsd-index-section "><h3>Interfaces</h3><ul class="tsd-index-list"><li class="tsd-kind-interface"><a href="interfaces/BetterLockJobOptions.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Job<wbr/>Options</a></li><li class="tsd-kind-interface"><a href="interfaces/BetterLockOptions.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Options</a></li></ul></section><section class="tsd-index-section "><h3>Type aliases</h3><ul class="tsd-index-list"><li class="tsd-kind-type-alias"><a href="modules.html#BetterLockErrorName" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Error<wbr/>Name</a></li><li class="tsd-kind-type-alias tsd-has-type-parameter"><a href="modules.html#BetterLockExecutor" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Executor</a></li><li class="tsd-kind-type-alias"><a href="modules.html#BetterLockKey" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Key</a></li></ul></section><section class="tsd-index-section "><h3>Variables</h3><ul class="tsd-index-list"><li class="tsd-kind-variable"><a href="modules.html#BetterLock" class="tsd-kind-icon">Better<wbr/>Lock</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>References</h2><section class="tsd-panel tsd-member tsd-kind-reference"><a id="default" class="tsd-anchor"></a><h3 class="tsd-anchor-link">default<a href="#default" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3>Renames and re-exports <a href="modules.html#BetterLock">BetterLock</a></section></section><section class="tsd-panel-group tsd-member-group "><h2>Type aliases</h2><section class="tsd-panel tsd-member tsd-kind-type-alias"><a id="BetterLockErrorName" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Better<wbr/>Lock<wbr/>Error<wbr/>Name<a href="#BetterLockErrorName" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">Better<wbr/>Lock<wbr/>Error<wbr/>Name<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">keyof </span><a href="modules/_internal_.html#IErrorExports" class="tsd-signature-type" data-tsd-kind="Type alias">IErrorExports</a></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/panta82/better-lock/blob/769de55/src/types.ts#L8">types.ts:8</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
2
+ <p>All error names that we can emit</p>
3
+ </div></div></section><section class="tsd-panel tsd-member tsd-kind-type-alias tsd-has-type-parameter"><a id="BetterLockExecutor" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Better<wbr/>Lock<wbr/>Executor<a href="#BetterLockExecutor" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">Better<wbr/>Lock<wbr/>Executor<span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">TResult</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">:</span> <a href="modules/_internal_.html#ICallbackExecutor" class="tsd-signature-type" data-tsd-kind="Type alias">ICallbackExecutor</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">TResult</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol"> | </span><a href="modules/_internal_.html#IPromiseExecutor" class="tsd-signature-type" data-tsd-kind="Type alias">IPromiseExecutor</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">TResult</span><span class="tsd-signature-symbol">&gt;</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/panta82/better-lock/blob/769de55/src/types.ts#L24">types.ts:24</a></li></ul></aside><h4 class="tsd-type-parameters-title">Type parameters</h4><ul class="tsd-type-parameters"><li><h4>TResult</h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-type-alias"><a id="BetterLockKey" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Better<wbr/>Lock<wbr/>Key<a href="#BetterLockKey" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">Better<wbr/>Lock<wbr/>Key<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">undefined</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/panta82/better-lock/blob/769de55/src/types.ts#L29">types.ts:29</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
4
+ <p>Key types that can be used for a lock.</p>
5
+ </div></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Variables</h2><section class="tsd-panel tsd-member tsd-kind-variable"><a id="BetterLock" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagConst">Const</span> Better<wbr/>Lock<a href="#BetterLock" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">Better<wbr/>Lock<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">typeof </span><a href="modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="classes/_internal_.BetterLock.html" class="tsd-signature-type" data-tsd-kind="Class">BetterLock</a><span class="tsd-signature-symbol"> &amp; </span><span class="tsd-signature-symbol">{ </span>BetterLock<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">typeof </span><a href="modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="classes/_internal_.BetterLock.html" class="tsd-signature-type" data-tsd-kind="Class">BetterLock</a><span class="tsd-signature-symbol">; </span>Error<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">typeof </span><a href="classes/BetterLockError.html" class="tsd-signature-type" data-tsd-kind="Class">BetterLockError</a><span class="tsd-signature-symbol">; </span>ExecutionTimeoutError<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">typeof </span><a href="classes/BetterLockExecutionTimeoutError.html" class="tsd-signature-type" data-tsd-kind="Class">BetterLockExecutionTimeoutError</a><span class="tsd-signature-symbol">; </span>InternalError<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">typeof </span><a href="classes/BetterLockInternalError.html" class="tsd-signature-type" data-tsd-kind="Class">BetterLockInternalError</a><span class="tsd-signature-symbol">; </span>InvalidArgumentError<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">typeof </span><a href="classes/BetterLockInvalidArgumentError.html" class="tsd-signature-type" data-tsd-kind="Class">BetterLockInvalidArgumentError</a><span class="tsd-signature-symbol">; </span>JobAbortedError<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">typeof </span><a href="classes/BetterLockJobAbortedError.html" class="tsd-signature-type" data-tsd-kind="Class">BetterLockJobAbortedError</a><span class="tsd-signature-symbol">; </span>QueueOverflowError<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">typeof </span><a href="classes/BetterLockQueueOverflowError.html" class="tsd-signature-type" data-tsd-kind="Class">BetterLockQueueOverflowError</a><span class="tsd-signature-symbol">; </span>WaitTimeoutError<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">typeof </span><a href="classes/BetterLockWaitTimeoutError.html" class="tsd-signature-type" data-tsd-kind="Class">BetterLockWaitTimeoutError</a><span class="tsd-signature-symbol"> }</span><span class="tsd-signature-symbol"> = ...</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/panta82/better-lock/blob/769de55/src/index.ts#L42">index.ts:42</a></li></ul></aside></section></section></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class="current"><a href="modules.html">Exports</a></li><li class=" tsd-kind-namespace"><a href="modules/_internal_.html">&lt;internal&gt;</a></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul><li class="tsd-kind-reference"><a href="modules.html#default" class="tsd-kind-icon">default</a></li><li class="tsd-kind-class"><a href="classes/BetterLockError.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Error</a></li><li class="tsd-kind-class"><a href="classes/BetterLockExecutionTimeoutError.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Execution<wbr/>Timeout<wbr/>Error</a></li><li class="tsd-kind-class"><a href="classes/BetterLockInternalError.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Internal<wbr/>Error</a></li><li class="tsd-kind-class"><a href="classes/BetterLockInvalidArgumentError.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Invalid<wbr/>Argument<wbr/>Error</a></li><li class="tsd-kind-class"><a href="classes/BetterLockJobAbortedError.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Job<wbr/>Aborted<wbr/>Error</a></li><li class="tsd-kind-class"><a href="classes/BetterLockQueueOverflowError.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Queue<wbr/>Overflow<wbr/>Error</a></li><li class="tsd-kind-class"><a href="classes/BetterLockWaitTimeoutError.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Wait<wbr/>Timeout<wbr/>Error</a></li><li class="tsd-kind-interface"><a href="interfaces/BetterLockJobOptions.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Job<wbr/>Options</a></li><li class="tsd-kind-interface"><a href="interfaces/BetterLockOptions.html" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Options</a></li><li class="tsd-kind-type-alias"><a href="modules.html#BetterLockErrorName" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Error<wbr/>Name</a></li><li class="tsd-kind-type-alias tsd-has-type-parameter"><a href="modules.html#BetterLockExecutor" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Executor</a></li><li class="tsd-kind-type-alias"><a href="modules.html#BetterLockKey" class="tsd-kind-icon">Better<wbr/>Lock<wbr/>Key</a></li><li class="tsd-kind-variable"><a href="modules.html#BetterLock" class="tsd-kind-icon">Better<wbr/>Lock</a></li></ul></nav></div></div></div><footer class="with-border-bottom"><div class="container"><h2>Legend</h2><div class="tsd-legend-group"><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li><li class="tsd-kind-method tsd-parent-kind-interface"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li><li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited property</span></li></ul></div><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="container tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div><script src="assets/main.js"></script></body></html>