The following line alters an object that, in some cases, is passed to the library by the user without any expectation that the object might be modified.
|
value.type = ApplicationTag.NULL |
However, I do understand why this is being done, which is to ensure consistency for NULL values. I think replacing that block with a conditional assertion would work much better and make for more informative error messages. Basically, I would suggest going from this:
if (value.value === null) {
value.type = ApplicationTag.NULL
}
To this:
if (value.type === ApplicationTag.NULL) {
assert(value.value === null, 'inconsistent value object, type is ApplicationTag.NULL but value is not null');
}
I stumbled into this because, for performance reasons, I pre-allocate an array of frozen ApplicationTag.NULL values to populate PRIORITY_ARRAY and reading such property network-side (without writing to it!) resulted in this error:
TypeError: Cannot assign to read only property 'type' of object '#<Object>'
The following line alters an object that, in some cases, is passed to the library by the user without any expectation that the object might be modified.
client/src/lib/asn1.ts
Line 662 in 27a399a
However, I do understand why this is being done, which is to ensure consistency for NULL values. I think replacing that block with a conditional assertion would work much better and make for more informative error messages. Basically, I would suggest going from this:
To this:
I stumbled into this because, for performance reasons, I pre-allocate an array of frozen
ApplicationTag.NULLvalues to populatePRIORITY_ARRAYand reading such property network-side (without writing to it!) resulted in this error: