0.3.1 • Published 1 year ago

frdrk-js-semaphore v0.3.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

frdrk-js-semaphore - Syncronization Using Promises (fork)

License Travis CI Coverage Status Commitizen

js-semaphore is a simple Semaphore implementation using Promises for JavaScript aplications.

Installation

js-semaphore is available with npm/yarn:

$ npm install frdrk-js-semaphore --save

Usage

With require

const Semaphore = require('frdrk-js-semaphore').Semaphore;

// Semaphore with 1 resource = Mutex
const semaphore = Semaphore();

// Semaphore with 1 resource, starting at 0 value
const semaphore = Semaphore({ resource: 1, start: 0 });

// Semaphore with 3 resources
const semaphore = Semaphore({ resource: 3 });

// acquire the semaphore
semaphore.acquire().then(() => {
  // Your code goes here
  const x = 2 + 3;

  // remember to release the semaphore at the end of your usage
  semaphore.release();
});

License

MIT License © Codevor

ababacornacorn-globalsacorn-jsxacorn-walkajvaggregate-errorajv-errorsansi-escapesansi-regexansi-stylesanymatchaprobaargarr-diffargparsearr-unionarray-equalarray-includesarray-uniquearr-flattenarray.prototype.flatmaparray.prototype.reduceasn1array.prototype.flatassertasn1.jsassert-plusastral-regexassign-symbolsasync-eachasync-limiterasynckitat-least-nodeatobaws-sign2available-typed-arraysaws4babel-plugin-istanbulbabel-plugin-jest-hoistbabel-plugin-polyfill-corejs3babel-plugin-polyfill-regeneratorbabel-plugin-polyfill-corejs2babel-preset-jestbalanced-matchbasebase64-jsbcrypt-pbkdfbig.jsbinary-extensionsbindingsblbn.jsbluebirdbrace-expansionbracesbrorandbrowser-process-hrtimebrowser-resolvebrowserify-aesbrowserify-cipherbrowserify-desbrowserify-signbrowserify-rsabrowserify-zlibbrowserslistbserbufferbuffer-frombuffer-xorbuiltin-status-codescacachecache-basecall-bindcachedircaller-callsitecallsitescamelcasecaller-pathcaniuse-litecapture-exitchalkcaselesschardetchokidarchownrchrome-trace-eventcipher-baseci-infoclass-utilsclean-stackcli-cursorcli-spinnerscli-widthclonecliuicocollection-visitcolor-convertcolor-namecombined-streamcommandercommondirconcat-mapcomponent-emitterconfusing-browser-globalsconsole-browserifyconcat-streamconstants-browserifyconventional-commit-typesconvert-source-mapcopy-concurrentlycopy-descriptorcore-js-compatcore-util-iscosmiconfigcosmiconfig-typescript-loadercreate-ecdhcreate-hashcreate-requirecreate-hmaccross-spawncrypto-browserifycssomcssstylecyclistdashdashdebugdata-urlsdecamelizedecode-uri-componentdedentdeep-isdefine-propertiesdefine-propertydefaultsdelayed-streamdetect-filedetect-indentdes.jsdetect-newlinediffdiff-sequencesdiffie-hellmandoctrinedomain-browserdomexceptionecc-jsbnduplexifyelectron-to-chromiumellipticemoji-regexemojis-listend-of-streamenhanced-resolveerrnoes-abstracterror-exes-array-method-boxes-properlyes-set-tostringtages-shim-unscopableses-to-primitiveescaladeescape-string-regexpescodegeneslint-module-utilseslint-import-resolver-nodeeslint-utilseslint-scopeespreeeslint-visitor-keysesprimaesqueryesrecurseestraverseesutilseventsevp_bytestokeyexec-shexecaexitexpand-bracketsexpand-tildeexpectextendextend-shallowexternal-editorextglobextsprintffast-deep-equalfast-json-stable-stringifyfast-levenshteinfb-watchmanfiggy-puddingfiguresfile-entry-cachefile-uri-to-pathfill-rangefind-cache-dirfind-node-modulesfind-rootfind-upfindup-syncflat-cacheflattedflush-write-streamfor-eachfor-inforever-agentfragment-cacheform-datafrom2fs-extrafs-minipassfs-readdir-recursivefs-write-stream-atomicfs.realpathfseventsfunction-bindfunction.prototype.namefunctions-have-namesfunctional-red-black-treegensyncget-intrinsicget-stdinget-streamget-symbol-descriptionget-caller-fileget-valuegetpassglobglobal-dirsglob-parentglobal-modulesglobal-prefixglobalsglobalthisgraceful-fsgrowlygopdhar-schemahar-validatorhashas-flaghas-bigintshas-symbolshas-protohas-property-descriptorshas-valueshas-tostringtaghash-basehas-valuehash.jshmac-drbghomedir-polyfillhosted-git-infohtml-encoding-snifferhtml-escaperhttp-signaturehttps-browserifyiconv-liteieee754iferrignoreimport-freshimport-localimurmurhashindent-stringinfer-ownerinflightinheritsiniinquirerinternal-slotinterpretinvariantis-array-bufferis-arrayishis-accessor-descriptoris-bigintis-binary-pathis-boolean-objectis-bufferis-ciis-callableis-core-moduleis-data-descriptoris-descriptoris-date-objectis-directoryis-extendableis-extglobis-fullwidth-code-pointis-generator-fnis-globis-interactiveis-negative-zerois-numberis-number-objectis-plain-objectis-regexis-shared-array-bufferis-stringis-typed-arrayis-symbolis-streamis-unicode-supportedis-utf8is-weakrefis-wslis-typedarrayis-windowsisarrayisexeisstreamisobjectistanbul-lib-coverageistanbul-lib-instrumentistanbul-lib-reportistanbul-lib-source-mapsjest-changed-filesistanbul-reportsjest-clijest-configjest-diffjest-docblockjest-eachjest-environment-jsdomjest-environment-nodejest-haste-mapjest-get-typejest-jasmine2jest-leak-detectorjest-matcher-utilsjest-mockjest-regex-utiljest-pnp-resolverjest-message-utiljest-resolve-dependenciesjest-resolvejest-runnerjest-runtimejest-serializerjest-snapshotjest-utiljest-validatejest-watcherjest-workerjs-tokensjs-yamljsdomjsbnjsescjson-parse-better-errorsjson-schemajson-schema-traversejson-parse-even-better-errorsjson-stable-stringify-without-jsonifyjson-stringify-safejson5jsonfilejsprimkind-ofkleurlcov-parseleft-padload-json-filelevenlevnlodashlines-and-columnsloader-utilsloader-runnerlodash.isplainobjectlodash.debouncelodash.maplocate-pathlodash.mergewithlodash.mergelodash.uniqlodash.sortbylog-driverlog-symbolslongestloose-envifylru-cachemake-dirmake-errormap-cachemakeerrormap-visitmd5.jsmemory-fsmergemerge-streammicromatchmiller-rabinmime-typesmime-dbmimic-fnminimalistic-assertminimatchminimistminimalistic-crypto-utilsminipassminipass-collectminipass-flushminipass-pipelinemississippimixin-deepmkdirpmove-concurrentlymsmute-streamnannanomatchnatural-compareneo-asyncnode-int64nice-trynode-libs-browsernode-notifiernormalize-package-datanode-releasesnpm-run-pathnormalize-pathnwsapioauth-signobject-assignobject-copyobject-inspectobject-keysobject.assignobject.entriesobject-visitobject.getownpropertydescriptorsobject.pickobject.valuesonceopencollective-postinstallonetimeoptionatororaos-tmpdirp-each-seriesos-browserifyp-finallyp-limitp-locatep-mapp-reducep-trypakoparallel-transformparent-moduleparse-jsonparse-asn1parse-passwdparse5pascalcasepath-browserifypath-dirnamepath-existspath-is-absolutepath-keypath-parsepbkdf2path-typeperformance-nowpicocolorspicomatchpifypiratespkg-dirplease-upgrade-nodepnposix-character-classesprelude-lsprocesspretty-formatprocess-nextick-argsprogresspromise-inflightpromptsprrpslpublic-encryptpumppumpifypunycodeqsquerystringquerystring-es3randombytesrandomfillreact-isread-pkgread-pkg-upreadable-streamreaddirprealpath-nativeregenerateregenerate-unicode-propertiesregenerator-runtimeregex-notregenerator-transformregexp.prototype.flagsregexppregexpu-coreregjsparserremove-trailing-separatorrepeat-elementrepeat-stringrequestrequest-promise-corerequire-directoryrequest-promise-nativerequire-from-stringresolverequire-main-filenameresolve-cwdresolve-dirresolve-fromresolve-globalresolve-urlretrestore-cursorright-padripemd160rsvprun-asyncrun-noderun-queuerxjssafe-regexsafe-buffersafe-regex-testsafer-buffersanesaxschema-utilssemversemver-compareserialize-javascriptset-blockingset-valuesetimmediatesha.jsshebang-commandshebang-regexshellwordsside-channelsisteransisignal-exitslashslice-ansisnapdragonsnapdragon-nodesnapdragon-utilsource-list-mapsource-mapsource-map-resolvesource-map-supportsource-map-urlspdx-correctspdx-exceptionsspdx-expression-parsespdx-license-idssplit-stringsprintf-jssshpkssristack-utilsstatic-extendstealthy-requirestream-browserifystream-eachstream-httpstream-shiftstring-lengthstring.prototype.trimendstring-widthstring.prototype.trimstartstring_decoderstrip-ansistrip-bomstrip-eofstrip-json-commentssupports-colorsupports-preserve-symlinks-flagtabletapablesymbol-treetersertest-excludetext-tablethroatthroughthrough2timers-browserifytmptmplto-arraybufferto-object-pathto-fast-propertiesto-regexto-regex-rangetough-cookietr46ts-nodetsconfig-pathstty-browserifytslibtunnel-agenttweetnacltype-festtyped-array-lengthtypedarraytype-checktypescriptunbox-primitiveunicode-canonical-property-names-ecmascriptunicode-match-property-value-ecmascriptunicode-match-property-ecmascriptunicode-property-aliases-ecmascriptunion-valueunique-filenameunique-sluguniversalifyunset-valueupathuri-jsurixurlupdate-browserslist-dbuseutilutil-deprecateutil.promisifyv8-compile-cacheuuidv8-compile-cache-libvalidate-npm-package-licenseverrorvm-browserifyw3c-hr-timewalkerwatchpack-chokidar2watchpackwcwidthwebidl-conversionswebpack-sourceswhatwg-encodingwhatwg-mimetypewhatwg-urlwhichwhich-boxed-primitivewhich-typed-arrayworker-farmword-wrapwhich-modulewrap-ansiwrappywritewrite-file-atomicwsxml-name-validatorxtendy18nyallistyargsyargs-parseryn
0.3.1

1 year ago

0.3.0

1 year ago