This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* decaffeinate suggestions: | |
* DS102: Remove unnecessary code created because of implicit returns | |
* DS201: Simplify complex destructure assignments | |
* DS207: Consider shorter variations of null checks | |
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md | |
*/ | |
import _ from "underscore"; | |
_.mixin(require("underscore.deep")); | |
const async = require("async"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function useCacheable<T, H>( | |
filePath: PathLike, | |
promiseFunction: (args: H) => Promise<T> | |
): (args: H) => Promise<T> { | |
return async (...args: [H]) => { | |
createFileIfNoteExist(filePath) | |
return new Promise(resolve => { | |
return promiseFunction(...args).then( | |
value => { | |
if (!isEmpty(value)) { |