Socket
Socket
Sign inDemoInstall

ember-group-by

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-group-by

An Ember.js computed property macro for grouping objects by a given property.


Version published
Weekly downloads
800
increased by18.52%
Maintainers
2
Weekly downloads
 
Created
Source

ember-group-by

Download count all time Build Status npm version Ember Observer Score Dependencies up to date

ember-group-by provides a computed property macro for grouping objects by a given property.

Installation

ember install ember-group-by

Usage

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 by
  • value The value for the property that you grouped the items by
  • items All of the objects with the matching value for that property

You 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.

Running Tests

  • 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/.

Keywords

FAQs

Package last updated on 19 Sep 2017

Did you know?

Socket

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.

Install

Related posts

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