<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents

-   [array][1]
    -   [sortByObjectKey][2]
        -   [Parameters][3]
        -   [Examples][4]
    -   [filterBy][5]
        -   [Parameters][6]
        -   [Examples][7]
    -   [indexCollection][8]
        -   [Parameters][9]
        -   [Examples][10]
-   [date][11]
    -   [beautifySeconds][12]
        -   [Parameters][13]
    -   [beautifyMinutes][14]
        -   [Parameters][15]
    -   [fromBeutyToSeconds][16]
        -   [Parameters][17]
    -   [daysBetween][18]
        -   [Parameters][19]
    -   [curdate][20]
    -   [firstDayOfTheMonth][21]
    -   [lastDayOfTheMonth][22]
        -   [Parameters][23]
-   [string][24]
    -   [resolveUrl][25]
        -   [Parameters][26]
    -   [ucfirst][27]
        -   [Parameters][28]
    -   [capitalize][29]
        -   [Parameters][30]
    -   [ucwords][31]
        -   [Parameters][32]
    -   [excerpt][33]
        -   [Parameters][34]
    -   [uuid][35]
-   [object][36]
    -   [getFlattened][37]
        -   [Parameters][38]
    -   [getFirstFlattened][39]
        -   [Parameters][40]
    -   [setFlattened][41]
        -   [Parameters][42]
    -   [firstKey][43]
        -   [Parameters][44]
    -   [collectionContains][45]
        -   [Parameters][46]
    -   [flatten][47]
        -   [Parameters][48]
    -   [isCyclic][49]
        -   [Parameters][50]

## array

### sortByObjectKey

Sort a collection of objects by one of the keys

#### Parameters

-   `data` **[Array][51]&lt;[Object][52]>** 
-   `prop` **[String][53]** 
-   `direction` **[String][53]** defines if sort should be asc or desc

#### Examples

```javascript
const data = [{id: 1, name: "foo"}, {id: 2, name: "abc"}]
sortByObjectKey(data, "name")
// output will be [{id: 2, name: "abc"}, {id: 1, name: "foo"}]
```

Returns **[Array][51]&lt;[Object][52]>** sorted arrray

### filterBy

Filter a collection of objects by one prop

#### Parameters

-   `key` **[String][53]** 
-   `values` **any** 
-   `items` **[Array][51]&lt;[Object][52]>** 

#### Examples

```javascript
const arr = [{a: 1}, {a: 2}, {a: 3}]
filterBy("a", [1, 3], arr);

// The output will be:
// [{a: 1}, {a: 3}]
```

Returns **[Array][51]&lt;[Object][52]>** 

### indexCollection

Takes an array of objects and transforms it into an object where the keys
are some value of each array

#### Parameters

-   `data` **[Array][51]&lt;[Object][52]>** 
-   `prop` **[String][53]** 

#### Examples

```javascript
const data = [{id: 1, name: "foo"}, {id: 2, name: "abc"}]
indexCollection(data, "id")
// output will be {1: {id: 1, name: "foo"}, {id: 2, name: "abc"}}
```

Returns **[Object][52]** 

## date

### beautifySeconds

Receive a number of seconds and return an string representing the amount of
hours on the format: 00h00m00s
Examples:
beautifySeconds(60, false) => 01m
beautifyMinutes(120, false) => 02m
beautifyMinutes(3900, false) => 1h05m
beautifyMinutes(3900, true) => 1h05m00s

#### Parameters

-   `seconds` **[Number][54]** 
-   `showSeconds` **[Boolean][55]**  (optional, default `true`)

Returns **[string][56]** 

### beautifyMinutes

-   **See: beautifySeconds
    Works the same way as beautifySeconds, but receive an amount of minutes
    **

#### Parameters

-   `minutes` **[Number][54]** 
-   `showSeconds` **[Boolean][55]**  (optional, default `true`)

Returns **[String][53]** 

### fromBeutyToSeconds

Receives an duration with the format 00h00m00s and returns the amount
of seconds. The inverse of beautifySeconds

#### Parameters

-   `theTime` **[String][53]** 

Returns **[Number][54]** 

### daysBetween

Receive two dates and returns the amount of days between them
Dates on the format supported by the Date constructor

#### Parameters

-   `startDateString` **[String][53]** 
-   `endDateString` **[String][53]** 

Returns **[Number][54]** 

### curdate

Returns the current date on the format: yyyy-mm-dd

Returns **[String][53]** 

### firstDayOfTheMonth

Returns the first day of the current month on the format: yyyy-dd-mm

Returns **[String][53]** 

### lastDayOfTheMonth

Returns the last day of the month on the format: yyyy-mm-dd
It accepts an optional month and year to get the last day of an particular month

#### Parameters

-   `month` **([String][53] \| [number][54])** 
-   `year` **([String][53] \| [number][54])** 

Returns **[String][53]** 

## string

### resolveUrl

Add basepath if isn't complete
Consider a complete url when it contains '//'

Examples of complete urls:
[http://google.com][57]
[https://google.com][58]
//google.com

Examples of incomplete urls:
google.com
google
users/create
/users/create

#### Parameters

-   `url` **[String][53]** 
-   `basePath` **[String][53]** basepath to be used, with protocol (optional, default `""`)

Returns **[String][53]** 

### ucfirst

Makes string capitalized

#### Parameters

-   `string` **[String][53]** 

Returns **[string][56]** 

### capitalize

-   **See: App.helpers.string.ucfirst
    **

#### Parameters

-   `string` **[String][53]** 

Returns **[String][53]** 

### ucwords

Makes every word from string capitalized

#### Parameters

-   `string` **[String][53]** 

Returns **[string][56]** 

### excerpt

Will crop the text to fit the maxLength provided. Will try to not break any words
and add "..." on the end of the string

#### Parameters

-   `text` **[String][53]** 
-   `maxLength` **[Number][54]** 

Returns **[String][53]** 

### uuid

generares a UUID
Ref: [http://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript][59]

Returns **[String][53]** 

**Meta**

-   **deprecated**: this function will be removed on next major verson


## object

### getFlattened

Get element from obj by string path
Example:
Given the object let a = {a: {b: 1}}
When you do getFlattened("a.b", a)
Then you get the number 1.

#### Parameters

-   `path` **[string][56]** specify the key of the object you want
-   `obj` **[Object][52]** reference object
-   `defaultValue` **any** value to return if key was not found. Default is null (optional, default `null`)

Returns **any** 

### getFirstFlattened

-   **See: getFlattened
    **

Receives a list of paths and use getFlattened to get the first existent value

#### Parameters

-   `paths` **[Array][51]&lt;[String][53]>** 
-   `obj` **[Object][52]** 
-   `defaultValue` **any?**  (optional, default `null`)

Returns **any** 

### setFlattened

-   **See: getFlattened
    Similar to getFlattened, but it set the value instead of return it.
    Example:
    Given the object let b = {a: {b: 1}}
    When you do setFlattened("a.b", 2)
    Then you get {a: {b: 2}}
    **

#### Parameters

-   `path` **[String][53]** 
-   `newValue` **any** 
-   `obj` **[Object][52]** 

Returns **any** 

### firstKey

Get first key of an object or null if it doesn't have keys

#### Parameters

-   `obj` **[Object][52]** 

Returns **any** 

### collectionContains

Checks if an array of objetcs contain another object (even partially)

#### Parameters

-   `collection` **[Array][51]&lt;[Object][52]>** 
-   `userFilters` **[Object][52]** object to find
-   `detailed` **[Boolean][55]?** if true will return an object with deails about the searc (optional, default `false`)
-   `ignoreCase` **[Boolean][55]?** if true, will ignore case when matching strings (optional, default `false`)

Returns **([Boolean][55] \| [Object][52])** 

### flatten

Transforms an nested object into an flat object with dotted notation
Example: flatten({a: {b: 2}}) will return {"a.b": 2}

#### Parameters

-   `obj` **([Object][52] \| [Array][51])** the source object or array
-   `separator` **[string][56]**  (optional, default `"."`)
-   `prefix` **[string][56]** All keys will be prefixed with this arg (optional, default `""`)

Returns **[Object][52]** 

### isCyclic

Check if any given object has some kind of cyclic reference.

#### Parameters

-   `obj` **[Object][52]** the source to be checked

Returns **[boolean][55]** 

[1]: #array

[2]: #sortbyobjectkey

[3]: #parameters

[4]: #examples

[5]: #filterby

[6]: #parameters-1

[7]: #examples-1

[8]: #indexcollection

[9]: #parameters-2

[10]: #examples-2

[11]: #date

[12]: #beautifyseconds

[13]: #parameters-3

[14]: #beautifyminutes

[15]: #parameters-4

[16]: #frombeutytoseconds

[17]: #parameters-5

[18]: #daysbetween

[19]: #parameters-6

[20]: #curdate

[21]: #firstdayofthemonth

[22]: #lastdayofthemonth

[23]: #parameters-7

[24]: #string

[25]: #resolveurl

[26]: #parameters-8

[27]: #ucfirst

[28]: #parameters-9

[29]: #capitalize

[30]: #parameters-10

[31]: #ucwords

[32]: #parameters-11

[33]: #excerpt

[34]: #parameters-12

[35]: #uuid

[36]: #object

[37]: #getflattened

[38]: #parameters-13

[39]: #getfirstflattened

[40]: #parameters-14

[41]: #setflattened

[42]: #parameters-15

[43]: #firstkey

[44]: #parameters-16

[45]: #collectioncontains

[46]: #parameters-17

[47]: #flatten

[48]: #parameters-18

[49]: #iscyclic

[50]: #parameters-19

[51]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array

[52]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object

[53]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String

[54]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number

[55]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean

[56]: #string

[57]: http://google.com

[58]: https://google.com

[59]: http://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript
