GianlucaGuarini / icaro

Smart and efficient javascript object observer, ideal for batching DOM updates (~1kb)
MIT License
573 stars 29 forks source link

Request: Rename toJSON → toBasicObject #1

Closed anko closed 7 years ago

anko commented 7 years ago

To me, JSON means the text format that JavaScript's built-in JSON library is designed to operate on, with JSON.stringify and JSON.parse.

However, calling toJSON on an icaro-wrapped object returns an object (not JSON), which is confusing.

Could we rename it? I'd suggest obj.toBasicObject.

GianlucaGuarini commented 7 years ago

In icaro I am using standards and toJSON [is the method](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#toJSON()_behavior) JSON.stringify uses to convert anything into a string. I don't see any reason to rename this method but thanks for asking anyway

anko commented 7 years ago

Oh man, JavaScript's own naming is confusing. :sweat: Seeing [that](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#toJSON()_behavior), I agree. It would be bad to fight the language spec.