slice = Array::slice
Look what you make me do Javascript
slice = Array::slice
DOM simplifier (no jQuery dependency) NodeJS compatible
$ = (sel, root = document) ->
return sel if typeof sel is "object" or exports?
root.querySelector sel
class Util
Unique value utility
@uniqid = do ->
id = 0
get: -> id++
Helper function that extends one object with all the properies of other objects
@extend = (obj, src...) ->
dest = obj
for copy in src
for own prop of copy
dest[prop] = copy[prop]
return dest
In order to stay true to the latest spec, RGB values must be clamped between 0 and 255. If we don't do this, weird things happen.
@clampRGB = (val) ->
switch val >> 8
when 0 then val
when -1 then 0
when 1 then 255
@copyAttributes: (from, to, opts={}) ->
for attr in from.attributes
continue if opts.except? and attr.nodeName in opts.except
to.setAttribute(attr.nodeName, attr.nodeValue)
Support for browsers that don't know Uint8Array (such as IE9)
@dataArray: (length = 0) ->
return new Uint8Array(length) if Caman.NodeJS or window.Uint8Array?
return new Array(length)