Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

underscore-inherit

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

underscore-inherit - npm Package Compare versions

Comparing version 0.0.5 to 1.0.0

underscore-inherit.sublime-project

2

bower.json
{
"name": "underscore-inherit",
"version": "0.0.5",
"version": "1.0.0",
"main": "underscore-inherit.js",

@@ -5,0 +5,0 @@ "dependencies": {

{
"name": "underscore-inherit",
"version": "0.0.5",
"version": "1.0.0",
"author": "Casey Foster <c@sey.me>",

@@ -5,0 +5,0 @@ "main": "underscore-inherit",

@@ -17,5 +17,3 @@ underscore-inherit

```js
var Animal = function () {};
_.extend(Animal.prototype, {
var Animal = _.inherit({
name: 'Chupacabra',

@@ -28,6 +26,8 @@ sound: 'roarmeowbarkmoo',

var Dog = _.inherit(Animal, {
var HardWorker = _.inherit();
var Dog = _.inherit(Animal, HardWorker, {
name: 'Gunner',
sound: 'woof'
});
}, {staticProp: 'hello'});

@@ -40,4 +40,12 @@ var Cat = _.inherit(Animal, {

(new Animal()).sing();
(new Cat()).sing();
(new Dog()).sing();
(new Cat()).sing();
// (new Cat) instanceof Animal === true
// (new Cat) instanceof Cat === true
// Dog.staticProp === true
// (new Dog) instanceof Animal === true
// (new Dog) instanceof HardWorker === true
// (new Dog) instanceof Dog === true
```

@@ -10,3 +10,19 @@ (function () {

_.mixin({
inherit: function (Parent, protoProps, staticProps) {
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 () {};

@@ -13,0 +29,0 @@ // `Child` is the passed in `constructor` proto property

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc