with-known-usage

Observes object key usage

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
with-known-usage
321.0.06 years ago6 years agoMinified + gzip package size for with-known-usage in KB

Readme


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'];