UNPKG

water-orm

Version:

A monolith version of Standalone waterline ORM

32 lines (23 loc) 734 B
/** * Extend Method * * Taken from Backbone Source: * http://backbonejs.org/docs/backbone.html#section-189 */ var _ = require('lodash'); module.exports = function(protoProps, staticProps) { var parent = this; var child; if (protoProps && _.has(protoProps, 'constructor')) { child = protoProps.constructor; } else { child = function() { return parent.apply(this, arguments); }; } _.extend(child, parent, staticProps); var Surrogate = function() { this.constructor = child; }; Surrogate.prototype = parent.prototype; child.prototype = new Surrogate(); if (protoProps) _.extend(child.prototype, protoProps); child.__super__ = parent.prototype; return child; };