RyanMarcus / dirty-json

A parser for invalid JSON
GNU Affero General Public License v3.0
294 stars 30 forks source link

Enumerable properties of arrays #24

Closed Moai- closed 4 years ago

Moai- commented 4 years ago

Thank you for the great project, it helped enormously with loosening the requirements around quotes and such. That said, the project completely breaks all for/in loops because it adds peek and last methods to all arrays, and the loop thinks it's an index. These need to be non-enumerable; I will submit a PR if necessary.

RyanMarcus commented 4 years ago

Wow, I didn't realize that I was modifying the global prototype of Array. That's definitely no good. Is there a way to only modify the prototype locally? Or should I just refactor the code?

Moai- commented 4 years ago

Yessir, there is. You define them using Object.defineProperty; I have submitted a pull request for your convenience.

RyanMarcus commented 4 years ago

Awesome! Thanks so much. Fixed version available on NPM, 0.9.0.

Moai- commented 4 years ago

Confirm that issue is fixed on 0.9.0, thanks for the bump.