New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

set-aside

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

set-aside

Using a side storage (`WeakMap`) to create property setter hooks on an object.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by300%
Maintainers
1
Weekly downloads
 
Created
Source

set-aside

Using a side storage (WeakMap) to create property setter hooks on an object.

API

setAside.sideStore(obj)

Gives you the "side storage" object for an object. Uses WeakMap where available, or a non-enumerable property containing the side storage object where not.

setAside.sideSet(obj, key, {before, after})

Create a get/set property named key on the object using defineProperty. If the property was already a get/set property, it will chain onto the current getter and setter. If passed before and after can be functions with the argument list (newValue, oldValue, thisArg). The thisArg is passed in to make using arrows here a bit easier if you want.

setAside.beforeSet(obj, key, hook)

setAside.afterSet(obj, key, hook)

The hook should look like function( newValue, oldValue, thisArg ) {}. Just an alias for sideSet

Examples

class Foo {
  triggerRender() { console.log('trigger!'); }
}

setAside.afterSet(Foo.prototype, 'data', function() { this.triggerRender(); });

new Foo().data = 'foo'; // logs 'trigger!'

FAQs

Package last updated on 24 May 2016

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc