keyz / keyz/identity-obj-proxy
Support Object.prototype.* calls (such as hasOwnProperty).
- Dominant language
- JavaScript
- Stars
- 507
- Forks
- 19
- PR merge metrics
- No merged PRs in 30d
Description
👋 Hi there!
We have code that looks like this:
```js
import colors from 'colors.less';
function exampleUtilFunction(color) {
if (!colors.hasOwnProperty(color)) {
throw new Error();
}
}
```
When using this mock, it fails with:
```
TypeError: colors.hasOwnProperty is not a function
```
As a quick fix, we added this code to the proxy:
```js
if (key === 'hasOwnProperty') {
return () => true;
}
```
I think it'd be nice if `identity-obj-proxy` supported the methods on `Object.prototype`. I'm happy to submit a PR if it would be accepted. :)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading the proxy implementation used by identity-obj-proxy and examine how Object.prototype calls such as hasOwnProperty are handled. Reproduce the example with the colors.less import, then add coverage showing the requested calls work without breaking the existing identity behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100