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:
-
expr
Stringthe 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:
-
svg
SVGSVGElementthe svg document to render
getMousePoint
-
container
-
e
Parameters:
-
container
SVGElementthe container reference to get the mouse position from
-
e
MouseEventA 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:
-
x
Objectthe x position of the rectangle
-
y
Numberthe y position of the rectangle
-
w
Numberthe width of the rectangle
-
h
Numberthe 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:
-
element
Elementthe dom element to traverse.
svgToImageUrl
-
svg
Renders an SVG element to a Base64 encoded data URI.
Parameters:
-
svg
SVGSVGElementthe svg element to render