Socket
Socket
Sign inDemoInstall

obstruct

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

obstruct

Object > Constructor


Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Obstruct

Objects > Constructors

Usage

Obstruct provides simple inheritance without the use of traditional constructors. Inspired by the Type.new blog post, I wrapped up this functionality in a tiny little lib. Basic usage:

var Button = Obstruct.extend({
  constructor: function (el) {
    this.el = el;
    this.addEvents();
  },
  addEvents: function () {
    this.el.addEventListener('click', this.onClick.bind(this));
  },
  onClick: function (event) {
    alert('do suttin');
  }
});

var EvilButton = Button.extend({

  constructor: function () {
    console.log('MWHAHAHAHA');
    Button.apply(this, arguments); // call `super`
  },

  onClick: function () {
    window.location.href = 'http://evil.com'
  }

});

var mybtn = EvilButton.create(document.querySelector('a'));

Keywords

FAQs

Package last updated on 04 Jun 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

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