package
Snapshot and restore context
npm install snap-contextGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Manage context with ease
var Context = require('proto-context');
var ctx = new Context();
ctx.set('value', 'first version'); // console.log(ctx.get('value')) -> 'first version'
ctx.snapshot();
ctx.set('value', 'second version'); // console.log(ctx.get('value')) -> 'second version'
ctx.restore();
console.log(ctx.get('value')); // -> 'first version' Creates context object with methods:
Sets key for value in current context.
Gets value for key in current (or previous) context.
Creates new Object and add it to ctx prototype.
Removes created Object from prototype chain of ctx.
Benchmarking set -> snapshot -> get -> restore pattern:
Performance
1,133,011 op/s » Stack on array
668,539 op/s » Stack on list
645 op/s » Stack on object.prototype