Skip to content

Instantly share code, notes, and snippets.

View twick00's full-sized avatar

Tyler Wickline twick00

  • Seattle, WA
View GitHub Profile
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)) {
/*
* 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");