New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

snap-context

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

snap-context

Snapshot and restore context

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

snap-context NPM version Build Status Dependency Status

Manage context with ease

Usage

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' 

API

new Context

Creates context object with methods:

Context.set(key, value)

Sets key for value in current context.

Context.get(key)

Gets value for key in current (or previous) context.

Context.snapshot(ctx)

Creates new Object and add it to ctx prototype.

Context.restore(ctx)

Removes created Object from prototype chain of ctx.

Benchmark results

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

Keywords

prototype

FAQs

Package last updated on 23 Jul 2014

Did you know?

Socket

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.

Install

Related posts