# yy-misc v1.0.1

## misc.js

miscellaneous javascript functions

## Installation

include misc.js in your project or add to your workflow

`npm install yy-misc`

## API Reference

**Kind**: global class

- Misc
- .difference(a, b) â‡’ number
- .arrayCount(a) â‡’ object
- .arraySmallest(a) â‡’ number
- .sameSign(a, b)
- .preciseRound(num, decimals) â‡’ number
- .fontSize(text, maxWidth, [maxHeight], [fontFamily])
- .wordCount(text) â‡’ number
- .aboutEqual(test, value, percent) â‡’ boolean
- .uniqueArray(a) â‡’ Array
- .clamp(n, min, max) â‡’ number

### misc.difference(a, b) â‡’ number

return the difference between two numbers (greater - lesser)

**Kind**: instance method of Misc

Param | Type |
---|---|

a | number |

b | number |

### misc.arrayCount(a) â‡’ object

returns {most, least, all[]} array grouped by value

**Kind**: instance method of Misc**Returns**: object - {most: most, least: least, all: Array}

Param | Type |
---|---|

a | Array |

### misc.arraySmallest(a) â‡’ number

finds the smallest number in an array

**Kind**: instance method of Misc

Param | Type |
---|---|

a | Array |

### misc.sameSign(a, b)

returns whether a and b have the same sign or both equal 0

**Kind**: instance method of Misc

Param | Type |
---|---|

a | number |

b | number |

boolean |

### misc.preciseRound(num, decimals) â‡’ number

round number to certain number of decimals

**Kind**: instance method of Misc

Param | Type |
---|---|

num | number |

decimals | number |

### misc.fontSize(text, maxWidth, maxHeight, fontFamily)

calculate ideal font size

**Kind**: instance method of Misc

Param | Type | Description |
---|---|---|

text | string | (use maximum-sized text) |

maxWidth | number | |

maxHeight | number | |

fontFamily | string |

### misc.wordCount(text) â‡’ number

from: http://stackoverflow.com/questions/6543917/count-number-of-words-in-string-using-javascript

**Kind**: instance method of Misc

Param | Type |
---|---|

text | string |

### misc.aboutEqual(test, value, percent) â‡’ boolean

returns whether the test value is about equal to the value (i.e., within the given percentage)

**Kind**: instance method of Misc

Param | Type |
---|---|

test | number |

value | number |

percent | number |

### misc.uniqueArray(a) â‡’ Array

Removes duplicates from array and returns new array from http://stackoverflow.com/questions/9229645/remove-duplicates-from-javascript-array

**Kind**: instance method of Misc

Param | Type |
---|---|

a | Array |

### misc.clamp(n, min, max) â‡’ number

clamps a number

**Kind**: instance method of Misc

Param | Type | Description |
---|---|---|

n | number | to clamp |

min | number | |

max | number |

Copyright (c) 2016 YOPEY YOPEY LLC - MIT License - Documented by jsdoc-to-markdown