Skip to content
This repository has been archived by the owner on May 23, 2022. It is now read-only.

Commit

Permalink
Faster 'make'.
Browse files Browse the repository at this point in the history
  • Loading branch information
robotlolita committed May 23, 2013
1 parent ce2e089 commit 385660a
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions lib/boo.js
Expand Up @@ -124,7 +124,7 @@ function fastExtend(object, mixins) {
//
// :: object, mixin... -> object
function extend(target) {
return fastExtend(target, slice.call(arguments, 1)) }
return fastExtend(target, slice(arguments, 1)) }


// ### Function merge
Expand All @@ -145,7 +145,7 @@ function merge() {
//
// :: object, mixin... -> object
function derive(proto) {
return fastExtend(inherit(proto), slice.call(arguments, 1)) }
return fastExtend(inherit(proto), slice(arguments, 1)) }



Expand All @@ -158,14 +158,32 @@ function derive(proto) {
// :: object <| Base
var Base = {

constructor: function(){ }

// #### Function make
// Constructs new instances of this object.
//
// :: @object => A... -> this <| object
, make:
function make() {
var instance = new this.constructor
if (this.init) this.init.apply(instance, arguments)
return instance }

// #### Function derive
// Constructs a new object that inherits from the object this function
// is being applied to, and extends it with the provided mixins.
//
// :: @object => mixin... -> this <| object
derive:
, derive:
function _derive() {
return fastExtend(inherit(this), arguments) }}
var instance = fastExtend(inherit(this), arguments)

instance.constructor = function(){ }
instance.constructor.prototype = instance
return instance }}

Base.constructor.prototype = Base



Expand Down

0 comments on commit 385660a

Please sign in to comment.