Javascript Utility Classes

Posted: June 25th, 2011 | Author: | Filed under: Javascript | Tags: , , | No Comments »

I have recently started porting some of my most used Actionscript utility classes to javascript.

You can probably find most of this (and a whole lot more) in libraries such as Underscore.js, but what can I say – I like things my own way. Anyway, this is what I’ve got so far.

Javadoc-style documentation is available in the source files.

ArrayUtil methods:
left, right, copy, toggle, remove, contains, shuffle, validIndex, getRandom, swap, unique, insert, insertBefore, insertAfter

KeyUtil methods:
isEnter, isBackspace, isTab, isAlt, isCtrl, isShift, isSpace, isEsc, isHome, isEnd, isPageDown, isPageUp, isDelete, isLeft, isRight, isUp, isDown, isNumPlus, isNumMinus, isCopy, isCut, isPaste, isSave, isSelectAll, isPrint

NumberUtil methods:
ceilTo, degreesToRadians, delta, diff, floorTo, isBetween, isEven, isFloat, isInteger, isOdd, isPrime, limit, radiansToDegrees, randomFloat, randomInt, randomSign, roundTo, roundToDecimals

StringUtil methods:
contains, upperCaseFirst, upperCaseWords, upperCaseSentence, stripWhiteSpace, trim, trimLeft, trimRight, startsWith, endsWith, replace, remove, truncate, numberFormat

TypeUtil methods:
isNumeric, isInteger, isFloat, isString, isArray, isBoolean, isObject, isFunction, isDate, isDOMElement

ValidationUtil methods: (norwegian formats)
isEmail, isPhone, isMobile, isDate, isZip, isIpAddress, isUrl, isDomain, notEmpty, isNumericOnly, isAlphabeticOnly, noWhiteSpace, noSpecialCharacters

You can download the classes here.


Comments are closed.