forked from facundoolano/app-store-scraper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (26 loc) · 896 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
'use strict';
const R = require('ramda');
const memoizee = require('memoizee');
const constants = require('./lib/constants');
const methods = {
app: require('./lib/app'),
list: require('./lib/list'),
search: require('./lib/search'),
developer: require('./lib/developer'),
privacy: require('./lib/privacy'),
suggest: require('./lib/suggest'),
similar: require('./lib/similar'),
reviews: require('./lib/reviews'),
ratings: require('./lib/ratings')
};
function memoized (opts) {
const cacheOpts = Object.assign({
primitive: true,
normalizer: JSON.stringify,
maxAge: 1000 * 60 * 5, // cache for 5 minutes
max: 1000 // save up to 1k results to avoid memory issues
}, opts);
const doMemoize = (fn) => memoizee(fn, cacheOpts);
return Object.assign({}, constants, R.map(doMemoize, methods));
}
module.exports = Object.assign({memoized}, constants, methods);