Skip to content

Util

@namespace Util

Various utility functions, used by Leaflet internally.

Methods

MethodReturnsDescription
stamp(obj: Object)NumberReturns the unique ID of an object, assigning it one if it doesn't have it.
throttle(fn: Function, time: Number, context: Object)FunctionReturns a function which executes function fn with the given scope context
wrapNum(num: Number, range: Number[], includeMax?: Boolean)NumberReturns the number num modulo range in such a way so it lies within
falseFn()FunctionReturns a function which always returns false.
`formatNum(num: Number, precision?: Numberfalse)`Number
splitWords(str: String)String[]Trims and splits the string on whitespace and returns the array of parts.
setOptions(obj: Object, options: Object)ObjectMerges the given properties to the options of the obj object, returning the resulting options. See Class options.
template(str: String, data: Object)StringSimple templating facility, accepts a template string of the form 'Hello {a}, {b}'