GpsGate Server JavaScript API

Util  1.0.0

GpsGate Server JavaScript API > Util > Franson.Util
Search:
 
Filters

static Class Franson.Util

namespace

Methods

blockArguments

function blockArguments(closure)
creates a bound function that only uses the initally passed arguments this is actually useful in some occasions. setTimeout/setInterval calls the attached function with an undocumented number param(!) for example... example: setTimeout(closeBind(bind(fn, arg1, arg2)), 1000); todo: hmm, perhaps add a function limitNumArguments?
Parameters:
closure <function>
Returns: function
closure wrapped in a guard-closure

chainComparators

BinaryComparator (function(a,b)) chainComparators(comparators)
Lexicographical chaining of multiple comparators.
todo: better name? combine? lexiCombine? todo: integrate this kind of functionality with a prio-queue? todo: move to Functional module example: var cmp = chainComparisons([cmpName, cmpAddress, cmpZipCode])
Parameters:
comparators <BinaryComparator[]> Or individual arguments
Returns: BinaryComparator (function(a,b))

deepClone

object deepClone(obj)
todo: write non-recursive version? todo: this will probably have same problems as mochikit.updatetree when dealing with Date, RegExp etc.. todo: umm, isn't this same as updatetree..? (deprecate) todo: ! fails for Arrays..
Parameters:
obj <object>
Returns: object

equalContent

boolean equalContent(setA, setB)
compares iterable ranges for equal content, but not order (set style). (convenience for empty symmetric difference between the sets.) O(N^2)
Parameters:
setA <Iterable>
setB <Iterable>
Returns: boolean

equalJSON

boolean equalJSON(a, b)
deep equals using JSON representation as definition. useful? (todo: should rather create a "deepCompare" (which wouldn't be dependent on order of properties also for example..))
Parameters:
a <object>
b <object>
Returns: boolean

getUniqueId

integer getUniqueId()
note that this is a unique-id only within the current session. (todo: a random-nr + clock could be more "secure" on a global level)
Returns: integer

isDecimalNumber

boolean isDecimalNumber(str)
This is actually needed since parseInt(str) allows cases like "10xy"! allows leading '-', '+' and surrounding whitespace todo: put in namespace String? todo: create a "parseIntSafe()" using this?
Parameters:
str <string>
Returns: boolean

isIE

boolean isIE()
Determines whether the current browser is Internet Explorer todo: put in a Franson.System module?
Returns: boolean

isNil

boolean isNil(obj)
Parameters:
obj <Object>
Returns: boolean
true if obj is undefined or null

isSizeLike

boolean isSizeLike(obj)
does the object fulfil the Size interface? (w, h number properties)
Parameters:
obj <object>
Returns: boolean

lexicoCmp

integer lexicoCmp(arr0, arr1)
only works on types having a native '<' operator.
intended as a faster (IE..) (but less robust) version of MochiKit.Base.compare()
Parameters:
arr0 <object[]>
arr1 <object[]>
Returns: integer
[-1, 0, +1] (less, equal, greater)

returnFalse

boolean returnFalse()
function that always returns false
Returns: boolean
false

returnTrue

boolean returnTrue()
function that always returns true
Returns: boolean
true

roundToMaxFiexed

string roundToMaxFiexed(value, [numDecimals=3])
Formats a number to a specific maximum number of decimal places. i.e similar to MochiKit.Format.roundToFixed() but will drop trailing 0s
example: roundToMaxFixed(123.0, 3) => "123"
Parameters:
value <float>
[numDecimals=3] <integer>
Returns: string

valueOrDefault

valueOrDefault(value, defaultValue)
Parameters:
value <Object>
defaultValue <Object>


Copyright © 2009 Franson Technology AB, Sweden. All rights reserved.