1.1.11 • Published 5 days ago

@taktikorg/laudantium-voluptatum-dignissimos v1.1.11

Weekly downloads
-
License
MIT
Repository
github
Last release
5 days ago

FSLockJS

NPM Version Build Status

Easy to use file system queue with locking and events. Provide Asynchronous utilities for Directories and File

This library's goal is to provide nothing than a easy way to wait for the asynchronous execution of a FS operation in a lock environment.

Table of Contents

Installation

npm install fslock

Usage

mkdir myproject
cd myproject
npm init
npm install fslock
touch index.js

And there just use that snipets to start playing ! :

const {FSLock, File, Directory} = require('@taktikorg/laudantium-voluptatum-dignissimos');
const queue = new FSLock();

const start = async function () {
  const doc = {_id:'507f1f77bcf86cd799439011',name:"Alex", age:28};
  const doc2 = {_id:'507f1f77bcf86cd799439011',name:"Alex", age:27};
  const job = queue.add('File.create','.db/507f1f77bcf86cd799439011.json',doc);
  const job2 = queue.add('File.overwrite','.db/507f1f77bcf86cd799439011.json',doc2);
  const job3 = queue.add('File.read','.db/507f1f77bcf86cd799439011.json');

  await job3.execution();
  console.log(job3.results===doc2) //true
  
  const isExisting = await File.exists('.db/507f1f77bcf86cd799439011.json')//true
}
start();

Alternatively, you could suppress the autoexec, and deal with it this way

  const queue = new FSLock({autoexec:false});
  const doc = {_id:'507f1f77bcf86cd799439011',name:"Alex", age:28};
  queue.add('File.create','.db/507f1f77bcf86cd799439011.json',doc);
  const job = queue.add('File.read','.db/507f1f77bcf86cd799439011.json');

  await queue.processNext();
  await queue.processNext();
  console.log(job.results===doc) //true

Also, we provide events on job

  const queue = new FSLock({autoexec:false});
  const doc = {_id:'507f1f77bcf86cd799439011',name:"Alex", age:28};
  queue.add('File.create','.db/507f1f77bcf86cd799439011.json',doc);
  const job = queue.add('File.read','.db/507f1f77bcf86cd799439011.json');
  job.on('executed',()=>{
    console.log(job.results);
    console.log(job.results===doc) //true
  });
  queue.start();

Documentation

FAQ :

Why ?

Because of being able to do await job.execution()

Which end up being a nice way to wait for the resolvement of a FS Job in concurrent conditions

const job = await this.queue.add('File.exists', path).execution(); 
const isExistingFile = job.results;

Alternatively equal to this below, that will only returns results when having it.

const results = await this.queue.add('File.exists', path).getResults(); 

Caveat ?

Right now, an instance of FSLock only deal locally with the locks. If needed, we can make two instance working together with using real os lock.
Submit issue if you need such features.

guidmulti-packagetapeeventsObject.isfetchprotobufdayjshelpersglobalsObject.valuesredactstringifypersistentsetPrototypeOfkarmaspinnerindicatortimeObjectlruES3waf@@toStringTagfast-cloneObject.assignasyncrm -rfECMAScript 7espreevisualbreakemojitoobjectglobframercjkcircularcolores2015wordwrapECMAScript 2019CSSdropcall-bindpromisesposeinstringinternal slotES2019WeakSetshebangduplexArray.prototype.flattenprototypesymbolsyntaxerrorsomeMapcolumnscoercibledotenvtoArraySymbolfindLastIndexthreeflagvalidatematchesflatMapequalcmdwgetforkpromisees-shimses6commandreworkstylesBigInt64Arraypropertiescollection.es6preserve-symlinksgdprimportparsinges2018deep-cloneBigUint64ArrayregexequalityspecagentsymlinkinvariantmimecurlescapeArray.prototype.filtertddSetpnpm9RegExp.prototype.flagsdescriptorsfigletpatchfileES6trimRightautoprefixerpackageprivate datafixed-widthlazyoutputaccessores2017rdsdeeplanguageflatlastoptionproxy256ajaxtaskcloudwatchlibphonenumberstoragegatewayschemekoreannegative zerofullwidthdomawesomesaucemonoreposameValueZerostatelessstartexecutableexecfileUint32Arrayenumerableworkflowbluebirdcloudfrontargvfind-upObservablestesttypeerrortransformwebsiteES2021astRFC-6455toolschannelUnderscoresnsmkdirssortedtsarktypeiebatchconfigurableprocessapiperformantURLSearchParamsendpointmatchl10ntextgestureseast-asian-widthfast-deep-cloneanimationintrinsicES2017airbnbassertsString.prototype.trimECMAScript 2017shimES2018bundlingES2022genericsjsdomfast-copysetImmediatexdglogcomputed-typesprettyECMAScript 2018safelinewrapnpmworkspace:*robustextendstyled-componentswhichmodulejsxfeedexpressioncallbackgetintrinsicbufferhtmlurlArray.prototype.flatMapcsslintloadbalancingdebuggerimmerasciivaluesrangeerrorArray.prototype.findLastboundtapestreemetadatahasOwncreatereact-hooksclass-validatorconfiggroupSymbol.toStringTagcontainsfpsserializationreducerAsyncIteratorES7ObservableinputES8redux-toolkitmovewalkthrottleTypeBoxviewserializerenvironmentsfiltersource maptestingincludesWebSocketsfindLastxdg-opendataviewsubprocessimportexportES5xtermiteratetypedpositiveregular expressionsmapreducemergebindvestvariablesscheme-validationInt32Arraycompilernativecolumnnumberfastifystreams2trimStartenderutil.inspectdiffapollophonetestercommand-linefastunicodesuperstructformatsortnodejsentriesdirremoveopensterminalajvdefinerequireregexpatomutilitydragquotedeleteMicrosoftclienttypesisConcatSpreadablemapvarssetterdataECMAScript 2021JSON-SchemastructuredClonestreamprotoaccessibilitywordbreakjsdiffes5Object.entriesRegExp#flagsregularbinroutingmakeio-tsavaObject.fromEntrieserror_.extendwalkingcore-jsconcurrencywriteansiArray.prototype.findLastIndexsymbolssettingsArrayBufferstdlibtslib$.extendbinariessuperagentprogressrmdirnamesvpcarraybufferdataViewforEachYAMLpathexecutewidthbyteUint16ArrayReactiveXinstallUint8ClampedArrayxmlopendefaulttoStringTagCSSStyleDeclarationECMAScript 2015installerECMAScript 2020javascriptString.prototype.matchAllchromiumswfawaitsqsUint8ArrayObject.definePropertytyped arrayworkerReflect.getPrototypeOfdependency managerpreprocessorslotrecursivelockfilecodesbusystablecloudtraildescriptorStreamiteratorchromeownratelimitspeediamreact animationdeterministiclistenersidentifiersfast-deep-copyFloat32Arrayfull-widthreduxes8parentargsshellpicomatchfindreadablestreamtermidleomittc39prunePromisecopyESnextlinkautoscalingHyBielectronECMAScript 2016loggera11ycalltostringtagtoSortedkeylimits3querywritableeslintpluginsimpledbES2023concatMapWebSocketperformancetypeofbddpopmotionuuidObject.keystrimzodStreamspyyamlawsnodespinnersoptimizergetinspectcolourhashwhatwgtypescriptobject__proto__globaljshintextrabannerbrowserreadcensorlookdirectorykeyseslint-pluginlook-upoffsetexecargumentsschemareact-hook-formbyteLengthmime-dbfunctionsbrowserlistpackage managerhelpercoregetterhigher-orderstylingflagsuninstallparentsdefinePropertyfromgetOwnPropertyDescriptorsequencemake dirArrayBuffer.prototype.sliceefficientloadingObject.getPrototypeOfrateprefixconsolebundlerebschaiTypeScriptgetPrototypeOfRxresolvecharactersvalidation-0pushgraphqlrmArrayrequestecmascriptstylehardlinksmrufunctionalsescloudsearchprotocol-bufferstakettyconcatparsertelephonepackage.jsonbufferscss-in-jsTypedArraybinarystringifiertranspilerInt16Arrayemitimmutablehas-ownsharedformattingtypeeslintconfigarrayqueueArray.prototype.flatsyntaxmkdirformshas.envpipetrimLeftreact-testing-libraryspringthroathttpECMAScript 3jasmineStyleSheetes7hooksArrayBuffer#slicewaitamazoncollectiontoolkitjapaneseArray.prototype.includescall-boundsidedeepcopycharactercryptospawnpackagesquerystringtypesafehasOwnPropertyappdescriptionrssflattenruntimeeventEmitterinferencematchAllinternalES2016Iteratorrandomjsrfc4122jest0modulesroutestarterFloat64Arrayzxcloudformationformchilddom-testing-libraryonceexpresscloneutilgroupBywrapartvalueES2020propform-validationvalidec2rm -frenvironmenttraverseopenersetminimales-abstractcachefolderutilitieslengthparsereactdynamodbdeepclonefsprivateemrbrowserslistECMAScript 2023objmimetypesglaciermanipulationmochaiterationurlsdebugnegativeshampostcsseventDispatcherlocaleditorRxJScallbindFunction.prototype.namedependenciesassertion
1.1.11

5 days ago

1.1.10

6 days ago

1.1.9

7 days ago

1.1.8

8 days ago

1.1.7

9 days ago

1.1.6

10 days ago

1.1.5

11 days ago

1.1.4

12 days ago

1.1.3

13 days ago

1.0.3

14 days ago

1.0.2

15 days ago

1.0.1

16 days ago

1.0.0

16 days ago