1.0.1 • Published 5 years ago

@kingjs/create-constructor v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

@kingjs/create-constructor

Usage

var createConstructor = require('@kingjs/create-constructor');

var Vehicle = createConstructor(
  'Vehicle',
  null,
  function Vehicle(company, name) { 
    this.company = company;
    this.name = name;
  }
);
Vehicle.prototype.isVehicle = true;

var Car = createConstructor(
  'Car',
  Vehicle
);
Car.prototype.isCar = true;

var Truck = createConstructor(
  'Truck',
  Vehicle,
  function(company, name, towingCapacity) {
    this.towingCapacity = towingCapacity;
  }
);
Truck.prototype.isTruck = true;

result:

API

declare function createConstructor(
): any

Parameters

Returns

Remarks

Install

With npm installed, run

$ npm install @kingjs/create-constructor

License

MIT

Analytics