New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

backbone-prototype-compatibility

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backbone-prototype-compatibility

Enables Prototyping Handling for Javascript for the Backbone Classes.

latest
Source
npmnpm
Version
1.0.5
Version published
Maintainers
1
Created
Source

backbone-prototype-compatibility

Why this?

Backbone uses the extend function to create models, collections, views. But this function use internally a surrogate, which does not allow the native using of JS Prototypes. With this surrogate, you can not determine an backbone object of a specific instance (the instanceof test will always failed).

This function allows your own prototypes to interact correctly with backbone by using the backbone prototypes model, collection, views.

Install

bower install backbone-prototype-compatibility --save
bower install backbone-prototype-compatibility --save

Usage

es5

function MyModel(attributes, options) {
    Backbone.Model.apply(this, arguments);
}

MyModel.prototype = Object.create(Backbone.Model, {
    property: {
        value: 10,
        enumerable: true,
        configurable: true,
        writable: true
    }
});
MyModel = compatibility(MyModel);

es6

class MyModel extends Backbone.Model {
    constructor(attributes, options) {
        this.property = 10;
        
        super(attributes, options);
    }
}

MyModel = compatibility(MyModel);

After the creation of the prototype and using the compatibility function, the prototype will contain the static methods

  • compatibility ... this is the compatibility function from this repository
  • extend ... this is the original Backbone.extend function, which is present on every Backbone Prototype.

FAQs

Package last updated on 30 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts