underscore-inherit
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "underscore-inherit", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"main": "underscore-inherit.js", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
{ | ||
"name": "underscore-inherit", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"author": "Casey Foster <c@sey.me>", | ||
@@ -11,4 +11,10 @@ "main": "underscore-inherit", | ||
"devDependencies": { | ||
"underscore": "x" | ||
"chai": "x", | ||
"mocha": "x", | ||
"underscore": "x", | ||
"watchy": "x" | ||
}, | ||
"scripts": { | ||
"test": "make test" | ||
} | ||
} |
underscore-inherit | ||
================== | ||
[![Build Status](https://secure.travis-ci.org/caseywebdev/underscore-inherit.png)](http://travis-ci.org/caseywebdev/underscore-inherit) | ||
Add constructor extensibility to Underscore.js. | ||
@@ -5,0 +7,0 @@ |
@@ -8,21 +8,16 @@ (function () { | ||
var slice = [].slice; | ||
// Define the mixin | ||
_.mixin({ | ||
inherit: function () { | ||
var protoProps; | ||
var staticProps; | ||
var Parent = _.reduce(arguments, function (Parent, arg) { | ||
if (_.isFunction(arg)) { | ||
if (!Parent) return arg; | ||
return _.inherit(arg, {constructor: Parent}); | ||
} | ||
if (_.isObject(arg)) { | ||
if (!protoProps) { | ||
protoProps = arg; | ||
} else if (!staticProps) { | ||
staticProps = arg; | ||
} | ||
} | ||
return Parent; | ||
}, null) || function () {}; | ||
var args = slice.call(arguments); | ||
var Parent; | ||
while (_.isFunction(args[0])) { | ||
var arg = args.shift(); | ||
Parent = Parent ? _.inherit(arg, {constructor: Parent}) : arg; | ||
} | ||
if (!Parent) Parent = function () {}; | ||
var protoProps = args[0]; | ||
var staticProps = args[1]; | ||
@@ -29,0 +24,0 @@ // `Child` is the passed in `constructor` proto property |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34600
12
108
51
4