Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

perf: add cached version of isDir #218

Merged
merged 4 commits into from
May 11, 2019

Conversation

keithamus
Copy link
Contributor

We cache isFile and readFile, but the resolve package also allows us to override the isDir function - which we can add our caching to to make performance better.

src/index.js Outdated Show resolved Hide resolved
src/index.js Outdated Show resolved Hide resolved
src/index.js Outdated Show resolved Hide resolved
src/index.js Outdated Show resolved Hide resolved
@keithamus keithamus force-pushed the perf-add-cached-version-of-isdir branch from 2e3a623 to d786f8d Compare May 10, 2019 15:49
};
const readFileCached = cache(readFileAsync);
const isDirCached = cache(file => statAsync(file).then(stat => stat.isDirectory(), ignoreENOENT));
const isFileCached = cache(file => statAsync(file).then(stat => stat.isFile(), ignoreENOENT));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice now that I wrapped my head around it!

Copy link
Member

@lukastaegert lukastaegert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!

@lukastaegert lukastaegert merged commit e7eef7f into master May 11, 2019
@lukastaegert lukastaegert deleted the perf-add-cached-version-of-isdir branch May 11, 2019 07:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants