1.0.0 • Published 6 years ago

with-known-usage v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

Tracking object usage in a performant way. Created specially for tracking redux store usage.

import {withKnowUsage} from 'with-known-usage';

const obj = { a:1, b:2 };

const {
  proxy: obj,
  usage: Set<string>,
  usedKeys: Array<string>,
  resetUsage()
} = withKnowUsage(obj);

usage.has('a') === false;
usedKeys === [];

// now use it
proxy.a === 1 // (==obj.a)

usage.has('a') === true;
usedKeys === ['a'];