Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Union methods are not bound #233

Open
l1bbcsg opened this issue Feb 8, 2019 · 1 comment
Open

Union methods are not bound #233

l1bbcsg opened this issue Feb 8, 2019 · 1 comment

Comments

@l1bbcsg
Copy link

l1bbcsg commented Feb 8, 2019

Union methods frequently use this in their implementations. Calling them with a different context breaks them:

const fs = require('fs');
const ufs = new (require('unionfs').Union);

[].find(fs.existsSync); // undefined
[].find(ufs.existsSync); // TypeError: Cannot read property 'fss' of undefined

fs.existsSync.call(null, 'foo') // false
ufs.existsSync.call(null, 'foo') // TypeError: Cannot read property 'fss' of null

While this might be a questionable approach, this behaviour breaks unionfs compatibility with native fs. In my case this error originated from a different package in test environment where unionfs was mocking real fs.

@streamich
Copy link
Owner

Yes, they should be bound. It is my mistake, in recent PR review I let it slip through.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants