
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
proxyequal
Advanced tools
Shallow equal is a good thing, but it compares thing you don't need.
Proxy equal - "MobX"-like solution, which will "magically" compare only used keys.
Wrap an object with proxyState
Run some computations using providing proxyObject. proxyState returns object with shape
proxy
will collect all referenced or used keys
proxyEqual
will compare all used "endpoint" keys of 2 objects
proxyShallow
will compare all used NON "endpoint" keys of 2 objects.
The difference between proxyEqual and proxyShallow is in expectations.
shallowEqual
, it compares the top level objects. Might be they are still the same.spreadGuardsEnabled(boolean=[true])
- controls spread guards, or all-keys-enumeration, which makes proxyEqual ineffective.sourceMutationsEnabled(boolean=[false])
- controls set behavior. By default proxied state is frozen.When you have a big state, for example redux state, but some function (redux selector, or mapStateToProps) uses just a small subset.
Here proxyequal can shine, detecting the only used branches, and comparing only the used keys.
import {proxyState, proxyEqual, proxyShallow} from 'proxyequal';
// wrap the original state
const trapped = proxyState(state);
// use provided one in computations
mapStateToProps(trapped.state);
// first shallow compare
proxyShallow(state, newState, trapped.affected);
// next - deep compare
proxyEqual(state, newState, trapped.affected);
const trapped = proxyState(state);
// do something
workWith(trapped.state);
trapped.seal();
// now tracking is disabled
trapped.unseal();
// and enabled
Uses ES6 Proxy
underneath to detect used branches(as MobX
), and search-trie
to filter out keys for shallow or equal compare.
So - it is lighting fast.
Unfortunately, due to Proxy wrappers all objects
will be unique each run.
shallowEqual(proxyState(A), proxyState(A)) === false
There is a undocumented way to solve it, used internally in memoize-state library. Once it will be proven to work stable - we will expose it.
Requires Proxy
support, so the proxy-polyfill is included in the common bundle for Internet Explorer 11. How this works may change in future, see issue #15 "ProxyPolyfill is unconditionally imported" for details.
MIT
FAQs
A proxy based usage tracking and comparison
We found that proxyequal demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.