Security News
Highlights from the 2024 Rails Community Survey
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
ember-group-by
Advanced tools
An Ember.js computed property macro for grouping objects by a given property.
ember-group-by provides a computed property macro for grouping objects by a given property.
ember install ember-group-by
import Controller from '@ember/controller';
import groupBy from 'ember-group-by';
export default Controller.extend({
carsByColor: groupBy('model', 'color')
});
This will return an array of POJOs with the following properties:
[
{ property: 'color', value: 'red', items: [car1, car2] },
{ property: 'color', value: 'blue', items: [car3, car4] },
{ property: 'color', value: 'green', items: [car5] }
]
Each group object will have the following properties:
property
The name of the property that you grouped the items byvalue
The value for the property that you grouped the items byitems
All of the objects with the matching value for that propertyYou can then use this in your templates to do cool things like:
<h1>Cars grouped by color</h1>
{{#each carsByColor as |group|}}
<h3>Cars that have {{group.property}} {{group.value}}</h3>
<ul>
{{#each group.items as |car|}}
<li>{{car.name}}</li>
{{/each}}
</ul>
{{/each}}
There is also an example in test/dummy.
npm test
(Runs ember try:each
to test your addon against multiple Ember versions)ember test
ember test --server
For more information on using ember-cli, visit https://ember-cli.com/.
FAQs
An Ember.js computed property macro for grouping objects by a given property.
The npm package ember-group-by receives a total of 633 weekly downloads. As such, ember-group-by popularity was classified as not popular.
We found that ember-group-by demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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.
Security News
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.