bestiejs / json3

A JSON polyfill. No longer maintained.
https://bestiejs.github.io/json3
Other
1.02k stars 150 forks source link

When possible, use JSON as a base when creating a module #6

Closed oyvindkinsey closed 12 years ago

oyvindkinsey commented 12 years ago

Summary: This patch simplifies the process of selecting how to define the module, and also changes it so that JSON is also used as the base of the module when present.

Test Plan: Ran the unit test in /tests without failure.

ghost commented 12 years ago

Hi Øyvind,

Thank you very much for the pull request. I ended up adopting a variant of your fix, which adds support for asynchronous module loaders and Node (this == exports in Node, so JSON 3 will still bypass the native implementation).

The verbose typeof define === "function" && define.amd check is actually necessary for compatibility with the RequireJS optimizer, which uses a hard-coded RegExp to check for the define condition.

The fix will be part of v3.2.1, which I hope to release tomorrow. Sound good?

Thanks again! :star2: