yy-misc
v1.0.1
Published
miscellaneous javascript functions
Downloads
2
Readme
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