['a', 48.0, 48.0, 0.0, 1.0, 1.0, 48.0, -48.0],
['a', 48.0, 48.0, 0.0, 0.0, 1.0, -48.0, 48.0]
])
+
+ expect(pathParser('M0+0 L100+0 L50+100')).toEqual([
+ ['M', 0, 0],
+ ['L', 100, 0],
+ ['L', 50, 100]
+ ])
})
})
})
return parser.lastToken.toUpperCase() === 'E'
}
+const pathDelimiters = new Set([' ', ',', '\t', '\n', '\r', '\f'])
export function pathParser(d, toAbsolute = true) {
let index = 0
let token = ''
continue
}
- if (token === ' ' || token === ',') {
+ if (pathDelimiters.has(token)) {
if (parser.inNumber) {
finalizeNumber(parser, false)
}
continue
}
- if (token === '-') {
+ if (token === '-' || token === '+') {
if (parser.inNumber && !isExponential(parser)) {
finalizeNumber(parser, false)
--index