Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
ember-array-computed-macros
Advanced tools
This addon is supplemental to the already existing computed macros existing in Ember.js
This addon is supplemental to the already existing array computed macros existing in Ember.js
maxBy(listProperty, valueProperty)
Takes all values of valueProperty
from listProperty
and then picks the maximum value from that.
Example:
var ContactList = Ember.Component.extend({
highestAge: maxBy('people', 'age')
});
const myContactList = ContactList.create({
people: [
{ first: 'Tom', last: 'Dale', age: 21 },
{ first: 'Yehuda', last: 'Katz', age: 42 }
]
}).
myContactList.get('highestAge') // returns 42
minBy(listPropery, valueProperty)
See maxBy
, except it takes the minimum value instead of the maximum.
orderBy(listProperty, ...sortProperties)
Takes a listProperty
and returns that list sorted by the sortProperties
.
Append :desc
to the sort property to sort in reverse order for that property.
import Ember from 'ember';
import { map } from 'ember-array-computed-macros';
export default Ember.Component.extend({
names: [
{ first: 'Tom', last: 'Dale', age: 21 },
{ first: 'Yehuda', last: 'Katz', age: 42 }
],
orderedNames: orderBy('names', 'last', 'first'. 'age:desc')
});
There is also a variant for groupBy
that works with a dynamic list of
sortProperties called groupByComputedProperty
:
import Ember from 'ember';
import { map } from 'ember-array-computed-macros';
export default Ember.Component.extend({
names: [
{ first: 'Tom', last: 'Dale', age: 21 },
{ first: 'Yehuda', last: 'Katz', age: 42 }
],
nameOrdering: ['last', 'first', 'age:desc'],
orderedNames: orderByComputedProperty('names', 'nameOrdering')
});
groupBy(listProperty, valueProperty)
Pushes all items in listProperty
that have the same value at valueProperty
into an array.
var ContactList = Ember.Component.extend({
groupedByAge: groupBy('people', 'age')
});
const myContactList = ContactList.create({
people: [
{ first: 'Tom', last: 'Dale', age: 21 },
{ first: 'Yehuda', last: 'Katz', age: 42 },
{ first: 'Robert', last: 'Jackson', age: 42 },
{ first: 'Stefan', last: 'Penner', age 33 }
]
}).
myContactList.get('groupedByAge') // returns:
//[
// [
// { first: 'Tom', last: 'Dale', age: 21 }
// ],
// [
// { first: 'Yehuda', last: 'Katz', age: 42 },
// { first: 'Robert', last: 'Jackson', age: 42 }
// ],
// [
// { first: 'Stefan', last: 'Penner', age 33 }
// ]
//]
sumBy(listProperty, valueProperty)
Takes all values of valueProperty
from listProperty
and then sums those values.
Example:
var ContactList = Ember.Component.extend({
collectiveAge: sumBy('people', 'age')
});
const myContactList = ContactList.create({
people: [
{ first: 'Tom', last: 'Dale', age: 21 },
{ first: 'Yehuda', last: 'Katz', age: 42 }
]
}).
myContactList.get('collectiveAge') // returns 53
meanBy(listProperty, valueProperty)
Takes all values of valueProperty
from listProperty
and calculate their arithmetic mean value.
Example:
var ContactList = Ember.Component.extend({
averageAge: meanBy('people', 'age')
});
const myContactList = ContactList.create({
people: [
{ first: 'Tom', last: 'Dale', age: 21 },
{ first: 'Yehuda', last: 'Katz', age: 42 }
]
}).
myContactList.get('collectiveAge') // returns 31.5
reverse(listProperty)
Reverses the array at listProperty
with Array.prototype.reverse
.
everyBy(listPropery, valueProperty)
Takes all values of valueProperty
from listProperty
and then checks if all of those values are truthy.
anyBy(listProperty, valueProperty)
Takes all values of valueProperty
from listProperty
and then checks if any of those values are truthy.
The addon re-exports all array computed macros from Ember.js for convenience.
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
});
git clone
this repositorynpm install
bower install
ember server
ember test
ember test --server
ember build
For more information on using ember-cli, visit http://www.ember-cli.com/.
FAQs
This addon is supplemental to the already existing computed macros existing in Ember.js
We found that ember-array-computed-macros demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.