1.0.0 • Published 1 year ago

@wemnyelezxnpm/nemo-accusamus-magnam v1.0.0

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

@wemnyelezxnpm/nemo-accusamus-magnam

A simple cache system for a single user request, built on the same concepts of data loader.

Install

npm i @wemnyelezxnpm/nemo-accusamus-magnam

Usage

const { Factory } = require('.')
const factory = new Factory()

factory.add('fetchSomething', {
  // cache by default, set to false to just do batching
  cache: true
}, async (queries, context) => {
  console.log(queries)
  // [ 42, 24 ]

  console.log(context)
  // { some: 'data' }

  return queries.map((k) => {
    return { k }
  })
})

async function run () {
  const context = {
    some: 'data'
  }
  const cache = factory.create(context)

  const p1 = cache.fetchSomething(42)
  const p2 = cache.fetchSomething(24)

  const res = await Promise.all([p1, p2])

  console.log(res)
  // [
  //   { k: 42 },
  //   { k: 24 }
  // ]
}

run().catch(console.log)

If the query parameter is an object, its cache key will be generated using safe-stable-stringify.

License

MIT

bundlingdiffpropertyArray.prototype.findLastIndexbabel-corextermdebugpoint-freemovedefaulttoobjectclassesinternaldescriptionReflect.getPrototypeOfdeleteframerbytehelpersutilitiesasyncES2023gradients css3colourshamstablebyteOffsetString.prototype.matchAllperformanceshebangdataviewparentsetPrototypeOfstreamsfetchformatspechookformstreams2watchcachehttpseast-asian-widthmobilesuperagentprotobufweaksetbindmakefstypedarraytoArraypropertiesstringmkdirpObjectreadvaluesSetkarmavaluewritableincludesposebootstrap lessArray.prototype.flatMapmacosrecursivetraversepasswordobjnested cssObject.isprivate dataObject.fromEntriesassertionwalkingefficient6to5chineseECMAScript 6reduxclass-validatorxdg-openperformantjses-abstractdotenvreact-testing-librarynpmECMAScript 2020moduleurltypanionflattencss lessUint16Arrayrandomprogressvariables in cssequalitycryptocopyArrayBuffer#sliceworkerjsonpathmergeclassnamescore-jshooksless compilerreduceSymbolpackage.jsonArray.prototype.flattenhigher-ordersignalsURLindicatortypeoffromfast-deep-clonewidthyamllesses-shim APIES2015errortoSortedlanguagetimeECMAScript 2017phoneauthenticationspinnersarrayshttpgetintrinsiccheckeditortc39variablesargumentstatusasciimatchlistenersopenseslint-plugin-0ECMAScript 2015yupdropoptimistloggertelephonemruinput__proto___.extendprototypeidlemimees2017ESnextelectrondeepcloneinstallersigintregular expressionsmime-dbreal-timemochapackageeslintconfigvestframeworkquerystringflatMapjson-schema-validationexpressesintrinsicObject.assignfastcloneopen[[Prototype]]ES
1.0.0

1 year ago