🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

ampersand-collection-filterable

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ampersand-collection-filterable

Simple filterable ampersand collections

0.3.0
latest
Source
npm
Version published
Maintainers
1
Created
Source

ampersand-collection-filterable

build status

Simple filterable ampersand collections

Example

var filterable = require('../ampersand-collection-filterable'),
  AmpersandCollection = require('ampersand-collection'),
  AmpersandState = require('ampersand-state');

var Candy = AmpersandState.extend({
  props: {
    id: 'number',
    name: 'string'
  }
});

var CandyCollection = AmpersandCollection.extend(filterable, {model: Candy});

var bag = new CandyCollection([
  {id: 1, name: 'Reese\'s Egg'},
  {id: 2, name: 'Snickers'},
  {id: 3, name: 'Three Musketeers'},
  {id: 4, name: 'Milky Way'},
  {id: 5, name: 'Twix'}
]);

bag.filter(function(candy){
  return candy.name === 'Twix';
});

assert.equal(bag.length, 1);

bag.add({id: 6, name: 'Peppermint Patty'});

assert.equal(bag.length, 1);

bag.unfilter();

assert.equal(bag.length, 6);

Installation

npm install --save ampersand-collection-filterable

Testing

npm test

License

MIT

Keywords

mongodb-js

FAQs

Package last updated on 15 Jan 2020

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