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

backbone-emulate-collection

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-emulate-collection

Mix in methods from Underscore, for iteration, and other collection related features. Borrowing this code from Backbone.Collection.

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

backbone-emulate-collection

Travis build status Code Climate Test Coverage Dependency Status

Mix in methods from Underscore, for iteration, and other collection related features. Borrowing this code from Backbone.Collection.

It works by taking an object and a property field, in this example 'list', and appending collection functions to the object so that it can delegate collection calls to its list.

Object Literal
var obj = {
  list: [1, 2, 3]
}

emulateCollection(obj, 'list');

var double = function(v){ return v*2; };
console.log(obj.map(double)); // [2, 4, 6]
Function Prototype
var Func = function(list) {
  this.list = list;
};

emulateCollection(Func.prototype, 'list');
var func = new Func([1,2,3]);

var double = function(v){ return v*2; };
console.log(func.map(double)); // [2, 4, 6]

For more information about the proxied methods, see the Underscore.js documentation.

FAQs

Package last updated on 25 Nov 2015

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

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