utils.parse-property-expression Class
A function that will parse a path expression into a "getter" function that can retrieve a value from that path off of any object when called.
Example
import parsePropertyExpr from 'utils/parse-property-expr';
var test = { foo: { bar: ['apple', 'banana'] } };
var getFooBar1 = parsePropertyExpr('foo.bar[1]');
var result = getFooBar1(test);
console.log(result); // "banana"
Notes
Will return undefined if the nothing is at the end of the path, or the
path cannot be reached.
Item Index
Methods
default
-
expr
Parameters:
-
exprStringthe expression to parse
Returns:
a function that when called with an object, will locate the value at the end of the expressed path.
downloadSvg
-
svg
Triggers a download of an image rendered from the passed svg document
Parameters:
-
svgSVGSVGElementthe svg document to render
getMousePoint
-
container -
e
Parameters:
-
containerSVGElementthe container reference to get the mouse position from
-
eMouseEventA DOM mouse event
Returns:
the {x, y} data of the mouse position relative to the container
getRectPath
-
x -
y -
w -
h
Creates an SVG path string for a rectangle
Parameters:
-
xObjectthe x position of the rectangle
-
yNumberthe y position of the rectangle
-
wNumberthe width of the rectangle
-
hNumberthe height of the rectangle
Returns:
the svg path string for the rectangle
inlineAllStyles
-
element
Traverses an element and all of its descendants, setting their inline style property to whatever the computed style is.
Parameters:
-
elementElementthe dom element to traverse.
svgToImageUrl
-
svg
Renders an SVG element to a Base64 encoded data URI.
Parameters:
-
svgSVGSVGElementthe svg element to render
