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

ampersand-collection-underscore-mixin

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ampersand-collection-underscore-mixin - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

.jshintignore

18

ampersand-collection-underscore-mixin.js

@@ -16,5 +16,5 @@ var _ = require('underscore');

// Mix in each Underscore method as a proxy to `Collection#models`.
_.each(methods, function(method) {
_.each(methods, function (method) {
if (!_[method]) return;
mixins[method] = function() {
mixins[method] = function () {
var args = slice.call(arguments);

@@ -30,6 +30,6 @@ args.unshift(this.models);

// Use attributes instead of properties.
_.each(attributeMethods, function(method) {
_.each(attributeMethods, function (method) {
if (!_[method]) return;
mixins[method] = function(value, context) {
var iterator = _.isFunction(value) ? value : function(model) {
mixins[method] = function (value, context) {
var iterator = _.isFunction(value) ? value : function (model) {
return model.get ? model.get(value) : model[value];

@@ -43,5 +43,5 @@ };

// `filter`.
mixins.where = function(attrs, first) {
mixins.where = function (attrs, first) {
if (_.isEmpty(attrs)) return first ? void 0 : [];
return this[first ? 'find' : 'filter'](function(model) {
return this[first ? 'find' : 'filter'](function (model) {
var value;

@@ -58,3 +58,3 @@ for (var key in attrs) {

// of `find`.
mixins.findWhere = function(attrs) {
mixins.findWhere = function (attrs) {
return this.where(attrs, true);

@@ -64,3 +64,3 @@ };

// Plucks an attribute from each model in the collection.
mixins.pluck = function(attr) {
mixins.pluck = function (attr) {
return _.invoke(this.models, 'get', attr);

@@ -67,0 +67,0 @@ };

{
"name": "ampersand-collection-underscore-mixin",
"description": "A mixin for extending ampersand-collection with underscore methods.",
"version": "1.0.0",
"version": "1.0.1",
"author": "Henrik Joreteg <henrik@andyet.net>",

@@ -13,3 +13,7 @@ "bugs": {

"devDependencies": {
"ampersand-collection": "^1.0.0"
"ampersand-collection": "^1.0.0",
"ampersand-state": "^4.3.2",
"precommit-hook": "~0.3.10",
"run-browser": "~1.2.0",
"tape": "~2.12.1"
},

@@ -27,3 +31,24 @@ "homepage": "https://github.com/ampersandjs/ampersand-collection-underscore-mixin",

"url": "git://github.com/ampersandjs/ampersand-collection-underscore-mixin"
},
"scripts": {
"test": "node test/index.js",
"validate": "jshint .",
"start": "run-browser test/index.js"
},
"testling": {
"files": "test/*.js",
"browsers": [
"ie/9..latest",
"firefox/17..latest",
"firefox/nightly",
"chrome/22..latest",
"chrome/canary",
"opera/12..latest",
"opera/next",
"safari/5.1..latest",
"ipad/6.0..latest",
"iphone/6.0..latest",
"android-browser/4.2..latest"
]
}
}

@@ -5,2 +5,6 @@ # ampersand-collection-underscore-mixin

If you're using an [ampersand-rest-collection](http://ampersandjs.com/docs/#ampersand-rest-collection) this is already mixed in for you.
Out of the box, ampersand-collections proxy the [ES5 iteration methods already](http://ampersandjs.com/docs/#ampersand-collection-proxied-es5-array-methods-9) so you don't _have_ to use this mixin, but if you want all the underscore methods, or better browser support, you can use this.
## install

@@ -7,0 +11,0 @@

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