Greasy Fork

Shined up real nice.

data-cache.js

A Map sub-class backed by a persistant store

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://greasyfork.org/scripts/31448-data-cache-js/code/data-cachejs.js?version=206062

Advertisement
Author
spiralx
Ratings
0 0 0
Version
1.0.0
Created
Updated
License
N/A
Applies to
All sites

Author's Description

data-cache.js

Example: Quick tester cache

For playing with in DevTools.

c = ((key, data) => {
  function getter() { console.info('getter(): %o', data); return data }
  function setter(value) { console.info('setter(%o)', value); data = value }

  return new DataCache({ getter, setter, debug: true })
})('test', { name: 'bob', items: ['foo', 'bar'] })
Example: User Script
const cache = new DataCache({
  getter: GM_getValue,
  setter: GM_setValue,
  key: 'repos'
})

cache.set('favourites', [ 'json-schema-faker/json-schema-faker', 'angular/angular', 'jquery/jquery' ])