1.0.16 • Published 7 years ago
@kengres/config v1.0.16
@kengres/config
useful functions, sass mixins and other reusable code for my projects
how to use
css
// in your root scss file import the index.scss from node_modules
@import '@kengres/config/lib/css/index.scss';
javascript functions
groupBy()
- receives and array of objects and the property to group by
// examples
const arr = [
{ name: 'Alan', city: 'Berlin' age: 22 },
{ name: 'Bikovkiy', city: 'Moscow' age: 22 },
{ name: 'Maria', city: 'Moscow' age: 22 },
{ name: 'Alan', city: 'Berlin' age: 22 }
];
const grouped = groupBy(arr, 'city'); // property must be a string
// output
{
Moscow: [
{ name: 'Bikovkiy', city: 'Moscow' age: 22 },
{ name: 'Maria', city: 'Moscow' age: 22 }
],
Berlin: [
{ name: 'Alan', city: 'Berlin' age: 22 },
{ name: 'Alan', city: 'Berlin' age: 22 }
]
}