Created
November 5, 2019 16:07
-
-
Save dark4eg/bcb3593ca3865665940a719a481184e7 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
finction memoize (fn) { | |
const cache = {}; | |
return function (...args) { | |
let stringifiedArgs = JSON.stringify(args); | |
if (cache[stringifiedArgs]) { | |
return cache[stringifiedArgs]; | |
} | |
const result = fn(...arguments); | |
cache[stringifiedArgs] = result; | |
return result; | |
}; | |
}; | |
const getBondsDataFn = async ({date, isins}) => { | |
const result = await http.post({ | |
url: `/bonds/${date}`, | |
body: isins | |
}); | |
return result; | |
}; | |
const getBondsData = memoize(getBondsDataFn); | |
getBondsData({ date: '20180120', isins: ['XS0971721963', 'RU000A0JU4L3'] }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment