API Docs for:
Show:

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.

Methods

default

(
  • expr
)
Function

Parameters:

  • expr String

    the expression to parse

Returns:

Function:

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 SVGSVGElement

    the svg document to render

getMousePoint

(
  • container
  • e
)
Object

Parameters:

  • container SVGElement

    the container reference to get the mouse position from

  • e MouseEvent

    A DOM mouse event

Returns:

Object:

the {x, y} data of the mouse position relative to the container

getRectPath

(
  • x
  • y
  • w
  • h
)
String

Creates an SVG path string for a rectangle

Parameters:

  • x Object

    the x position of the rectangle

  • y Number

    the y position of the rectangle

  • w Number

    the width of the rectangle

  • h Number

    the height of the rectangle

Returns:

String:

the svg path string for the rectangle

inlineAllStyles

(
  • element
)
private

Traverses an element and all of its descendants, setting their inline style property to whatever the computed style is.

Parameters:

  • element Element

    the dom element to traverse.

svgToImageUrl

(
  • svg
)

Renders an SVG element to a Base64 encoded data URI.

Parameters:

  • svg SVGSVGElement

    the svg element to render