1.0.6 • Published 6 years ago

@fippli/array-utils v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

JavaScript Array Utils

Help functions for JavaScript Arrays

!

This package might be a mess and be broken from time to time. Will try to make it stable but no guarantees.

Installation

npm install @fippli/array-utils

or

yarn add @fippli/array-utils

How to use

sortObjectArray

Sorts array with objects.

ArgumentsDescriptionExample
Object arrayArray with javascript objects{name: "Optimus prime", type: "Transformer"}, {name: "Batman", type: "Superhero"}, {name: "Magikarp", type: "Pokémon"}
KeyObject key that the array should be sorted on"name"
ReverseBoolean indicating if the sorted order should be reversedtrue

Example:

const characters = [
    {name: "Optimus prime", type: "Transformer"}, 
    {name: "Batman", type: "Superhero"}, 
    {name: "Magikarp", type: "Pokémon"} 
];

sortObjectArray( characters, "name", false );
// Returns:
// [{name: "Batman", type: "Superhero"}, 
//  {name: "Magikarp", type: "Pokémon"} 
//  {name: "Optimus prime", type: "Transformer"}]
         

Bug reports and feature requests are welcome :)

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago