1.0.1 • Published 7 years ago

yy-misc v1.0.1

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

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

return the difference between two numbers (greater - lesser)

Kind: instance method of Misc

ParamType
anumber
bnumber

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}

ParamType
aArray

misc.arraySmallest(a) ⇒ number

finds the smallest number in an array

Kind: instance method of Misc

ParamType
aArray

misc.sameSign(a, b)

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

Kind: instance method of Misc

ParamType
anumber
bnumber
boolean

misc.preciseRound(num, decimals) ⇒ number

round number to certain number of decimals

Kind: instance method of Misc

ParamType
numnumber
decimalsnumber

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

calculate ideal font size

Kind: instance method of Misc

ParamTypeDescription
textstring(use maximum-sized text)
maxWidthnumber
maxHeightnumber
fontFamilystring

misc.wordCount(text) ⇒ number

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

Kind: instance method of Misc

ParamType
textstring

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

ParamType
testnumber
valuenumber
percentnumber

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

ParamType
aArray

misc.clamp(n, min, max) ⇒ number

clamps a number

Kind: instance method of Misc

ParamTypeDescription
nnumberto clamp
minnumber
maxnumber

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