feeles-ide
Version:
The hackable and serializable IDE to make learning material
34 lines (28 loc) • 842 B
JavaScript
import includes from 'lodash/includes';
export default (function (file, query) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
options = options || getOptions(query);
if (options.showInvisibles === !!file.moduleName) {
return false;
}
if (options.showTrashes !== file.options.isTrashed) {
return false;
}
return query.split(/\s+/).every(function (keyword) {
if (!keyword) {
return true;
}
if (keyword[0] === ':') {
return true;
}
return includes(file.name, keyword);
});
});
export var getOptions = function getOptions(query) {
return query.split(/\s+/).reduce(function (p, keyword) {
return {
showInvisibles: p.showInvisibles || keyword[0] === '.',
showTrashes: p.showTrashes || keyword === ':trash'
};
}, {});
};