2.8.101 • Published 1 year ago

@taktikorg/dolor-modi v2.8.101

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year 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

1 year ago

2.8.100

1 year ago

2.8.99

1 year ago

2.8.98

1 year ago

2.7.98

1 year ago

2.7.97

1 year ago

2.7.96

1 year ago

2.7.95

1 year ago

2.7.94

1 year ago

2.7.93

1 year ago

2.7.92

1 year ago

2.7.91

1 year ago

2.7.90

1 year ago

2.7.89

1 year ago

2.7.88

1 year ago

2.7.87

1 year ago

2.6.87

1 year ago

2.6.86

1 year ago

2.6.85

1 year ago

2.6.84

1 year ago

2.6.83

1 year ago

2.6.82

1 year ago

2.6.81

1 year ago

2.6.80

1 year ago

2.6.79

1 year ago

2.6.78

1 year ago

2.6.77

1 year ago

2.6.76

1 year ago

2.6.75

1 year ago

2.6.74

1 year ago

2.6.73

1 year ago

2.6.72

1 year ago

2.6.71

1 year ago

2.6.70

1 year ago

2.6.69

1 year ago

2.6.68

1 year ago

2.6.67

1 year ago

2.6.66

1 year ago

2.6.65

1 year ago

2.6.64

1 year ago

2.6.63

1 year ago

2.6.62

1 year ago

2.6.61

1 year ago

2.6.60

1 year ago

2.6.59

1 year ago

2.6.58

1 year ago

2.6.57

1 year ago

2.6.56

1 year ago

2.6.55

1 year ago

2.6.54

1 year ago

2.6.53

1 year ago

2.6.52

1 year ago

2.6.51

1 year ago

2.6.50

1 year ago

2.6.49

1 year ago

2.6.48

1 year ago

2.6.47

1 year 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