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

ampersand-collection

Package Overview
Dependencies
Maintainers
2
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ampersand-collection - npm Package Compare versions

Comparing version 1.3.3 to 1.3.4

2

package.json
{
"name": "ampersand-collection",
"version": "1.3.3",
"version": "1.3.4",
"author": "Henrik Joreteg <henrik@andyet.net>",

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

@@ -13,2 +13,3 @@ # ampersand-collection

<!-- starthide -->
## browser support

@@ -18,4 +19,5 @@

](https://ci.testling.com/ampersandjs/ampersand-collection)
<!-- endhide -->
## install
## Installation

@@ -26,2 +28,3 @@ ```

<!-- starthide -->
## massive flexibility

@@ -75,4 +78,72 @@

In order to deal with this (because sometimes this is a legitimate scenario), `collection` simply creates a read-only `isCollection` property on all collection objects that can be used to check whether or a not a given object is in fact a collection object no matter what its constructor was.
<!-- endhide -->
## API Reference
### extend `AmpersandCollection.extend([attributes])`
### constructor/initialize `new AmpersandCollection([modelsArray], [options])`
### model `collection.model`
### mainIndex `collection.mainIndex
### indexes `collections.indexes`
### isModel `collection.isModel(model)`
### length `collection.length`
### isCollection `collection.isCollection`
### add `collection.add(modelOrObject)`
### serialize `collection.serialize()`
### toJSON `collection.toJSON()`
### set `collection.set(models, [options])`
### get `collection.get(query, [indexName])`
### at `collection.at(index)`
### remove `collection.remove(models, [options])`
### reset `collection.reset(models, [options])`
### sort `collection.sort([options])`
### **proxied ES5 array methods (9)**
The base AmpersandCollection proxies some basic ES5 methods to the underlying model array:
* indexOf
* lastIndexOf
* every
* some
* forEach
* each (alias for forEach)
* map
* filter
* reduce
* reduceRight
Unlike a backbone collection it doesn not include underscore and all the array methods from underscore, though if you wish more functions than those built into modern browsers, you can mixin [ampersand-collection-underscore-mixin](#ampersand-collection-underscore-mixin) to get them.
```javascript
var people = People([
{ name: 'Phil', hatColor: 'red' },
{ name: 'Jenn', hatColor: 'green' },
{ name: 'Henrik', hatColor: 'blue' },
{ name: 'Julie', hatColor: 'yellow' }
]);
people.map(function (person) { return person.name; }) //=> ['Phil', 'Jenn', 'Henrik', 'Julie']
people.filter(function (person) {
return person.name[0] === 'J';
}) //=> ['Jenn', 'Julie']
```
<!-- starthide -->

@@ -79,0 +150,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