6.13.119 • Published 10 months ago

@patrtorg/nulla-ut-sequi v6.13.119

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

@patrtorg/nulla-ut-sequi

========= CircleCI

Given a MongoDB query cursor, process the results in parallel, up to the specified limit.

var @patrtorg/nulla-ut-sequi = require('@patrtorg/nulla-ut-sequi');
var cursor = mongoCollection.find({});

return @patrtorg/nulla-ut-sequi(cursor, 8, function(doc, callback) {
  // Up to 8 of these will be invoked simultaneously
  // Do something with doc, then...
  return callback(null);
}, function(err) {
  // All done
});

Why?

We wanted to work with MongoDB queries the way we work with async.eachLimit, but without yanking everything into memory at once with toArray.

Specifically, we wanted to resize some images in parallel, rather than waiting to do them one at a time. We have a MongoDB collection with information about all of the images. But there are a lot of them, so we don't want to yank all of that information into memory up front.

@patrtorg/nulla-ut-sequi wraps MongoDB's Cursor.nextObject with a queueing mechanism that allows several results to be processed at once, but only up to the limit you specify. You don't run out of memory due to too many image processes, you don't wait too long, and you don't have to load the entire array into memory at once. Everybody gets a medal.

What about errors?

If an error occurs, @patrtorg/nulla-ut-sequi will:

  1. Stop starting new iterator callbacks.
  2. Wait for any outstanding iterator callbacks to finish.
  3. Invoke the final callback (its third argument) with the first error it received.

Using @patrtorg/nulla-ut-sequi without mongodb

You can pass any object with a nextObject method as the "cursor." That method should invoke its callback with (err, object). If there is no error, object should be the next object retrieved from your data source. If there are no more objects, pass null as object.

About P'unk Avenue and Apostrophe

@patrtorg/nulla-ut-sequi was created at P'unk Avenue for use in many projects built with Apostrophe, an open-source content management system built on node.js. If you like @patrtorg/nulla-ut-sequi you should definitely check out apostrophecms.com.

Support

Feel free to open issues on github.

Changelog

1.1.0

  • Adds support for both MongoDB 2 and 3 via the cursor next and nextObject methods.
  • Adds JS linting to the tests.

1.0.0

  • Declared 1.0.0 stable as this has long been a component of Apostrophe. Updated lodash dependency to satisfy npm audit.

0.1.1

  • Fixed a rare race condition which caused @patrtorg/nulla-ut-sequi to invoke its final callback more than once.

0.1.0

  • Initial release. With shiny unit tests, of course.
multi-packageelasticachePushregexgetfast-clonegetterWeakMapredux-toolkites2017writeObjectObject.fromEntriesclonechildcomputed-typescreatenegativeargumentlogl10nsnskey parmatchesrequirepyyamlcloudwatchprogressperformancefast-deep-copyeventEmittermatchAllpatchshamtypescriptObject.getPrototypeOftypeofBigInt64Arrayschemafolderreact poseimportexportairbnbhasOwnPropertyspinnersescapeawsdefineglobinstallerrorjson cachecloudformationprocesssharedbundlerutilitiesponyfillestreeidentifiersfastcopyjestdefinePropertyArrayBuffer.prototype.slicemobilebundlinghardlinksdynamodbcacheconfigtddnativeurlslibphonenumberposefile systemexecnegative zerospringcode pointsexecutableprotocol-buffers@@toStringTagproputilpolyfillglobalqueryexpressstreams2languagemkdirprotoJSONconvertformatupfunctionsRxJSconcurrencystdlibformattingrm -frec2assertenumerablecompareRFC-6455fullendpointfindECMAScript 3trimRightconfigurabledotenvextraes-abstractsimpledbwebsitecore-jsECMAScript 2023class-validatorinstallerreadablestreamvisuales2018searchjQuerygetintrinsicxdgmodule0appparserspecoutputstructuredCloneenvironmentslistenersECMAScript 2020persistentMicrosoftspawnfind-upparsingindicatorcharacteruninstallequalitydeep-cloneincludesa11yjsdomfsserializationagentoptimistparentformlimitedvalidationxterm3dcolumnpackage managerString.prototype.trimreuseoffsetquerystringmimereact-hookscryptoassertionvestES2015checkmonorepoparentsform-validationqswgetfpskinesisnodejsprotobufmime-dbcodestestingcopypushnamemrudom-testing-librarystoragegatewayrouteReactiveExtensionsUint32Arrayratelimitlastdependency managerObject.valuestakeECMAScript 7typeerrorcircularstylestypesObject.assign.envfullwidthregularenviterationsetImmediateSetcolumnsdeterministicurlprunewhichstylingsomesameValueZeromodulescollectionyuprm -rfwidthdragES5hashmake__proto__Array.prototype.flatMapES2021TypeBoxrmlinkqueueMicrotaskruntimebuffersidepnpm9whatwgstreamsetPrototypeOfObject.entriesdeleteinternal slotWebSocketsarrayschromejsbusystringcharactersstartajvjavascriptUint8ArraygraphqlUnderscoreflattenargumentsES3call-bindObservablesefficienthooksdebugtypeaccessorFloat32ArraylimitnopepropertieshasOwnmomentrmdirdescriptoriteratorcall-boundes2015east-asian-widthmovelaunchlrusesreact-hook-formmimetypeszerorfc4122browserslistcolorIteratorobjUint16Arraycommand-lineString.prototype.matchAllmkdirsPromiseomitsettingsdataprefixminimalfastifytextinputtc39assignprivate dataCSSStyleDeclarationwarningassertsES6exesyntaxjapaneseRxTypedArraywordbreakHyBiReactiveXFunction.prototype.nameECMAScript 2016walkreact animationjsxsuperagentbddglobalsreact-testing-librarydeepReflect.getPrototypeOfspinnerhas-owneslintzodtoolspackage.jsonregular expressionpropertycollection.es6es8valuefastcloneanimationTypeScriptECMAScript 2022serializerES2020threettyshellmapautoprefixerECMAScript 6cloudsearchkeysapollodeepclonetslibkey valuepluginthrottletermisConcatSpreadableArraytypedarraysrobustframerloadingeslintpluginlocationdataViewworkflowbeanstalkshimArray.prototype.includesiculoggingelectrondebuggergenericsparseArray.prototype.flattenisgetoptsimple cachecliistanbulavatspositivearraybuffertypedloggercontainsresolvestreamsbrowsertrimLeftECMAScript 2021inferencepipetraversedropes-shimsutilityamazonfast-deep-clonechineseinreal-timebluebirdarraysequenceArrayBuffer#slicesyntaxerrorcharsetcss-in-jschanneldirfilterschemetestercloudtrailreadablees6validategetPrototypeOffileflagfromlazyshrinkwrapemitawaitfunctionalterminaltoobjectawesomesaucebreakinvariantstylefastdependenciesbrowserlistietapeansies5bufferslengthextensions3mochaBigUint64ArraybatchpromisesArray.prototype.flatlockfileInt16ArrayfetchesautoscalingES2023viewfindLastslotdatastructuretelephoneforEachjoiecmascriptstarteroptiontoArrayECMAScript 2015es-shim APIsharedarraybufferemrpathRegExp.prototype.flagshelpercommandES2022reducestablewordwrapprettyio-tsreduxtoSortedtapSymbol.toStringTagoncesetsafejsonpathclientiteratesymlinkeslint-pluginbannerslicefunction.lengthtestnpmbindpreserve-symlinksnodeESnextdiffsqsinternalregexpeventsInt32ArrayArray.prototype.filterdomURLiamsymbolcommanderhigher-orderes7serializerangeerrorelbhttpsidleFloat64ArrayUint8ClampedArrayvalidobject$.extendduplexrandomcjksymlinksfull-widthmergecompilerArrayBufferfile cacheproxytostringtaginspectasciiarktypesortedmkdirpimportInt8ArrayfindupfindLastIndexscheme-validationes2016astrecursiveboundcensorcallbindcolorsworkspace:*typedarraycallbackargvkarmagroupenvironmentpromiseObject.definePropertyAsyncIteratorSymbolYAMLArray.prototype.containsStreamsinstrumentationtouchkeycoverageuuidasyncweakmappackagedeepcopyquoteemojinamestrimEndStyleSheetwrappostcss-pluginregular expressionsstringify
3.2.24

1 year ago

3.2.23

1 year ago

3.2.26

1 year ago

3.2.25

1 year ago

3.2.28

1 year ago

3.2.27

1 year ago

3.2.29

1 year ago

3.4.41

1 year ago

3.4.42

1 year ago

3.2.20

1 year ago

3.2.22

1 year ago

3.2.21

1 year ago

3.0.12

1 year ago

3.0.13

1 year ago

3.0.16

1 year ago

3.0.17

1 year ago

3.0.14

1 year ago

3.0.15

1 year ago

3.2.30

1 year ago

4.8.56

1 year ago

4.8.58

1 year ago

4.8.57

1 year ago

4.13.103

11 months ago

3.6.48

1 year ago

4.13.104

11 months ago

3.6.47

1 year ago

4.13.101

11 months ago

3.6.46

1 year ago

4.13.102

11 months ago

3.6.45

1 year ago

4.13.107

10 months ago

3.6.44

1 year ago

4.13.108

10 months ago

3.6.43

1 year ago

4.13.105

10 months ago

4.10.63

12 months ago

3.6.42

1 year ago

4.13.106

10 months ago

4.10.64

12 months ago

4.13.109

10 months ago

3.6.49

1 year ago

4.9.59

12 months ago

4.9.58

1 year ago

4.13.110

10 months ago

4.12.82

11 months ago

4.12.81

11 months ago

3.6.55

1 year ago

3.6.54

1 year ago

3.6.53

1 year ago

3.2.19

1 year ago

3.6.52

1 year ago

3.6.51

1 year ago

3.6.50

1 year ago

4.13.100

11 months ago

3.3.35

1 year ago

3.3.36

1 year ago

3.3.37

1 year ago

3.3.38

1 year ago

3.3.39

1 year ago

3.3.30

1 year ago

3.3.31

1 year ago

3.3.32

1 year ago

3.3.33

1 year ago

3.3.34

1 year ago

4.7.56

1 year ago

5.13.110

10 months ago

5.13.112

10 months ago

5.13.111

10 months ago

5.13.114

10 months ago

5.13.113

10 months ago

5.13.116

10 months ago

5.13.115

10 months ago

6.13.118

10 months ago

5.13.118

10 months ago

6.13.119

10 months ago

5.13.117

10 months ago

4.9.60

12 months ago

4.9.62

12 months ago

3.3.40

1 year ago

4.9.61

12 months ago

3.3.41

1 year ago

4.9.63

12 months ago

3.1.19

1 year ago

4.11.81

11 months ago

4.11.80

11 months ago

4.13.99

11 months ago

4.11.76

12 months ago

4.11.75

12 months ago

4.13.97

11 months ago

4.11.74

12 months ago

4.13.98

11 months ago

4.11.73

12 months ago

3.7.55

1 year ago

4.11.79

11 months ago

3.7.56

1 year ago

4.11.78

11 months ago

4.11.77

11 months ago

4.13.91

11 months ago

4.13.92

11 months ago

3.0.18

1 year ago

4.13.90

11 months ago

3.0.19

1 year ago

4.13.95

11 months ago

4.11.72

12 months ago

4.13.96

11 months ago

4.11.71

12 months ago

4.13.93

11 months ago

4.11.70

12 months ago

4.13.94

11 months ago

4.13.88

11 months ago

4.11.65

12 months ago

4.13.89

11 months ago

4.11.64

12 months ago

4.13.86

11 months ago

4.13.87

11 months ago

4.11.69

12 months ago

4.11.68

12 months ago

3.5.42

1 year ago

4.11.67

12 months ago

4.11.66

12 months ago

4.13.84

11 months ago

4.13.85

11 months ago

4.13.82

11 months ago

4.13.83

11 months ago

3.0.11

1 year ago

3.0.10

1 year ago

3.0.8

1 year ago

3.0.7

1 year ago

3.0.9

1 year ago

3.0.6

1 year ago

3.0.5

1 year ago

3.0.4

1 year ago

3.0.3

1 year ago

3.0.2

1 year ago

2.0.2

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago