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

clazzjs

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

clazzjs

Clazz is a simple JavaScript class providing liblary.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-25%
Maintainers
1
Weekly downloads
 
Created
Source

Clazz.js

Clazz.js is a simple JavaScript class providing liblary.

Getting Started

using in webapp

Download js file from here.

<script type="text/javascript" src="clazz.min.js"></script>
var MyClass = new Clazz({
	init: function(message){
		this.message = message;
	},
	say: function(){
		console.log(this.message);
	}
});

var myClass = new MyClass('I am an instance of MyClass.');
myClass.say();

using in node.js app

Install the module with: npm install clazzjs

var Clazz = require('clazz');

var MyClass = new Clazz({
	init: function(message){
		this.message = message;
	},
	say: function(){
		console.log(this.message);
	}
});

var myClass = new MyClass('I am an instance of MyClass.');
myClass.say();

Documentation

Create a Class

var MyClass = new Clazz({
	// The first argument is a instance method module.
	init: function(){
		// "init" is a special method which is executed in the constructor.
	},
	someMethod: function(){
		// you can define
	},
	someAttribute: ''
},
{
	// The second argument is a static method module.
	someStaticMethod: function(){
	}
});

new MyClass().someMethod(); // calling a instance method.
MyClass.someStaticMethod(); // calling a static method.

Inheritance

Clazz.js supports Inheritance. Use "extend" method to create a sub class. In subclass method, you can use access super method by "_dl" property. The "_dl" property returns a function to delegate super method.

var SubClass = MyClass.extend({
	someMethod: function(){
		this._dl('someMethod')(); // call "someMethod" which is deifined by the super class.
	}
});

Mix in

Using "mixin" method, you can import an external module to your class.

var module = {
	action: function(){
		console.log(this.message);
	};
};

var MyClass = new Clazz({
	init:function(message){
		this.message = message;
	}
}).mixin(module);
new MyClass('Hello!').action(); // -> 'Hello!'

Examples

(Coming soon)

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

(Nothing yet)

License

Copyright (c) 2013 quramy. Licensed under the MIT license.

FAQs

Package last updated on 05 Aug 2013

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