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

ember-array-computed-macros

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-array-computed-macros - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

59

addon/index.js

@@ -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() {

7

package.json
{
"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 @@

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