Function fromString

Parses a point as a string, in the form 'x,y' or 'x,y,z'. eg '10,15' will be returned as { x: 10, y: 15 }.

Throws an error if str is not a string.

Points.fromString(`10,15`);  // { x:10, y:15 }
Points.fromString(`a,10`); // { x:NaN, y:10 }

Use Points.isNaN to check if returned point has NaN for either coordinate.

  • Parameters

    • str: string

    Returns Point