Revision 2f13fea2bf0428e65fe80014ab42ee0e97546fa5 authored by Facundo Olano on 05 May 2019, 17:00:10 UTC, committed by Facundo Olano on 05 May 2019, 17:00:10 UTC
1 parent 700ab06
index.js
'use strict';
const R = require('ramda');
const constants = require('./lib/constants');
const memoizee = require('memoizee');
const appMethod = require('./lib/app');
const getParseList = require('./lib/utils/parseList');
const parseList = R.partial(getParseList, [appMethod]);
const methods = {
app: appMethod,
list: R.partial(require('./lib/list'), [parseList]),
search: R.partial(require('./lib/search'), [parseList]),
suggest: require('./lib/suggest'),
developer: R.partial(require('./lib/developer'), [parseList]),
reviews: require('./lib/reviews'),
similar: require('./lib/similar'),
permissions: require('./lib/permissions'),
categories: require('./lib/categories')
};
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);
// need to rebuild the methods so they all share the same memoized appMethod
const doMemoize = (fn) => memoizee(fn, cacheOpts);
const mAppMethod = memoizee(appMethod, cacheOpts);
const mParseList = R.partial(getParseList, [mAppMethod]);
const otherMethods = {
list: R.partial(require('./lib/list'), [mParseList]),
search: R.partial(require('./lib/search'), [mParseList]),
suggest: require('./lib/suggest'),
developer: R.partial(require('./lib/developer'), [mParseList]),
reviews: require('./lib/reviews'),
similar: require('./lib/similar'),
permissions: require('./lib/permissions'),
categories: require('./lib/categories')
};
return Object.assign({app: mAppMethod},
constants,
R.map(doMemoize, otherMethods));
}
module.exports = Object.assign({memoized}, constants, methods);
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...