ember-array-computed-macros
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -5,21 +5,11 @@ import Ember from 'ember'; | ||
export var map = function(listProperty, mapFunction) { | ||
return computed(`${listProperty}.@each`, function() { | ||
return get(this, listProperty).map(mapFunction); | ||
}).readOnly(); | ||
}; | ||
// For your convenience | ||
export var map = Ember.computed.map; | ||
export var mapBy = Ember.computed.mapBy; | ||
export var max = Ember.computed.max; | ||
export var min = Ember.computed.min; | ||
export var filter = Ember.computed.filter; | ||
export var filterBy = Ember.computed.filterBy; | ||
export var sort = Ember.computed.sort; | ||
export var mapBy = function(listProperty, valueProperty) { | ||
return computed(`${listProperty}.@each.${valueProperty}`, function() { | ||
return get(this, listProperty).map((item) => get(item, valueProperty)); | ||
}).readOnly(); | ||
}; | ||
export var max = function(listProperty) { | ||
return computed(`${listProperty}.@each`, function() { | ||
const values = get(this, listProperty); | ||
return Math.max(...values); | ||
}).readOnly(); | ||
}; | ||
export var maxBy = function(listProperty, valueProperty) { | ||
@@ -32,9 +22,2 @@ return computed(`${listProperty}.@each.${valueProperty}`, function() { | ||
export var min = function(listProperty) { | ||
return computed(`${listProperty}.@each`, function() { | ||
const values = get(this, listProperty); | ||
return Math.min(...values); | ||
}).readOnly(); | ||
}; | ||
export var minBy = function(listProperty, valueProperty) { | ||
@@ -47,20 +30,2 @@ return computed(`${listProperty}.@each.${valueProperty}`, function() { | ||
export var filter = function(listProperty, filterFunction) { | ||
return computed(`${listProperty}.@each`, function() { | ||
return get(this, listProperty).filter(filterFunction); | ||
}).readOnly(); | ||
}; | ||
export var filterBy = function(listProperty, valueProperty) { | ||
return computed(`${listProperty}.@each.${valueProperty}`, function() { | ||
return get(this, listProperty).filter((item) => get(item, valueProperty)); | ||
}).readOnly(); | ||
}; | ||
export var sort = function(listProperty, sortFunction = compare ) { | ||
return computed(`${listProperty}.@each`, function() { | ||
return get(this, listProperty).sort(sortFunction); | ||
}).readOnly(); | ||
}; | ||
export var orderBy = function(listProperty, ...sortProperties) { | ||
@@ -98,10 +63,2 @@ sortProperties = sortProperties.map((sortProperty) => { | ||
export var sum = function(listProperty) { | ||
return computed(`${listProperty}.@each`, function() { | ||
return get(this, listProperty).reduce((sum, item) => { | ||
return sum + (item || 0); | ||
}, 0); | ||
}); | ||
}; | ||
export var sumBy = function(listProperty, valueProperty) { | ||
@@ -108,0 +65,0 @@ return computed(`${listProperty}.@each.${valueProperty}`, function() { |
{ | ||
"name": "ember-array-computed-macros", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "The default blueprint for ember-cli addons.", | ||
@@ -14,3 +14,3 @@ "directories": { | ||
}, | ||
"repository": "", | ||
"repository": "https://github.com/martndemus/ember-array-computed-macros", | ||
"engines": { | ||
@@ -35,7 +35,6 @@ "node": ">= 0.10.0" | ||
"ember-computed-decorators": "0.1.4", | ||
"ember-data": "1.13.5", | ||
"ember-disable-prototype-extensions": "^1.0.0", | ||
"ember-disable-proxy-controllers": "^1.0.0", | ||
"ember-export-application-global": "^1.0.2", | ||
"ember-try": "0.0.6" | ||
"ember-try": "0.0.7" | ||
}, | ||
@@ -42,0 +41,0 @@ "keywords": [ |
# ember-array-computed-macros | ||
[![npm version](https://badge.fury.io/js/ember-array-computed-macros.svg)](http://badge.fury.io/js/ember-array-computed-macros) [![Build Status](https://travis-ci.org/martndemus/ember-array-computed-macros.svg?branch=master)](https://travis-ci.org/martndemus/ember-array-computed-macros) | ||
@@ -61,2 +62,20 @@ ## Usage | ||
## Decorators | ||
```js | ||
import Ember from 'ember'; | ||
import { map } from 'ember-array-computed-macros/decorators'; | ||
export default Ember.Component.extend({ | ||
names: [ | ||
{ first: 'Tom', last: 'Dale' }, | ||
{ first: 'Yehuda', last: 'Katz' } | ||
], | ||
@mapBy('names', 'first') | ||
firstNames | ||
}); | ||
``` | ||
## Installation | ||
@@ -63,0 +82,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
17
101
9261
148