# ctrl8

> Ctrl8

Latest version **0.0.17** (published 2017-06-27) · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.17 |
| Published | 2017-06-27 |
| First published | 2017-05-11 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Manh Le |
| Maintainers | manhle8 |

## Links

- npm: https://www.npmjs.com/package/ctrl8
- Repository: https://github.com/ManhQLe/Ctrl8
- Homepage: https://github.com/ManhQLe/Ctrl8#readme
- Issues: https://github.com/ManhQLe/Ctrl8/issues
- npm.io page: https://npm.io/package/ctrl8

## Recent versions

- 0.0.17 (latest) — 2017-06-27
- 0.0.16 — 2017-06-27
- 0.0.15 — 2017-06-24
- 0.0.14 — 2017-06-04
- 0.0.13 — 2017-05-26
- 0.0.12 — 2017-05-25
- 0.0.11 — 2017-05-24
- 0.0.10 — 2017-05-23
- 0.0.9 — 2017-05-21
- 0.0.8 — 2017-05-21
- 0.0.7 — 2017-05-21
- 0.0.5 — 2017-05-19
- 0.0.4 — 2017-05-17
- 0.0.3 — 2017-05-17
- 0.0.2 — 2017-05-11
- … 2 more at https://npm.io/package/ctrl8/versions

## README

# Ctrl8

# Installation
>npm install ctrl8 --save

## Usage
>Mainly used for creating custom component.

### Inheritance
```javascript
      function Toy(init) {
			Toy.baseConstructor.call(this,init);
	  }
	  Ctrl8.ExtendsTo(Toy)
```

### Define custom properties

```javascript
	  
	function Specification(init){
		Specification.baseConstructor.call(this,init);
		this.Prop("BaseHeight",1);
		this.Prop("Width",1);
		this.Prop("Length",1);
		this.Prop("WheelCount",2);
		this.CalcProp("Volume",function(){
			return this.Width*this.BaseHeight*this.Length;
		})
	}
	
	Ctrl8.ExtendsTo(Specification)

	function Toy(init) {
		Toy.baseConstructor.call(this,init);
		this.Prop("Name","My Default Name");
		this.CalcProp("Specs",function(name,store){
			return new Specification(store[name]||(store[name]={}))
		},null,1); //Configurable
	}
	Ctrl8.ExtendsTo(CustomComponent1)

	function ControlUnit(init){
		ControlUnit.baseConstructor.call(this,init);
		this.Prop("Memory",3000000000); //3GBs
		this.Prop("Speed",45000000000); //4.5GHz;
	}

	Ctrl8.ExtendsTo(ControlUnit)

	function ASpec(init){
		ASpec.baseConstructor.CalcProp(this,init);
		this.Prop("RequiredPower",1.3) // Default 1.3 volts;
		this.Prop("WireCount",3) //Default WireCount: 3
		this.CalcProp("CPU",function(name,store){
			return new ControlUnit(store[name]||(store[name]={}))
		});
	}

	Specification.ExtendsTo(ASpec)


	function Robot(init){
		Robot.baseConstructor.call(this.init);
		this.Prop("SerialNumber","0000-0000-0000");
		this.CalcProp("Specs",function(name,store){
			return new ASpec(store[name]||(store[name]={}))
		},null,1) //Override Specs
	}

	Toy.ExtendsTo(Robot);


	var Comp1 = new Toy({
		"Name":"Toy1", // Set initial name
		"Specs": {
			"BaseHeight": 2,
			"Width":12,
			"Length":20,
			"WheelCount":4
		}
	})

	console.log(Comp1.Name);
	console.log("Toy Length: " , Comp1.Specs.Length);
	console.log("Volume: ", Comp1.Specs.Volume);

	var Android1 = new Robot({
		"Name":"Made Of Steel",
		"Specs": {
			"BaseHeight": 10,
			"Width":2,
			"Length":2,
			"WheelCount":8,
			"RequiredPower":9,
			"WireCount":125,
			"CPU":{
				"Memory":8000000000 //8GBs
			}
		}
	})

	console.log("Robot name: ",Android1.Name);
	console.log("Brain Speed: ",Android1.Specs.CPU.Speed);
	Android1.Specs.CPU.Speed+=2000; //Add more speed;

	console.log("New Brain Speed: ",Android1.Specs.CPU.Speed);

```

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