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

clazzy

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clazzy

A cross platform JavaScript library that provides a classical interface to a prototype system.

  • 0.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Clazz.js

A cross platform JavaScript library that provides a classical interface to a prototype system.

Clazz.js was built with some very simple goals in mind:

Usage

Creating a class

var Foo = Clazz.create(
{
	initialize : function ()
	{
		// Constructor
	},

	// --------------------------------

	baz : function ()
	{
		// Instance method
	},

	qux : function ()
	{
		// Another instance method
	},
	
	// --------------------------------

	static : 
	{
		corge : function ()
		{
			// Static method
		}
	}
});

var foo = new Foo();

*Note: All instance properties of your class should be defined within the constructor, anything in the definition treated as an instance member is applied to the Class prototype, meaning it will be shared by all instances of the class.

Creating a class that extends another class

var Bar = Clazz.create(
{
	extend : Foo,

	// --------------------------------

	initialize : function ()
	{
		this.super();
	},

	// --------------------------------

	baz : function ()
	{
		return 'bar';
	},

	qux : function ()
	{
		return 'super ' + this.super();
	}
});

var bar = new Bar();

Creating a class that includes another class

Clazz.js provides a method of code reuse called includes. Behaving similarly to Ruby's mixins and PHP's traits, they enable a developer to reuse sets of methods freely in several independent classes living in different class hierarchies.

var Baz = Clazz.Create(
{
	include : [Foo]
});

var baz = new Baz();

Some things to take note with includes:

  • If an include has a constructor, that constructor will be executed when the including class is being instantiated.
  • The super method will not refer to the base of the class it's included in, it will refer to the hierarchy the include class may have.
  • The precedence order is: an inherited member from a base class is overriden by an included member and an included member is overriden by a member from the current class.

Getting started

Node

Clazz.js is available through the Node package manager(npm), so you install like so:

npm install class

and bring into your code like so:

var Clazz = require('clazz');

Browser

To use Clazz.js in a browser envrionment it's as bringing it in using a script tag like so:

<script type="text/javascript" src="path/to/Clazz.js"></script>

To remove from the global namespace, you can use Clazz.noConflict(), like so:

Namespace.Clazz = Clazz.noConflict();

Development

Grunt is used to handle the build process for Clazz.js. To perform a full build, use the build task:

grunt build

which is just an alias for the default task:

grunt

To only check code quality and/or run unit tests use the test task:

grunt test

License

Clazz.js is released under the MIT License

FAQs

Package last updated on 10 Apr 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