1
0
Fork 0

feat(core): Cast distance to number in Path.offset()

This commit is contained in:
Joost De Cock 2022-10-06 23:12:26 +02:00
parent 513c23d0d8
commit 693243d8e9

View file

@ -540,8 +540,20 @@ Path.prototype.noop = function (id = false) {
* @return {object} this - The Path instance
*/
Path.prototype.offset = function (distance) {
if (typeof distance !== 'number')
this.log.error('Called `Path.offset(distance)` but `distance` is not a number')
if (typeof distance !== 'number') {
if (typeof distance === 'string') {
this.log.error(
'Called `Path.offset(distance)` but `distance` is not a number. Will attempt to cast to Number'
)
try {
distance = Number(distance)
} catch {
this.log.error(
'Called `Path.offset(distance)` but `distance` is not a number nor can it be cast to one'
)
}
} else this.log.error('Called `Path.offset(distance)` but `distance` is not a number')
}
return __pathOffset(this, distance, this.log)
}