Socket
Book a DemoInstallSign in
Socket

level2-base

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

level2-base

Level2 Base Module

1.0.0
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Level2 Base

Provides the base class and other bits of code that were being re-used within level2 projects.

API

Class

The Class class provides a simple way of defining new classes and extending classes. All uses of Class must extend Class itself or one of its subclasses.

var Something = Class.extend({
	// Provide prototype here
});

var ChildSomething = Something.extend({
	// Override Something prototoype if needed
});

:information_source: Within override methods a special function, this._super, is available to call the super class's function (note that this is only defined in the child function and is removed after the method returns)

To provide a constructor use the init property of the prototype. This function will be called when an instance is constructed.

var Something = Class.extend({
	init: function() {
		// Do initialization here
	}
});

Mixins are also supported when using Class.extend().

var Something = Class.extend(Mixin1, Mixin2, {
	// Provide prototype here
});

Class.extend([mixins...], prototype) - Function

Extends a Class with a new prototype. If any mixins are provided their attributes will be copied to the new class's prototype.

  • [mixins...] Function: mixins to apply to this class
  • prototype Object: prototype to apply to this class

EventEmitter

Because it was used so often a simple event emitter class is provided. This is intended to be used as a mixin.

EventEmitter.on(eventName, handler)

Adds an event listener for the given event name.

  • eventName String: The event name that the listener is waiting for
  • handler Function: The event handler function

EventEmitter.emit(eventName, [data...])

Calls all the registered event listeners for the given event.

  • eventName String: The event to fire
  • [data...] Mixed: The arguments to pass to the event handlers

FAQs

Package last updated on 24 Oct 2015

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.