For ow.isValid, it's acutually not necessary to inference the stack for the label because the message won't actually be used.
For the check of elements, e.g. ow.object.valuesOfType, ow.array.ofType, ow.map.keysOfType, ow.map.valuesOfType, ow.set.ofType, the inference of the label can also be avoided.
The original reason why I want to avoid the inference of label is not because of performance. It was because Error.prototype.stack is not in the standard. And it isn't available in Goja. When ow tries to use callsites to inference the stack, it will cause an error TypeError: Cannot read property 'slice' of undefined or null because of this line. For most cases, users of ow can explicitly specify the label to avoid the inference such as ow(value, 'value', ow.string). However, the cases mentioned above is out of the control of the users.
After the change in this PR, the error message is changed for some cases. I'm not sure if it is acceptable. If anyone has a better idea for this problem, feel free to commit to my branch or close my PR and create your own. :)
ow.isValid
, it's acutually not necessary to inference the stack for the label because the message won't actually be used.ow.object.valuesOfType
,ow.array.ofType
,ow.map.keysOfType
,ow.map.valuesOfType
,ow.set.ofType
, the inference of the label can also be avoided.Error.prototype.stack
is not in the standard. And it isn't available in Goja. Whenow
tries to usecallsites
to inference the stack, it will cause an errorTypeError: Cannot read property 'slice' of undefined or null
because of this line. For most cases, users ofow
can explicitly specify the label to avoid the inference such asow(value, 'value', ow.string)
. However, the cases mentioned above is out of the control of the users.