Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Support library
JavaScript

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin
docs
lib
support
test
.gitignore
.npmignore
.travis.yml
HISTORY.md
LICENSE
Makefile
README.md
bike.js
bike.min.js
package.json
runtime.js

README.md

Stage
Build Status

version 0.5.3 (stable) - History

Bike

Organize your classes through namespaces, extend or mix them.

This module can be used standalone or inside behere framework as behere.bike.

Installation

Install this using npm as follows for standalone use

$ npm install bike

Quick Start

Define a class

This will register a class.

var Bike = require('bike');

Bike.define('animal', {
  move: function(){
    return 'i move'
  }
});

Bike.create('animal').move();
// => 'i move'

behere use: behere.define()

Create a class

var animal = Bike.create('animal');

animal.move();
// => 'i move'

behere use: behere.create()

Extend a class

Extending a class will allow to inherit all the properties and methods from the extended object. To call the parent method use the this._super() syntax.

Bike.define('cat', {
  extend: 'animal',
  move: function(){
    return this._super() + ', run and jump'
  }
});

var cat = Bike.create('cat');

cat.move();
// => 'i move, run and jump'

Use namespaces

The namespace will bike you organize classes in a tree structure.

Bike.define('animal', {
  /* ... */
});

Bike.define('animal.cat', {
  extend: 'animal'
  /* ... */
});

Bike.define('animal.cat.Sophie', {
  extend: 'animal.cat'
  /* ... */
});

// And more..

Bike.define('animal.dog', {
  extend: 'animal'
  /* ... */
});

Bike.define('Monkey', {  // Monkey is the name of my dog :-)
  extend: 'animal.dog'
  /* ... */
});

Load missing libraries

In most of the cases your code will need to require libraries. With Bike what you need to do it so define namespaces and its system location.

Bike.namespace('foo', '/my/path/to/it');

Bike.create('foo.animal');
// => this will create a class defined in '/my/path/to/it/animal.js'

Works the same extending or mixing:

Bike.define('Sophie', {
  extend: 'foo.animal.cat'
});
// => This will extend the class defined in '/my/path/to/it/animal/cat.js'

Features

  • ...

Running Tests

Install dev dependencies and make tests:

$ npm install -d
$ make test

Contributors

Gabriele Di Stefano <gabriele.ds@gmail.com>

Behere Logo

License

The MIT License

Something went wrong with that request. Please try again.