Created
April 26, 2019 10:12
-
-
Save ylv-io/0019d7fb0148372e66c4413b5dce3edc to your computer and use it in GitHub Desktop.
This file contains 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
// in order to properly stub and mock libs which export function by default | |
// more https://github.com/sinonjs/sinon/issues/562 | |
export const cache = {}; | |
export default function(lib) { | |
const module = require(lib); | |
if (!cache.hasOwnProperty(lib)) cache[lib] = module; | |
return () => cache[lib].apply(this, args); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment