# classified

> Real OOP for Javascript

Latest version **0.1.3** (published 2014-10-08) · 0 weekly downloads

## Install

```sh
npm install classified
pnpm add classified
yarn add classified
bun add classified
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2014-10-08 |
| First published | 2014-09-07 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Christian Blanquera |
| Maintainers | cblanquera |
| Keywords | oop, class, protected, parent, structure, constructor, inheritence, constant |

## Links

- npm: https://www.npmjs.com/package/classified
- Repository: https://github.com/cblanquera/classified
- Issues: https://github.com/cblanquera/classified/issues
- npm.io page: https://npm.io/package/classified

## Recent versions

- 0.1.3 (latest) — 2014-10-08
- 0.1.2 — 2014-10-02
- 0.1.1 — 2014-09-17
- 0.1.0 — 2014-09-17
- 0.0.17 — 2014-09-17
- 0.0.16 — 2014-09-12
- 0.0.15 — 2014-09-11
- 0.0.14 — 2014-09-10
- 0.0.13 — 2014-09-10
- 0.0.12 — 2014-09-10
- 0.0.11 — 2014-09-09
- 0.0.10 — 2014-09-09
- 0.0.9 — 2014-09-09
- 0.0.8 — 2014-09-08
- 0.0.7 — 2014-09-08
- … 5 more at https://npm.io/package/classified/versions

## README

#Classified

  Real OOP for Javascript.


[![NPM](https://badge.fury.io/js/classified.svg)](https://www.npmjs.org/package/classified)
[![Build Status](https://api.travis-ci.org/cblanquera/classified.png)](https://travis-ci.org/cblanquera/classified/)


### Installation

```bash
$ npm install classified
```

  For client side you can just include the `index.js`

### Usage

#### Node

```
var classified = require('classified');
classified();
```

#### RequireJS

```
var classified = require(['classified'], function(classified) {});
```

#### jQuery

```
jQuery.classified();
```

#### Client Side

```
classified();
```

## Quick Start

```
var classified = require('classified');

//root definition
var RootClass = classified({
	//constants
	SOME_CONSTANT: 'foo',
	
	//public properties
	sampleProperty: 4.5,
	
	//protected properties
	_sampleProperty: 5.5,
	
	//private properties
	__sampleProperty: 6.5,
	
	//constructor
	___construct: function() {
		this.constructCalled = true;
	},
	
	//public methods
	sampleMethod: function() {
		return this._sampleMethod();
	},
	
	//protected methods
	_sampleMethod: function() {
		return this.__sampleMethod();
	},
	
	//private methods
	__sampleMethod: function() {
		return this.SOME_CONSTANT + this._sampleProperty;
	}
});

//child definition
//you can use object or function as the definition
var ChildClass = RootClass.extend(function() {
	//constants
	this.SOME_CONSTANT_2 = 'bar';
	
	//protected properties
	this._sampleProperty = 7.5;
	
	//public methods
	this.sampleMethod = function() {
		return this._sampleMethod();
	};
	
	//protected methods
	this._sampleMethod = function() {
		return this.___parent._sampleMethod();
	};
});

//instantiate child
var child = ChildClass.load();

//test it
console.log(child.sampleMethod()); //--> foo7.5

try {
	child._sampleMethod();
} catch(e) {
	console.log('Protected call did not work');
}
```

### Features

  * Public, Private, Protected
  * Constants
  * Inheritance
  * Traits
  * Works on server or client
  * Circular Dependencies Ready
  * Node asyncrounous protected and private support

### Methods

  * define(object|function) - Defines the class
  * extend(object|function) - Adds a parent to be combined with the definition
  * definition() - Returns the entire definition including the protected and private properties
  * parents() - Returns direct parents of this definition
  * get() - Returns the publically accessable class definition function
  * load() - Returns class defined instantiation
  * register(string) - saves a state of the definition which can be recalled in trait
  * trait(string|function|object) - will setup the provided as a parent, if string will recall from registry

### What's up with the underscores?

  * _ - protected properties and methods
  * __ - private properties and methods
  * ___ - Magic placeholder (Waiting on harmony)


### Node Async Support

  Use `___freeze()` and `___unfreeze()` in Node for asyncronous patterns as in the example below. 

```
classified(function() {
	this._protectedValue = 4;
	this.somethingToAsync = function() {
		this.___freeze();
		setTimeout(function() {
			this._protectedValue = 5;
			this.___unfreeze();
		}.bind(this), 10);
	};
});
```

---
_Source: https://npm.io/package/classified · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
