Skip to content

Razem/Jabi

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 

Jabi

Tiny objective library.

Example:

construct

var construct = require("jabi/lib/construct");

var A = construct({
  init: function (a) {
    this.a = a;
  },

  proto: {
    toString: function () {
      return "a: " + this.a;
    }
  }
});

var Show = {
  show: function () {
    alert(this.a + ", " + this.b);
  }
};

var B = construct({
  inherit: A,

  init: function (a, b) {
    this.superInit(a);

    this.b = b;
  },

  proto: {
    toString: function () {
      return this.superCall("toString") + ", b: " + this.b;
    }
  },

  mixin: [Show],

  own: {
    create: function (a, b) {
      return new B(a, b);
    }
  }
});

struct

var struct = require("jabi/lib/struct");

// A simple struct with properties
var Point = struct("x", "y", "z");
var p = new Point(1, 2, 3); // x = 1, y = 2, z = 3

// A struct with a custom prototype
var Point = struct(["x", "y", "z"], {
  x: 0,
  y: 0,
  z: 0,
  toString: function () {
    return this.x + ":" + this.y + ":" + this.z;
  }
});

var p1 = new Point(1, 2, 3);
p1.toString() === "1:2:3";

var p2 = new Point(1, 2);
p2.toString() === "1:2:0";

Installation:

npm install jabi

Compatible with:

  • Node.js
  • Browserify

About

Tiny objective library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published