Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

redux-cache

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-cache - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

4

coverage/coverage-final.json
{"/Users/patrickgordon/sites/redux-cache/src/actions.ts": {"path":"/Users/patrickgordon/sites/redux-cache/src/actions.ts","statementMap":{"0":{"start":{"line":2,"column":0},"end":{"line":2,"column":62}},"1":{"start":{"line":3,"column":0},"end":{"line":3,"column":60}},"2":{"start":{"line":10,"column":0},"end":{"line":25,"column":2}},"3":{"start":{"line":11,"column":4},"end":{"line":11,"column":71}},"4":{"start":{"line":11,"column":43},"end":{"line":11,"column":69}},"5":{"start":{"line":13,"column":4},"end":{"line":15,"column":5}},"6":{"start":{"line":14,"column":8},"end":{"line":14,"column":40}},"7":{"start":{"line":16,"column":4},"end":{"line":18,"column":5}},"8":{"start":{"line":17,"column":8},"end":{"line":17,"column":42}},"9":{"start":{"line":19,"column":4},"end":{"line":24,"column":6}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":10,"column":26},"end":{"line":10,"column":27}},"loc":{"start":{"line":10,"column":58},"end":{"line":25,"column":1}},"line":10}},"branchMap":{"0":{"loc":{"start":{"line":11,"column":4},"end":{"line":11,"column":71}},"type":"if","locations":[{"start":{"line":11,"column":4},"end":{"line":11,"column":71}},{"start":{"line":11,"column":4},"end":{"line":11,"column":71}}],"line":11},"1":{"loc":{"start":{"line":13,"column":4},"end":{"line":15,"column":5}},"type":"if","locations":[{"start":{"line":13,"column":4},"end":{"line":15,"column":5}},{"start":{"line":13,"column":4},"end":{"line":15,"column":5}}],"line":13},"2":{"loc":{"start":{"line":16,"column":4},"end":{"line":18,"column":5}},"type":"if","locations":[{"start":{"line":16,"column":4},"end":{"line":18,"column":5}},{"start":{"line":16,"column":4},"end":{"line":18,"column":5}}],"line":16}},"s":{"0":2,"1":2,"2":2,"3":3,"4":1,"5":3,"6":2,"7":3,"8":1,"9":3},"f":{"0":3},"b":{"0":[1,2],"1":[2,1],"2":[1,2]},"inputSourceMap":{"version":3,"file":"actions.js","sourceRoot":"","sources":["actions.ts"],"names":[],"mappings":";;AAAa,QAAA,gBAAgB,GAAG,gCAAgC,CAAC;AASjE;;;;;GAKG;AACU,QAAA,eAAe,GAAG,UAAC,oBAA4C;IAA5C,qCAAA,EAAA,yBAA4C;IAC3E,IAAI,QAAQ,CAAC;IAEb,EAAE,CAAC,CAAC,oBAAoB,YAAY,KAAK,CAAC,CAAC,CAAC;QAC3C,QAAQ,GAAG,oBAAoB,CAAC;IACjC,CAAC;IAED,EAAE,CAAC,CAAC,OAAO,oBAAoB,KAAK,QAAQ,CAAC,CAAC,CAAC;QAC9C,QAAQ,GAAG,CAAC,oBAAoB,CAAC,CAAC;IACnC,CAAC;IAED,MAAM,CAAC;QACN,IAAI,EAAE,wBAAgB;QACtB,OAAO,EAAE;YACR,QAAQ,UAAA;SACR;KACD,CAAA;AACF,CAAC,CAAA","sourcesContent":["export const INVALIDATE_CACHE = \"@@redux-cache/INVALIDATE_CACHE\";\n\nexport interface InvalidateCacheAction {\n\ttype: string,\n\tpayload: {\n\t\treducers: string[]\n\t}\n}\n\n/**\n * This action can be used to invalidate the cache for a given array of reducers.\n * \n * @param {string[]} [reducersToInvalidate=[]] List of reducers to invalidate\n * @returns {InvalidateCacheAction}\n */\nexport const invalidateCache = (reducersToInvalidate: string[] | string = []): InvalidateCacheAction => {\n\tlet reducers;\n\n\tif (reducersToInvalidate instanceof Array) {\n\t\treducers = reducersToInvalidate;\n\t}\n\n\tif (typeof reducersToInvalidate === \"string\") {\n\t\treducers = [reducersToInvalidate];\n\t}\n\n\treturn {\n\t\ttype: INVALIDATE_CACHE,\n\t\tpayload: {\n\t\t\treducers\n\t\t}\n\t}\n}"]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"993ec08362b646eb622d633d00d2dce05de3c186"}
,"/Users/patrickgordon/sites/redux-cache/src/cacheEnhancer.ts": {"path":"/Users/patrickgordon/sites/redux-cache/src/cacheEnhancer.ts","statementMap":{"0":{"start":{"line":2,"column":15},"end":{"line":9,"column":1}},"1":{"start":{"line":3,"column":4},"end":{"line":7,"column":5}},"2":{"start":{"line":4,"column":8},"end":{"line":4,"column":25}},"3":{"start":{"line":5,"column":8},"end":{"line":6,"column":24}},"4":{"start":{"line":5,"column":25},"end":{"line":6,"column":24}},"5":{"start":{"line":6,"column":12},"end":{"line":6,"column":24}},"6":{"start":{"line":8,"column":4},"end":{"line":8,"column":13}},"7":{"start":{"line":10,"column":0},"end":{"line":10,"column":62}},"8":{"start":{"line":11,"column":18},"end":{"line":11,"column":40}},"9":{"start":{"line":12,"column":16},"end":{"line":12,"column":36}},"10":{"start":{"line":13,"column":16},"end":{"line":15,"column":1}},"11":{"start":{"line":14,"column":4},"end":{"line":14,"column":79}},"12":{"start":{"line":24,"column":0},"end":{"line":58,"column":2}},"13":{"start":{"line":25,"column":13},"end":{"line":25,"column":23}},"14":{"start":{"line":25,"column":31},"end":{"line":25,"column":57}},"15":{"start":{"line":26,"column":19},"end":{"line":26,"column":45}},"16":{"start":{"line":27,"column":20},"end":{"line":27,"column":41}},"17":{"start":{"line":29,"column":26},"end":{"line":35,"column":6}},"18":{"start":{"line":30,"column":23},"end":{"line":30,"column":59}},"19":{"start":{"line":31,"column":8},"end":{"line":33,"column":9}},"20":{"start":{"line":32,"column":12},"end":{"line":32,"column":91}},"21":{"start":{"line":34,"column":8},"end":{"line":34,"column":23}},"22":{"start":{"line":36,"column":4},"end":{"line":38,"column":5}},"23":{"start":{"line":37,"column":8},"end":{"line":37,"column":54}},"24":{"start":{"line":40,"column":31},"end":{"line":42,"column":6}},"25":{"start":{"line":41,"column":8},"end":{"line":41,"column":97}},"26":{"start":{"line":43,"column":4},"end":{"line":45,"column":5}},"27":{"start":{"line":44,"column":8},"end":{"line":44,"column":64}},"28":{"start":{"line":48,"column":4},"end":{"line":48,"column":114}},"29":{"start":{"line":48,"column":57},"end":{"line":48,"column":110}},"30":{"start":{"line":49,"column":4},"end":{"line":56,"column":5}},"31":{"start":{"line":50,"column":8},"end":{"line":55,"column":9}},"32":{"start":{"line":51,"column":12},"end":{"line":51,"column":140}},"33":{"start":{"line":54,"column":12},"end":{"line":54,"column":69}},"34":{"start":{"line":57,"column":4},"end":{"line":57,"column":20}},"35":{"start":{"line":59,"column":0},"end":{"line":67,"column":5}},"36":{"start":{"line":59,"column":51},"end":{"line":67,"column":2}},"37":{"start":{"line":60,"column":4},"end":{"line":62,"column":5}},"38":{"start":{"line":61,"column":8},"end":{"line":61,"column":38}},"39":{"start":{"line":63,"column":31},"end":{"line":63,"column":78}},"40":{"start":{"line":64,"column":23},"end":{"line":64,"column":45}},"41":{"start":{"line":65,"column":19},"end":{"line":65,"column":82}},"42":{"start":{"line":66,"column":4},"end":{"line":66,"column":20}},"43":{"start":{"line":74,"column":20},"end":{"line":82,"column":1}},"44":{"start":{"line":75,"column":4},"end":{"line":75,"column":43}},"45":{"start":{"line":75,"column":29},"end":{"line":75,"column":41}},"46":{"start":{"line":76,"column":4},"end":{"line":81,"column":9}},"47":{"start":{"line":76,"column":36},"end":{"line":81,"column":6}},"48":{"start":{"line":77,"column":20},"end":{"line":77,"column":97}},"49":{"start":{"line":78,"column":8},"end":{"line":80,"column":17}},"50":{"start":{"line":79,"column":16},"end":{"line":79,"column":82}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":2,"column":59},"end":{"line":2,"column":60}},"loc":{"start":{"line":2,"column":71},"end":{"line":9,"column":1}},"line":2},"1":{"name":"(anonymous_1)","decl":{"start":{"line":13,"column":16},"end":{"line":13,"column":17}},"loc":{"start":{"line":13,"column":39},"end":{"line":15,"column":1}},"line":13},"2":{"name":"(anonymous_2)","decl":{"start":{"line":24,"column":22},"end":{"line":24,"column":23}},"loc":{"start":{"line":24,"column":76},"end":{"line":58,"column":1}},"line":24},"3":{"name":"(anonymous_3)","decl":{"start":{"line":29,"column":54},"end":{"line":29,"column":55}},"loc":{"start":{"line":29,"column":76},"end":{"line":35,"column":5}},"line":29},"4":{"name":"(anonymous_4)","decl":{"start":{"line":40,"column":54},"end":{"line":40,"column":55}},"loc":{"start":{"line":40,"column":76},"end":{"line":42,"column":5}},"line":40},"5":{"name":"(anonymous_5)","decl":{"start":{"line":48,"column":33},"end":{"line":48,"column":34}},"loc":{"start":{"line":48,"column":55},"end":{"line":48,"column":112}},"line":48},"6":{"name":"(anonymous_6)","decl":{"start":{"line":59,"column":22},"end":{"line":59,"column":23}},"loc":{"start":{"line":59,"column":49},"end":{"line":67,"column":4}},"line":59},"7":{"name":"(anonymous_7)","decl":{"start":{"line":59,"column":58},"end":{"line":59,"column":59}},"loc":{"start":{"line":59,"column":83},"end":{"line":67,"column":1}},"line":59},"8":{"name":"(anonymous_8)","decl":{"start":{"line":74,"column":20},"end":{"line":74,"column":21}},"loc":{"start":{"line":74,"column":38},"end":{"line":82,"column":1}},"line":74},"9":{"name":"(anonymous_9)","decl":{"start":{"line":76,"column":11},"end":{"line":76,"column":12}},"loc":{"start":{"line":76,"column":34},"end":{"line":81,"column":8}},"line":76},"10":{"name":"(anonymous_10)","decl":{"start":{"line":76,"column":43},"end":{"line":76,"column":44}},"loc":{"start":{"line":76,"column":90},"end":{"line":81,"column":5}},"line":76},"11":{"name":"(anonymous_11)","decl":{"start":{"line":78,"column":53},"end":{"line":78,"column":54}},"loc":{"start":{"line":78,"column":72},"end":{"line":80,"column":13}},"line":78}},"branchMap":{"0":{"loc":{"start":{"line":2,"column":15},"end":{"line":9,"column":1}},"type":"binary-expr","locations":[{"start":{"line":2,"column":16},"end":{"line":2,"column":20}},{"start":{"line":2,"column":24},"end":{"line":2,"column":37}},{"start":{"line":2,"column":42},"end":{"line":2,"column":55}},{"start":{"line":2,"column":59},"end":{"line":9,"column":1}}],"line":2},"1":{"loc":{"start":{"line":5,"column":25},"end":{"line":6,"column":24}},"type":"if","locations":[{"start":{"line":5,"column":25},"end":{"line":6,"column":24}},{"start":{"line":5,"column":25},"end":{"line":6,"column":24}}],"line":5},"2":{"loc":{"start":{"line":14,"column":45},"end":{"line":14,"column":77}},"type":"binary-expr","locations":[{"start":{"line":14,"column":45},"end":{"line":14,"column":61}},{"start":{"line":14,"column":65},"end":{"line":14,"column":77}}],"line":14},"3":{"loc":{"start":{"line":25,"column":31},"end":{"line":25,"column":57}},"type":"cond-expr","locations":[{"start":{"line":25,"column":47},"end":{"line":25,"column":52}},{"start":{"line":25,"column":55},"end":{"line":25,"column":57}}],"line":25},"4":{"loc":{"start":{"line":31,"column":8},"end":{"line":33,"column":9}},"type":"if","locations":[{"start":{"line":31,"column":8},"end":{"line":33,"column":9}},{"start":{"line":31,"column":8},"end":{"line":33,"column":9}}],"line":31},"5":{"loc":{"start":{"line":31,"column":12},"end":{"line":31,"column":27}},"type":"binary-expr","locations":[{"start":{"line":31,"column":12},"end":{"line":31,"column":20}},{"start":{"line":31,"column":24},"end":{"line":31,"column":27}}],"line":31},"6":{"loc":{"start":{"line":36,"column":4},"end":{"line":38,"column":5}},"type":"if","locations":[{"start":{"line":36,"column":4},"end":{"line":38,"column":5}},{"start":{"line":36,"column":4},"end":{"line":38,"column":5}}],"line":36},"7":{"loc":{"start":{"line":41,"column":15},"end":{"line":41,"column":96}},"type":"binary-expr","locations":[{"start":{"line":41,"column":15},"end":{"line":41,"column":23}},{"start":{"line":41,"column":27},"end":{"line":41,"column":47}},{"start":{"line":41,"column":51},"end":{"line":41,"column":96}}],"line":41},"8":{"loc":{"start":{"line":43,"column":4},"end":{"line":45,"column":5}},"type":"if","locations":[{"start":{"line":43,"column":4},"end":{"line":45,"column":5}},{"start":{"line":43,"column":4},"end":{"line":45,"column":5}}],"line":43},"9":{"loc":{"start":{"line":49,"column":4},"end":{"line":56,"column":5}},"type":"if","locations":[{"start":{"line":49,"column":4},"end":{"line":56,"column":5}},{"start":{"line":49,"column":4},"end":{"line":56,"column":5}}],"line":49},"10":{"loc":{"start":{"line":50,"column":8},"end":{"line":55,"column":9}},"type":"if","locations":[{"start":{"line":50,"column":8},"end":{"line":55,"column":9}},{"start":{"line":50,"column":8},"end":{"line":55,"column":9}}],"line":50},"11":{"loc":{"start":{"line":60,"column":4},"end":{"line":62,"column":5}},"type":"if","locations":[{"start":{"line":60,"column":4},"end":{"line":62,"column":5}},{"start":{"line":60,"column":4},"end":{"line":62,"column":5}}],"line":60},"12":{"loc":{"start":{"line":63,"column":31},"end":{"line":63,"column":78}},"type":"binary-expr","locations":[{"start":{"line":63,"column":31},"end":{"line":63,"column":45}},{"start":{"line":63,"column":49},"end":{"line":63,"column":72}},{"start":{"line":63,"column":76},"end":{"line":63,"column":78}}],"line":63},"13":{"loc":{"start":{"line":75,"column":4},"end":{"line":75,"column":43}},"type":"if","locations":[{"start":{"line":75,"column":4},"end":{"line":75,"column":43}},{"start":{"line":75,"column":4},"end":{"line":75,"column":43}}],"line":75}},"s":{"0":1,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":1,"8":1,"9":1,"10":1,"11":0,"12":1,"13":4,"14":4,"15":4,"16":4,"17":4,"18":5,"19":5,"20":0,"21":5,"22":4,"23":0,"24":4,"25":4,"26":4,"27":0,"28":4,"29":3,"30":4,"31":0,"32":0,"33":0,"34":4,"35":1,"36":2,"37":2,"38":1,"39":1,"40":1,"41":1,"42":1,"43":1,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0},"f":{"0":0,"1":0,"2":4,"3":5,"4":4,"5":3,"6":2,"7":2,"8":0,"9":0,"10":0,"11":0},"b":{"0":[1,1,1,0],"1":[0,0],"2":[0,0],"3":[4,0],"4":[0,5],"5":[5,1],"6":[0,4],"7":[4,4,4],"8":[0,4],"9":[0,4],"10":[0,0],"11":[1,1],"12":[1,1,0],"13":[0,0]},"inputSourceMap":{"version":3,"file":"cacheEnhancer.js","sourceRoot":"","sources":["cacheEnhancer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A,WAAgC;IACtD,MAAM,CAAC,UAAC,WAAW,IAAK,OAAA,UAAC,WAAW,EAAE,YAAY,EAAE,QAAQ;QAC3D,IAAM,KAAK,GAAG,WAAW,CAAC,mBAAW,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;QAEpF,MAAM,cACF,KAAK,IACR,cAAc,EAAE,UAAC,OAAO;gBACvB,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,mBAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;YAC3D,CAAC,IACD;IACF,CAAC,EATuB,CASvB,CAAA;AACF,CAAC,CAAA","sourcesContent":["import { DEFAULT_KEY } from \"./constants\";\nimport { INVALIDATE_CACHE, InvalidateCacheAction } from \"./actions\";\n\nexport interface Store {\n\t[x: string]: any,\n\treplaceReducer: (reducer: () => State) => Function\n}\n\nexport interface State {\n\tDEFAULT_KEY?: number | null | undefined\n\t[x: string]: any,\n}\n\nexport interface CacheEnhancerConfig {\n\tlog?: boolean\n}\n\nconst logResult = (name: string, array: string[]): void => {\n\tconsole.log(\"redux-cache: %s: %s\", name, array.join(\", \") || \"none found\");\n};\n\n/**\n * // TODO: Add info here\n * \n * @param {string[]} reducersToInvalidate - List of reducers to invalidate\n * @param {object} currentState - The current and already reduced state.\n * @param {object} [config={}] - Configuration options\n * @param {boolean} [config.log=false] - Whether or not to output log information. Useful for debugging.\n */\nexport const updateState = (reducersToInvalidate, currentState, config) => {\n\tconst { log = false } = config;\n\tconst newState = { ...currentState };\n\tconst stateKeys = Object.keys(newState);\n\n\t// We filter to those reducers which exist in the application state tree\n\tconst matchedReducers = reducersToInvalidate.filter(reducerKey => {\n\t\tconst matched = (stateKeys.indexOf(reducerKey) !== -1);\n\t\tif (!matched && log) { console.log(\"redux-cache: did not match %s reducer to state tree\", reducerKey); }\n\t\treturn matched;\n\t});\n\tif (log) { logResult(\"matchedReducers\", matchedReducers); }\n\n\t// We filter those existing reducers down to those which actually have a the cache key.\n\tconst cacheEnabledReducers = matchedReducers.filter(reducerKey => {\n\t\treturn newState && newState[reducerKey] && newState[reducerKey][DEFAULT_KEY];\n\t});\n\tif (log) { logResult(\"cacheEnabledReducers\", cacheEnabledReducers); }\n\n\t// We are invalidating the cached reducers by setting the value for the cache key to null.\n\t// Don't fret -- they'll get a new and improved value for the cache key again when the successful action comes through.\n\tcacheEnabledReducers.forEach(reducerKey => { newState[reducerKey][DEFAULT_KEY] = null; });\n\tif (log) {\n\t\tif (cacheEnabledReducers.length > 0) {\n\t\t\tconsole.log(\"redux-cache: Set %s to null for following reducers: %s\", DEFAULT_KEY, cacheEnabledReducers.join(\", \"));\n\t\t} else {\n\t\t\tconsole.log(\"redux-cache: No cached reducers to update\");\n\t\t}\n\t}\n\n\treturn newState;\n};\n\nexport const liftReducer = (reducer, config) => (state, action) => {\n\tif (action.type !== INVALIDATE_CACHE) {\n\t\treturn reducer(state, action);\n\t}\n\n\tconst reducersToInvalidate = action.payload && action.payload.reducers || [];\n\tconst currentState = reducer(state, action);\n\tconst newState = updateState(reducersToInvalidate, currentState, config);\n\n\treturn newState;\n}\n\n/**\n * // TODO: add info here\n * \n * @param config \n * @returns {Object} - returns the enhanced store\n */\nconst cacheEnhancer = (config: CacheEnhancerConfig = {}) => {\n\treturn (createStore) => (rootReducer, initialState, enhancer) => {\n\t\tconst store = createStore(liftReducer(rootReducer, config), initialState, enhancer);\n\n\t\treturn { \n\t\t\t...store,\n\t\t\treplaceReducer: (reducer) => {\n\t\t\t\treturn store.replaceReducer(liftReducer(reducer, config));\n\t\t\t}\n\t\t}\n\t}\n}"]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"f9524ae34d7cc54f745e1bb456d88b7dad0e319c"}
,"/Users/patrickgordon/sites/redux-cache/src/checkCacheValid.ts": {"path":"/Users/patrickgordon/sites/redux-cache/src/checkCacheValid.ts","statementMap":{"0":{"start":{"line":2,"column":0},"end":{"line":2,"column":62}},"1":{"start":{"line":3,"column":18},"end":{"line":3,"column":40}},"2":{"start":{"line":11,"column":0},"end":{"line":23,"column":2}},"3":{"start":{"line":12,"column":4},"end":{"line":12,"column":68}},"4":{"start":{"line":12,"column":31},"end":{"line":12,"column":66}},"5":{"start":{"line":13,"column":16},"end":{"line":13,"column":26}},"6":{"start":{"line":14,"column":21},"end":{"line":14,"column":36}},"7":{"start":{"line":15,"column":4},"end":{"line":17,"column":5}},"8":{"start":{"line":16,"column":8},"end":{"line":16,"column":21}},"9":{"start":{"line":18,"column":22},"end":{"line":18,"column":32}},"10":{"start":{"line":19,"column":4},"end":{"line":21,"column":5}},"11":{"start":{"line":20,"column":8},"end":{"line":20,"column":20}},"12":{"start":{"line":22,"column":4},"end":{"line":22,"column":17}},"13":{"start":{"line":24,"column":0},"end":{"line":24,"column":42}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":11,"column":26},"end":{"line":11,"column":27}},"loc":{"start":{"line":11,"column":56},"end":{"line":23,"column":1}},"line":11}},"branchMap":{"0":{"loc":{"start":{"line":12,"column":4},"end":{"line":12,"column":68}},"type":"if","locations":[{"start":{"line":12,"column":4},"end":{"line":12,"column":68}},{"start":{"line":12,"column":4},"end":{"line":12,"column":68}}],"line":12},"1":{"loc":{"start":{"line":15,"column":4},"end":{"line":17,"column":5}},"type":"if","locations":[{"start":{"line":15,"column":4},"end":{"line":17,"column":5}},{"start":{"line":15,"column":4},"end":{"line":17,"column":5}}],"line":15},"2":{"loc":{"start":{"line":19,"column":4},"end":{"line":21,"column":5}},"type":"if","locations":[{"start":{"line":19,"column":4},"end":{"line":21,"column":5}},{"start":{"line":19,"column":4},"end":{"line":21,"column":5}}],"line":19}},"s":{"0":1,"1":1,"2":1,"3":6,"4":4,"5":6,"6":6,"7":6,"8":2,"9":4,"10":4,"11":3,"12":1,"13":1},"f":{"0":6},"b":{"0":[4,2],"1":[2,4],"2":[3,1]},"inputSourceMap":{"version":3,"file":"checkCacheValid.js","sourceRoot":"","sources":["checkCacheValid.ts"],"names":[],"mappings":";;AAAA,yCAA0C;AAO1C;;;;;;GAMG;AACU,QAAA,eAAe,GAAG,UAAC,QAAqB,EAAE,QAA8B;IAA9B,yBAAA,EAAA,WAAmB,uBAAW;IACpF,IAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IACzB,IAAM,UAAU,GAAW,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC3C,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;QACjB,MAAM,CAAC,KAAK,CAAA;IACb,CAAC;IAED,IAAM,WAAW,GAAW,IAAI,CAAC,GAAG,EAAE,CAAC;IACvC,EAAE,CAAC,CAAC,UAAU,GAAG,WAAW,CAAC,CAAC,CAAC;QAC9B,MAAM,CAAC,IAAI,CAAA;IACZ,CAAC;IAED,MAAM,CAAC,KAAK,CAAC;AAEd,CAAC,CAAC;AAEF,kBAAe,uBAAe,CAAC","sourcesContent":["import { DEFAULT_KEY } from \"./constants\";\n\nexport interface State {\n\tDEFAULT_KEY?: number | null | undefined,\n\t[x: string]: any\n}\n\n/**\n * Checks if the cache TTL is still valid.\n * \n * @param {function} getState \n * @param {string} [cacheKey=DEFAULT_KEY]\n * @returns {boolean}\n */\nexport const checkCacheValid = (getState: () => State, cacheKey: string = DEFAULT_KEY): boolean => {\n\tconst state = getState();\n\tconst cacheUntil: number = state[cacheKey];\n\tif (!cacheUntil) {\n\t\treturn false\n\t}\n\n\tconst currentTime: number = Date.now();\n\tif (cacheUntil > currentTime) {\n\t\treturn true\n\t}\n\n\treturn false;\n\n};\n\nexport default checkCacheValid;"]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"ddfaa953bd96d04ebfa26429bfe70072ff217ae2"}
,"/Users/patrickgordon/sites/redux-cache/src/cacheEnhancer.ts": {"path":"/Users/patrickgordon/sites/redux-cache/src/cacheEnhancer.ts","statementMap":{"0":{"start":{"line":2,"column":15},"end":{"line":9,"column":1}},"1":{"start":{"line":3,"column":4},"end":{"line":7,"column":5}},"2":{"start":{"line":4,"column":8},"end":{"line":4,"column":25}},"3":{"start":{"line":5,"column":8},"end":{"line":6,"column":24}},"4":{"start":{"line":5,"column":25},"end":{"line":6,"column":24}},"5":{"start":{"line":6,"column":12},"end":{"line":6,"column":24}},"6":{"start":{"line":8,"column":4},"end":{"line":8,"column":13}},"7":{"start":{"line":10,"column":0},"end":{"line":10,"column":62}},"8":{"start":{"line":11,"column":18},"end":{"line":11,"column":40}},"9":{"start":{"line":12,"column":16},"end":{"line":12,"column":36}},"10":{"start":{"line":13,"column":16},"end":{"line":15,"column":1}},"11":{"start":{"line":14,"column":4},"end":{"line":14,"column":79}},"12":{"start":{"line":26,"column":0},"end":{"line":60,"column":2}},"13":{"start":{"line":27,"column":13},"end":{"line":27,"column":23}},"14":{"start":{"line":27,"column":31},"end":{"line":27,"column":57}},"15":{"start":{"line":27,"column":64},"end":{"line":27,"column":79}},"16":{"start":{"line":27,"column":92},"end":{"line":27,"column":136}},"17":{"start":{"line":28,"column":19},"end":{"line":28,"column":45}},"18":{"start":{"line":29,"column":20},"end":{"line":29,"column":41}},"19":{"start":{"line":31,"column":26},"end":{"line":37,"column":6}},"20":{"start":{"line":32,"column":23},"end":{"line":32,"column":59}},"21":{"start":{"line":33,"column":8},"end":{"line":35,"column":9}},"22":{"start":{"line":34,"column":12},"end":{"line":34,"column":91}},"23":{"start":{"line":36,"column":8},"end":{"line":36,"column":23}},"24":{"start":{"line":38,"column":4},"end":{"line":40,"column":5}},"25":{"start":{"line":39,"column":8},"end":{"line":39,"column":54}},"26":{"start":{"line":42,"column":31},"end":{"line":44,"column":6}},"27":{"start":{"line":43,"column":8},"end":{"line":43,"column":82}},"28":{"start":{"line":45,"column":4},"end":{"line":47,"column":5}},"29":{"start":{"line":46,"column":8},"end":{"line":46,"column":64}},"30":{"start":{"line":50,"column":4},"end":{"line":50,"column":99}},"31":{"start":{"line":50,"column":57},"end":{"line":50,"column":95}},"32":{"start":{"line":51,"column":4},"end":{"line":58,"column":5}},"33":{"start":{"line":52,"column":8},"end":{"line":57,"column":9}},"34":{"start":{"line":53,"column":12},"end":{"line":53,"column":125}},"35":{"start":{"line":56,"column":12},"end":{"line":56,"column":69}},"36":{"start":{"line":59,"column":4},"end":{"line":59,"column":20}},"37":{"start":{"line":61,"column":0},"end":{"line":69,"column":5}},"38":{"start":{"line":61,"column":51},"end":{"line":69,"column":2}},"39":{"start":{"line":62,"column":4},"end":{"line":64,"column":5}},"40":{"start":{"line":63,"column":8},"end":{"line":63,"column":38}},"41":{"start":{"line":65,"column":31},"end":{"line":65,"column":78}},"42":{"start":{"line":66,"column":23},"end":{"line":66,"column":45}},"43":{"start":{"line":67,"column":19},"end":{"line":67,"column":82}},"44":{"start":{"line":68,"column":4},"end":{"line":68,"column":20}},"45":{"start":{"line":76,"column":0},"end":{"line":84,"column":2}},"46":{"start":{"line":77,"column":4},"end":{"line":77,"column":43}},"47":{"start":{"line":77,"column":29},"end":{"line":77,"column":41}},"48":{"start":{"line":78,"column":4},"end":{"line":83,"column":9}},"49":{"start":{"line":78,"column":36},"end":{"line":83,"column":6}},"50":{"start":{"line":79,"column":20},"end":{"line":79,"column":97}},"51":{"start":{"line":80,"column":8},"end":{"line":82,"column":17}},"52":{"start":{"line":81,"column":16},"end":{"line":81,"column":82}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":2,"column":59},"end":{"line":2,"column":60}},"loc":{"start":{"line":2,"column":71},"end":{"line":9,"column":1}},"line":2},"1":{"name":"(anonymous_1)","decl":{"start":{"line":13,"column":16},"end":{"line":13,"column":17}},"loc":{"start":{"line":13,"column":39},"end":{"line":15,"column":1}},"line":13},"2":{"name":"(anonymous_2)","decl":{"start":{"line":26,"column":22},"end":{"line":26,"column":23}},"loc":{"start":{"line":26,"column":76},"end":{"line":60,"column":1}},"line":26},"3":{"name":"(anonymous_3)","decl":{"start":{"line":31,"column":54},"end":{"line":31,"column":55}},"loc":{"start":{"line":31,"column":76},"end":{"line":37,"column":5}},"line":31},"4":{"name":"(anonymous_4)","decl":{"start":{"line":42,"column":54},"end":{"line":42,"column":55}},"loc":{"start":{"line":42,"column":76},"end":{"line":44,"column":5}},"line":42},"5":{"name":"(anonymous_5)","decl":{"start":{"line":50,"column":33},"end":{"line":50,"column":34}},"loc":{"start":{"line":50,"column":55},"end":{"line":50,"column":97}},"line":50},"6":{"name":"(anonymous_6)","decl":{"start":{"line":61,"column":22},"end":{"line":61,"column":23}},"loc":{"start":{"line":61,"column":49},"end":{"line":69,"column":4}},"line":61},"7":{"name":"(anonymous_7)","decl":{"start":{"line":61,"column":58},"end":{"line":61,"column":59}},"loc":{"start":{"line":61,"column":83},"end":{"line":69,"column":1}},"line":61},"8":{"name":"(anonymous_8)","decl":{"start":{"line":76,"column":24},"end":{"line":76,"column":25}},"loc":{"start":{"line":76,"column":42},"end":{"line":84,"column":1}},"line":76},"9":{"name":"(anonymous_9)","decl":{"start":{"line":78,"column":11},"end":{"line":78,"column":12}},"loc":{"start":{"line":78,"column":34},"end":{"line":83,"column":8}},"line":78},"10":{"name":"(anonymous_10)","decl":{"start":{"line":78,"column":43},"end":{"line":78,"column":44}},"loc":{"start":{"line":78,"column":90},"end":{"line":83,"column":5}},"line":78},"11":{"name":"(anonymous_11)","decl":{"start":{"line":80,"column":53},"end":{"line":80,"column":54}},"loc":{"start":{"line":80,"column":72},"end":{"line":82,"column":13}},"line":80}},"branchMap":{"0":{"loc":{"start":{"line":2,"column":15},"end":{"line":9,"column":1}},"type":"binary-expr","locations":[{"start":{"line":2,"column":16},"end":{"line":2,"column":20}},{"start":{"line":2,"column":24},"end":{"line":2,"column":37}},{"start":{"line":2,"column":42},"end":{"line":2,"column":55}},{"start":{"line":2,"column":59},"end":{"line":9,"column":1}}],"line":2},"1":{"loc":{"start":{"line":5,"column":25},"end":{"line":6,"column":24}},"type":"if","locations":[{"start":{"line":5,"column":25},"end":{"line":6,"column":24}},{"start":{"line":5,"column":25},"end":{"line":6,"column":24}}],"line":5},"2":{"loc":{"start":{"line":14,"column":45},"end":{"line":14,"column":77}},"type":"binary-expr","locations":[{"start":{"line":14,"column":45},"end":{"line":14,"column":61}},{"start":{"line":14,"column":65},"end":{"line":14,"column":77}}],"line":14},"3":{"loc":{"start":{"line":27,"column":31},"end":{"line":27,"column":57}},"type":"cond-expr","locations":[{"start":{"line":27,"column":47},"end":{"line":27,"column":52}},{"start":{"line":27,"column":55},"end":{"line":27,"column":57}}],"line":27},"4":{"loc":{"start":{"line":27,"column":92},"end":{"line":27,"column":136}},"type":"cond-expr","locations":[{"start":{"line":27,"column":108},"end":{"line":27,"column":131}},{"start":{"line":27,"column":134},"end":{"line":27,"column":136}}],"line":27},"5":{"loc":{"start":{"line":33,"column":8},"end":{"line":35,"column":9}},"type":"if","locations":[{"start":{"line":33,"column":8},"end":{"line":35,"column":9}},{"start":{"line":33,"column":8},"end":{"line":35,"column":9}}],"line":33},"6":{"loc":{"start":{"line":33,"column":12},"end":{"line":33,"column":27}},"type":"binary-expr","locations":[{"start":{"line":33,"column":12},"end":{"line":33,"column":20}},{"start":{"line":33,"column":24},"end":{"line":33,"column":27}}],"line":33},"7":{"loc":{"start":{"line":38,"column":4},"end":{"line":40,"column":5}},"type":"if","locations":[{"start":{"line":38,"column":4},"end":{"line":40,"column":5}},{"start":{"line":38,"column":4},"end":{"line":40,"column":5}}],"line":38},"8":{"loc":{"start":{"line":43,"column":15},"end":{"line":43,"column":81}},"type":"binary-expr","locations":[{"start":{"line":43,"column":15},"end":{"line":43,"column":23}},{"start":{"line":43,"column":27},"end":{"line":43,"column":47}},{"start":{"line":43,"column":51},"end":{"line":43,"column":81}}],"line":43},"9":{"loc":{"start":{"line":45,"column":4},"end":{"line":47,"column":5}},"type":"if","locations":[{"start":{"line":45,"column":4},"end":{"line":47,"column":5}},{"start":{"line":45,"column":4},"end":{"line":47,"column":5}}],"line":45},"10":{"loc":{"start":{"line":51,"column":4},"end":{"line":58,"column":5}},"type":"if","locations":[{"start":{"line":51,"column":4},"end":{"line":58,"column":5}},{"start":{"line":51,"column":4},"end":{"line":58,"column":5}}],"line":51},"11":{"loc":{"start":{"line":52,"column":8},"end":{"line":57,"column":9}},"type":"if","locations":[{"start":{"line":52,"column":8},"end":{"line":57,"column":9}},{"start":{"line":52,"column":8},"end":{"line":57,"column":9}}],"line":52},"12":{"loc":{"start":{"line":62,"column":4},"end":{"line":64,"column":5}},"type":"if","locations":[{"start":{"line":62,"column":4},"end":{"line":64,"column":5}},{"start":{"line":62,"column":4},"end":{"line":64,"column":5}}],"line":62},"13":{"loc":{"start":{"line":65,"column":31},"end":{"line":65,"column":78}},"type":"binary-expr","locations":[{"start":{"line":65,"column":31},"end":{"line":65,"column":45}},{"start":{"line":65,"column":49},"end":{"line":65,"column":72}},{"start":{"line":65,"column":76},"end":{"line":65,"column":78}}],"line":65},"14":{"loc":{"start":{"line":77,"column":4},"end":{"line":77,"column":43}},"type":"if","locations":[{"start":{"line":77,"column":4},"end":{"line":77,"column":43}},{"start":{"line":77,"column":4},"end":{"line":77,"column":43}}],"line":77}},"s":{"0":1,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":1,"8":1,"9":1,"10":1,"11":0,"12":1,"13":5,"14":5,"15":5,"16":5,"17":5,"18":5,"19":5,"20":6,"21":6,"22":0,"23":6,"24":5,"25":0,"26":5,"27":5,"28":5,"29":0,"30":5,"31":4,"32":5,"33":0,"34":0,"35":0,"36":5,"37":1,"38":2,"39":2,"40":1,"41":1,"42":1,"43":1,"44":1,"45":1,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0},"f":{"0":0,"1":0,"2":5,"3":6,"4":5,"5":4,"6":2,"7":2,"8":0,"9":0,"10":0,"11":0},"b":{"0":[1,1,1,0],"1":[0,0],"2":[0,0],"3":[5,0],"4":[4,1],"5":[0,6],"6":[6,1],"7":[0,5],"8":[5,5,5],"9":[0,5],"10":[0,5],"11":[0,0],"12":[1,1],"13":[1,1,0],"14":[0,0]},"input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+C,CAU/C,CAAA;AAED;;;;;GAKG;AACU,QAAA,aAAa,GAAG,UAAC,MAAgC;IAAhC,uBAAA,EAAA,WAAgC;IAC7D,MAAM,CAAC,UAAC,WAAW,IAAK,OAAA,UAAC,WAAW,EAAE,YAAY,EAAE,QAAQ;QAC3D,IAAM,KAAK,GAAG,WAAW,CAAC,mBAAW,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;QAEpF,MAAM,cACF,KAAK,IACR,cAAc,EAAE,UAAC,OAAO;gBACvB,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,mBAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;YAC3D,CAAC,IACD;IACF,CAAC,EATuB,CASvB,CAAA;AACF,CAAC,CAAA","sourcesContent":["import { DEFAULT_KEY } from \"./constants\";\nimport { INVALIDATE_CACHE, InvalidateCacheAction } from \"./actions\";\n\nexport interface Store {\n\t[x: string]: any,\n\treplaceReducer: (reducer: () => State) => Function\n}\n\nexport interface State {\n\tDEFAULT_KEY?: number | null | undefined,\n\t[x: string]: any\n}\n\nexport interface CacheEnhancerConfig {\n\tlog?: boolean,\n\tcacheKey?: string\n}\n\nconst logResult = (name: string, array: string[]): void => {\n\tconsole.log(\"redux-cache: %s: %s\", name, array.join(\", \") || \"none found\");\n};\n\n/**\n * This fn will handle invalidating the reducers you specify. It returns the updated state with the cache\n * values set to null.\n * \n * @param {string[]} reducersToInvalidate - List of reducers to invalidate\n * @param {object} currentState - The current and already reduced state.\n * @param {object} [config={}] - Configuration options\n * @param {boolean} [config.log=false] - Whether or not to output log information. Useful for debugging.\n * @param {string} [config.cacheKey=DEFAULT_KEY] - The cache key to use instead of the DEFAULT_KEY\n */\nexport const updateState = (reducersToInvalidate, currentState, config) => {\n\tconst { log = false, cacheKey = DEFAULT_KEY } = config;\n\tconst newState = { ...currentState };\n\tconst stateKeys = Object.keys(newState);\n\n\t// We filter to those reducers which exist in the application state tree\n\tconst matchedReducers = reducersToInvalidate.filter(reducerKey => {\n\t\tconst matched = (stateKeys.indexOf(reducerKey) !== -1);\n\t\tif (!matched && log) { console.log(\"redux-cache: did not match %s reducer to state tree\", reducerKey); }\n\t\treturn matched;\n\t});\n\tif (log) { logResult(\"matchedReducers\", matchedReducers); }\n\n\t// We filter those existing reducers down to those which actually have a the cache key.\n\tconst cacheEnabledReducers = matchedReducers.filter(reducerKey => {\n\t\treturn newState && newState[reducerKey] && newState[reducerKey][cacheKey];\n\t});\n\tif (log) { logResult(\"cacheEnabledReducers\", cacheEnabledReducers); }\n\n\t// We are invalidating the cached reducers by setting the value for the cache key to null.\n\t// Don't fret -- they'll get a new and improved value for the cache key again when the successful action comes through.\n\tcacheEnabledReducers.forEach(reducerKey => { newState[reducerKey][cacheKey] = null; });\n\tif (log) {\n\t\tif (cacheEnabledReducers.length > 0) {\n\t\t\tconsole.log(\"redux-cache: Set %s to null for following reducers: %s\", cacheKey, cacheEnabledReducers.join(\", \"));\n\t\t} else {\n\t\t\tconsole.log(\"redux-cache: No cached reducers to update\");\n\t\t}\n\t}\n\n\treturn newState;\n};\n\nexport const liftReducer = (reducer, config) => (state, action) => {\n\tif (action.type !== INVALIDATE_CACHE) {\n\t\treturn reducer(state, action);\n\t}\n\n\tconst reducersToInvalidate = action.payload && action.payload.reducers || [];\n\tconst currentState = reducer(state, action);\n\tconst newState = updateState(reducersToInvalidate, currentState, config);\n\n\treturn newState;\n}\n\n/**\n * This is the store enhancer that you will add when you configureStore.\n * \n * @param {CacheEnhancerConfig} [config={}]\n * @returns {Object} - returns the enhanced store\n */\nexport const cacheEnhancer = (config: CacheEnhancerConfig = {}) => {\n\treturn (createStore) => (rootReducer, initialState, enhancer) => {\n\t\tconst store = createStore(liftReducer(rootReducer, config), initialState, enhancer);\n\n\t\treturn { \n\t\t\t...store,\n\t\t\treplaceReducer: (reducer) => {\n\t\t\t\treturn store.replaceReducer(liftReducer(reducer, config));\n\t\t\t}\n\t\t}\n\t}\n}"]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"cb717a5dd6cd0bc836abc5ba31874d78d9c56c1c"}
,"/Users/patrickgordon/sites/redux-cache/src/checkCacheValid.ts": {"path":"/Users/patrickgordon/sites/redux-cache/src/checkCacheValid.ts","statementMap":{"0":{"start":{"line":2,"column":0},"end":{"line":2,"column":62}},"1":{"start":{"line":3,"column":18},"end":{"line":3,"column":40}},"2":{"start":{"line":12,"column":0},"end":{"line":24,"column":2}},"3":{"start":{"line":13,"column":4},"end":{"line":13,"column":68}},"4":{"start":{"line":13,"column":31},"end":{"line":13,"column":66}},"5":{"start":{"line":14,"column":16},"end":{"line":14,"column":26}},"6":{"start":{"line":15,"column":21},"end":{"line":15,"column":78}},"7":{"start":{"line":16,"column":4},"end":{"line":18,"column":5}},"8":{"start":{"line":17,"column":8},"end":{"line":17,"column":21}},"9":{"start":{"line":19,"column":22},"end":{"line":19,"column":32}},"10":{"start":{"line":20,"column":4},"end":{"line":22,"column":5}},"11":{"start":{"line":21,"column":8},"end":{"line":21,"column":20}},"12":{"start":{"line":23,"column":4},"end":{"line":23,"column":17}},"13":{"start":{"line":25,"column":0},"end":{"line":25,"column":42}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":12,"column":26},"end":{"line":12,"column":27}},"loc":{"start":{"line":12,"column":68},"end":{"line":24,"column":1}},"line":12}},"branchMap":{"0":{"loc":{"start":{"line":13,"column":4},"end":{"line":13,"column":68}},"type":"if","locations":[{"start":{"line":13,"column":4},"end":{"line":13,"column":68}},{"start":{"line":13,"column":4},"end":{"line":13,"column":68}}],"line":13},"1":{"loc":{"start":{"line":15,"column":21},"end":{"line":15,"column":78}},"type":"binary-expr","locations":[{"start":{"line":15,"column":21},"end":{"line":15,"column":26}},{"start":{"line":15,"column":30},"end":{"line":15,"column":47}},{"start":{"line":15,"column":51},"end":{"line":15,"column":78}}],"line":15},"2":{"loc":{"start":{"line":16,"column":4},"end":{"line":18,"column":5}},"type":"if","locations":[{"start":{"line":16,"column":4},"end":{"line":18,"column":5}},{"start":{"line":16,"column":4},"end":{"line":18,"column":5}}],"line":16},"3":{"loc":{"start":{"line":20,"column":4},"end":{"line":22,"column":5}},"type":"if","locations":[{"start":{"line":20,"column":4},"end":{"line":22,"column":5}},{"start":{"line":20,"column":4},"end":{"line":22,"column":5}}],"line":20}},"s":{"0":1,"1":1,"2":1,"3":5,"4":4,"5":5,"6":5,"7":5,"8":2,"9":3,"10":3,"11":2,"12":1,"13":1},"f":{"0":5},"b":{"0":[4,1],"1":[5,5,5],"2":[2,3],"3":[2,1]},"inputSourceMap":{"version":3,"file":"checkCacheValid.js","sourceRoot":"","sources":["checkCacheValid.ts"],"names":[],"mappings":";;AAAA,yCAA0C;AAO1C;;;;;;;GAOG;AACU,QAAA,eAAe,GAAG,UAAC,QAAqB,EAAE,UAAkB,EAAE,QAA8B;IAA9B,yBAAA,EAAA,WAAmB,uBAAW;IACxG,IAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IACzB,IAAM,UAAU,GAAW,KAAK,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,CAAC;IACrF,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;QACjB,MAAM,CAAC,KAAK,CAAA;IACb,CAAC;IAED,IAAM,WAAW,GAAW,IAAI,CAAC,GAAG,EAAE,CAAC;IACvC,EAAE,CAAC,CAAC,UAAU,GAAG,WAAW,CAAC,CAAC,CAAC;QAC9B,MAAM,CAAC,IAAI,CAAA;IACZ,CAAC;IAED,MAAM,CAAC,KAAK,CAAC;AAEd,CAAC,CAAC;AAEF,kBAAe,uBAAe,CAAC","sourcesContent":["import { DEFAULT_KEY } from \"./constants\";\n\nexport interface State {\n\tDEFAULT_KEY?: number | null | undefined,\n\t[x: string]: any\n}\n\n/**\n * Checks if the cache TTL is still valid.\n * \n * @param {function} getState \n * @param {string} reducerKey\n * @param {string} [cacheKey=DEFAULT_KEY]\n * @returns {boolean}\n */\nexport const checkCacheValid = (getState: () => State, reducerKey: string, cacheKey: string = DEFAULT_KEY): boolean => {\n\tconst state = getState();\n\tconst cacheUntil: number = state && state[reducerKey] && state[reducerKey][cacheKey];\n\tif (!cacheUntil) {\n\t\treturn false\n\t}\n\n\tconst currentTime: number = Date.now();\n\tif (cacheUntil > currentTime) {\n\t\treturn true\n\t}\n\n\treturn false;\n\n};\n\nexport default checkCacheValid;"]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"e109245ddf7ab4abd0fd30907c90b9b64419ce6a"}
,"/Users/patrickgordon/sites/redux-cache/src/constants.ts": {"path":"/Users/patrickgordon/sites/redux-cache/src/constants.ts","statementMap":{"0":{"start":{"line":2,"column":0},"end":{"line":2,"column":62}},"1":{"start":{"line":3,"column":0},"end":{"line":3,"column":37}},"2":{"start":{"line":4,"column":0},"end":{"line":4,"column":35}}},"fnMap":{},"branchMap":{},"s":{"0":3,"1":3,"2":3},"f":{},"b":{},"inputSourceMap":{"version":3,"file":"constants.js","sourceRoot":"","sources":["constants.ts"],"names":[],"mappings":";;AAAW,QAAA,mBAAmB,GAAW,MAAM,CAAC;AACrC,QAAA,WAAW,GAAW,YAAY,CAAC","sourcesContent":["export var DEFAULT_DURATION_MS: number = 600000;\nexport var DEFAULT_KEY: string = \"cacheUntil\";"]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"7d0a4d56d5fca48e6cfbfd49471807c418fa4dfa"}
,"/Users/patrickgordon/sites/redux-cache/src/generateCacheTTL.ts": {"path":"/Users/patrickgordon/sites/redux-cache/src/generateCacheTTL.ts","statementMap":{"0":{"start":{"line":2,"column":0},"end":{"line":2,"column":62}},"1":{"start":{"line":3,"column":18},"end":{"line":3,"column":40}},"2":{"start":{"line":10,"column":0},"end":{"line":13,"column":2}},"3":{"start":{"line":11,"column":4},"end":{"line":11,"column":76}},"4":{"start":{"line":11,"column":31},"end":{"line":11,"column":74}},"5":{"start":{"line":12,"column":4},"end":{"line":12,"column":33}},"6":{"start":{"line":14,"column":0},"end":{"line":14,"column":43}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":10,"column":27},"end":{"line":10,"column":28}},"loc":{"start":{"line":10,"column":47},"end":{"line":13,"column":1}},"line":10}},"branchMap":{"0":{"loc":{"start":{"line":11,"column":4},"end":{"line":11,"column":76}},"type":"if","locations":[{"start":{"line":11,"column":4},"end":{"line":11,"column":76}},{"start":{"line":11,"column":4},"end":{"line":11,"column":76}}],"line":11}},"s":{"0":1,"1":1,"2":1,"3":2,"4":1,"5":2,"6":1},"f":{"0":2},"b":{"0":[1,1]},"inputSourceMap":{"version":3,"file":"generateCacheTTL.js","sourceRoot":"","sources":["generateCacheTTL.ts"],"names":[],"mappings":";;AAAA,yCAAkD;AAElD;;;;;GAKG;AACU,QAAA,gBAAgB,GAAG,UAAC,QAAsC;IAAtC,yBAAA,EAAA,WAAmB,+BAAmB;IACtE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAC;AAC9B,CAAC,CAAA;AAED,kBAAe,wBAAgB,CAAC","sourcesContent":["import { DEFAULT_DURATION_MS } from \"./constants\";\n\n/**\n * Generates a unix timestamp in milliseconds\n * \n * @param {number} [duration=DEFAULT_DURATION_MS] \n * @returns {number}\n */\nexport const generateCacheTTL = (duration: number = DEFAULT_DURATION_MS): number => {\n\treturn Date.now() + duration;\n}\n\nexport default generateCacheTTL;"]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"503511e111ee41758f4b46eade65443b81b05030"}
}

@@ -9,6 +9,7 @@ export interface State {

* @param {function} getState
* @param {string} reducerKey
* @param {string} [cacheKey=DEFAULT_KEY]
* @returns {boolean}
*/
export declare const checkCacheValid: (getState: () => State, cacheKey?: string) => boolean;
export declare const checkCacheValid: (getState: () => State, reducerKey: string, cacheKey?: string) => boolean;
export default checkCacheValid;

@@ -8,9 +8,10 @@ "use strict";

* @param {function} getState
* @param {string} reducerKey
* @param {string} [cacheKey=DEFAULT_KEY]
* @returns {boolean}
*/
exports.checkCacheValid = function (getState, cacheKey) {
exports.checkCacheValid = function (getState, reducerKey, cacheKey) {
if (cacheKey === void 0) { cacheKey = constants_1.DEFAULT_KEY; }
var state = getState();
var cacheUntil = state[cacheKey];
var cacheUntil = state && state[reducerKey] && state[reducerKey][cacheKey];
if (!cacheUntil) {

@@ -17,0 +18,0 @@ return false;

{
"name": "redux-cache",
"version": "0.2.2",
"version": "0.2.3",
"description": "Client side TTL caching strategy for redux applications",

@@ -47,4 +47,6 @@ "main": "lib/index.js",

"js"
]
],
"testPathIgnorePatterns": ["/node_modules/", "/example/"],
"coveragePathIgnorePatterns": ["/node_modules/", "/example/"]
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc