ember-gather

A handy pair of macros for computing flattened arrays

MIT License

Downloads
4
Stars
3

ember-gather

A handy pair of macros for computing flattened arrays.

Usage

Use gather when you just need to flatten the top-level value of each property into a list:

import { gather } from 'ember-gather';
import Component from 'ember-component';

export default Component.extend({
  terrestrials: ['Mercury', 'Venus', 'Earth', 'Mars'],
  gasGiants: ['Jupiter', 'Saturn', 'Neptune', 'Uranus'],

  planets: gather('terrestrials', 'gasGiants')  // => ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn', 'Neptune', 'Uranus']
});

Use deepGather when you need to flatten all items within all values of each property into a list:

import { deepGather } from 'ember-gather';
import Component from 'ember-component';

const planets = [
  ['Mercury', 'Venus', 'Earth', 'Mars'],
  ['Jupiter', 'Saturn', 'Neptune', 'Uranus']
];

const dwarfPlanets = ['Pluto', 'Ceres', 'Eris', 'Haumes', 'MakeMake'];

export default Component.extend({
  planets,
  dwarfPlanets,

  planetaryBodies: deepGather('planets', 'dwarfPlanets') // => ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn', 'Neptune', 'Uranus', 'Pluto', 'Ceres', 'Eris', 'Haumes', 'MakeMake']
});

Developing

  • git clone <repository-url> this repository
  • cd ember-gather
  • npm install
  • bower install

Running

Running Tests

  • npm test (Runs ember try:each to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit http://ember-cli.com/.