2.8.101 • Published 10 months ago

@taktikorg/dolor-modi v2.8.101

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Async Await Mutex Lock

Tests

Mutex locks for async functions with functionality to use keys for separate locks

NPM

Usage Instructions

Without Key

import { Lock } from "@taktikorg/dolor-modi";

let lock = new Lock();

async function serialTask() {
  await lock.acquire();

  try {
    // Don't return a promise here as Promise may resolve after finally
    // has executed
  } finally {
    lock.release();
  }
}

With Key

All the keys will have their own separate locks and separate waiting lists. A key can have any type (eg. string, number, etc. or a custom type allowed by typescript as a Map key)

import { Lock } from "@taktikorg/dolor-modi";

let lock = new Lock<string>();

async function serialTask() {
  await lock.acquire("myKey");

  try {
    // Don't return a promise here as Promise may resolve after finally
    // has executed
  }
  finally {
    lock.release("myKey");
  }
}

async function serialTaskTwo() {
  await lock.acquire("myKeyTwo");

  try {
    // Don't return a promise here as Promise may resolve after finally
    // has executed
  }
  finally {
    lock.release("myKeyTwo");
  }
}

Checking if a lock is acquired or not

import { Lock } from "@taktikorg/dolor-modi";

let lock = new Lock();

async function serialTask() {
  await lock.acquire();

  console.log(lock.isAcquired()); // prints true
}

isAcquired() with key checks for the given key separately.

import { Lock } from "@taktikorg/dolor-modi";

let lock = new Lock<string>();

async function serialTask() {
  await lock.acquire("myKey");

  console.log(lock.isAcquired("myKey")) // prints true
}

Issues or Bugs

In case of any issues or bugs, please open a pull request here

descriptorsnegative zerorobustimmutablesomereworkArray.prototype.flatmodulelruplugini18naccessibilityprivate dataES6runtimebinariescircularfindclibinaryavalogserializerschemacolorscloudsearchdeepcjkbeanstalkdatahas-ownbrowserslistfindLastrmvarsyntaxerrorregularasciies6jsdiffclientpostcssfastifyfast-deep-copyredactwhatwgpicomatchfnmatchintrinsicoptionwritableES5terminalprotobufindicatortoReversedenderreadrgbpushmetadatavalidatorYAMLelbwidthchromiumslotspeedhelperargumentemrhttpspinnerphoneurlconsolepnpm9debuginstalltelephoneObject.definePropertyreducedefinePropertysuperstructserializationschemegraphqlquerygetOwnPropertyDescriptorl10ncensorES2017-0typedcollectionshimtakecloudformationObjecttypedarrayss3styleguideflag[[Prototype]]tc39estreeObservableURLes7superagentcss-in-jsspinnerslintgetapollodotenvvalidationcommandermkdirsbabelletWebSocketsrm -frsqseslint-plugincssdeepclonesliceyupio-tstsspawnreal-timereact-testing-librarycallbackesguidrdsmatchAllarraytddUint8ArrayframeworkdeletehastesterArray.prototype.flattentermmochapropertiesECMAScript 6escapemodulesES2015environmentsgetterRegExp#flagspolyfillfunctionhtmlawesomesaucedescriptionobjectecmascripttranspileres-shim APItestwafrangeerrorjsdomposefixed-widthglacierECMAScript 2020genericscurlrequireweakmapdeterministicjsonschemakeyseffect-tsInt8ArraylastlookObject.isconcatMapSymbol.toStringTagtypeofincludesrulesObject.keyshasOwnhelpersBigInt64ArrayclassestrimEndses3dcharacterstylenamesECMAScript 2017typesextraec2mrutimecallnameArray.prototype.findLastajaxpatch__proto__ReactiveExtensionscompilerpromisereact animationregular expressionsimportRFC-6455descriptorfastcloneelectronforkkoreangesturesserializeansiformtransformfunctionsassertsvaluesenvironment$.extendoffsetsubprocessxtermes2015lengthmakeeventEmitteristanbulArrayBuffereverymanipulationasteriskspositivebundlingloadingreversedglobequalityglobalsqueuenativereduxHyBiURLSearchParamschaitoSortedswfharmonyargsESnextises2016nodejseslinttoolsglobal objectStyleSheetmonoreponodeagentsameValueZeroeast-asian-widtha11yequalredirecttypesafebyteLengthinspectlibphonenumberObject.fromEntriestrimStartpreprocessorfindupeventDispatcherdom-testing-librarytypescriptutilES3256linkpackagesoptimizerpruneES2020ponyfillfast-deep-cloneaccessorutilsutil.inspectregular-expressiontapfile systemrecursiveReactiveXutilityfpfast-copyzodentriescloudwatchworkercheckinputBigUint64ArraybindassertionECMAScript 2023feedtypanionrmdirconcatbabel-coreshellhasOwnPropertycodesprocessgetPrototypeOflistenersES2019dataViewjscode pointsredux-toolkitresolvecharacterstrimLeftrm -rfECMAScriptdependency manageremojioutputES8dynamodbanimationrestcolumndayjsdataviewformatkinesiscreatesetPrototypeOfsearchhookformcallbindString.prototype.trimstreamsfilefpsRegExp.prototype.flagsfast-cloneArray.prototype.findLastIndexsafepopmotionfilterUint8ClampedArraychildwindowfunction.lengthfastroutingpropertycall-boundfull-widthrfc4122ajvarktypeES2016iteratortacitinstallervarsartrssassignfantasy-landhardlinkssorttransportexpressionpackage.jsonlook-upArray.prototype.containsES2022ECMAScript 5sinatrauninstallJSON-SchemashamObject.getPrototypeOfmkdirpsharedarraybufferloggersimpledbfunctionaltyped arrayperformanceremovees2018proxyECMAScript 2015WebSocketpackagestoragegatewayreuseargvcolorspringes8coercibletostringtagshebanggetoptidsymboltoobjectECMAScript 2019jsxrapid
2.8.101

10 months ago

2.8.100

10 months ago

2.8.99

10 months ago

2.8.98

10 months ago

2.7.98

10 months ago

2.7.97

10 months ago

2.7.96

10 months ago

2.7.95

11 months ago

2.7.94

11 months ago

2.7.93

11 months ago

2.7.92

11 months ago

2.7.91

11 months ago

2.7.90

11 months ago

2.7.89

11 months ago

2.7.88

11 months ago

2.7.87

11 months ago

2.6.87

11 months ago

2.6.86

11 months ago

2.6.85

11 months ago

2.6.84

11 months ago

2.6.83

11 months ago

2.6.82

11 months ago

2.6.81

11 months ago

2.6.80

11 months ago

2.6.79

11 months ago

2.6.78

11 months ago

2.6.77

11 months ago

2.6.76

11 months ago

2.6.75

11 months ago

2.6.74

11 months ago

2.6.73

11 months ago

2.6.72

11 months ago

2.6.71

11 months ago

2.6.70

11 months ago

2.6.69

11 months ago

2.6.68

11 months ago

2.6.67

11 months ago

2.6.66

12 months ago

2.6.65

12 months ago

2.6.64

12 months ago

2.6.63

12 months ago

2.6.62

12 months ago

2.6.61

12 months ago

2.6.60

12 months ago

2.6.59

12 months ago

2.6.58

12 months ago

2.6.57

12 months ago

2.6.56

12 months ago

2.6.55

12 months ago

2.6.54

12 months ago

2.6.53

12 months ago

2.6.52

12 months ago

2.6.51

12 months ago

2.6.50

12 months ago

2.6.49

12 months ago

2.6.48

12 months ago

2.6.47

12 months ago

2.6.46

1 year ago

2.6.45

1 year ago

2.6.44

1 year ago

2.6.43

1 year ago

2.6.42

1 year ago

2.6.41

1 year ago

2.6.40

1 year ago

2.6.39

1 year ago

2.6.38

1 year ago

1.6.38

1 year ago

1.5.38

1 year ago

1.5.37

1 year ago

1.5.36

1 year ago

1.5.35

1 year ago

1.5.34

1 year ago

1.4.34

1 year ago

1.4.33

1 year ago

1.4.32

1 year ago

1.4.31

1 year ago

1.3.31

1 year ago

1.3.30

1 year ago

1.3.29

1 year ago

1.3.28

1 year ago

1.3.27

1 year ago

1.3.26

1 year ago

1.3.25

1 year ago

1.3.24

1 year ago

1.3.23

1 year ago

1.3.22

1 year ago

1.2.22

1 year ago

1.2.21

1 year ago

1.2.20

1 year ago

1.2.19

1 year ago

1.1.19

1 year ago

1.1.18

1 year ago

1.1.17

1 year ago

1.1.16

1 year ago

1.1.15

1 year ago

1.1.14

1 year ago

1.1.13

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago