Skip to content

Commit

Permalink
Refactor: reducePaths now a private function, not instance method
Browse files Browse the repository at this point in the history
  • Loading branch information
nspragg committed Apr 11, 2016
1 parent 6de18df commit c968082
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/filehound.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
} from './files';

import * as arrays from './arrays';
import * as iterables from './iterables';

function isDefined(value) {
return value !== undefined;
Expand All @@ -43,6 +42,15 @@ function isHiddenDirectory(dir) {
return (/(^|\/)\.[^\/\.]/g).test(dir);
}

function reducePaths(searchPaths) {
if (searchPaths.length === 1) {
return searchPaths;
}

const subDirs = findSubDirectories(searchPaths.sort());
return searchPaths.filter(notSubDirectory(subDirs));
}

class FileHound {
constructor() {
this.searchPaths = [];
Expand Down Expand Up @@ -158,17 +166,8 @@ class FileHound {
return bluebird.all(searches).reduce(flatten).asCallback(cb);
}

_reducePaths(searchPaths) {
if (this.searchPaths.length === 1) {
return this.searchPaths;
}

const subDirs = findSubDirectories(this.searchPaths.sort());
return this.searchPaths.filter(notSubDirectory(subDirs));
}

getSearchPaths() {
return arrays.copy(this._reducePaths(this.searchPaths));
return arrays.copy(reducePaths(this.searchPaths));
}
}

Expand Down

0 comments on commit c968082

Please sign in to comment.