bruth / jsonpatch-js

A JavaScript implementation of the JSON Media Type for partial modifications: http://tools.ietf.org/html/rfc6902
http://bruth.github.io/jsonpatch-js
BSD 2-Clause "Simplified" License
181 stars 24 forks source link

Unable to use as Node.js module #4

Closed rudolf closed 12 years ago

rudolf commented 12 years ago

Hi,

The 'run everywhere boilerplate' isn't working for Node.js. My understanding is that Node.js is a CommonJS environment, although the boilerplate runs it as a 'direct script'.

A solution working for me is to add this before the other if cases:

if typeof module isnt 'undefined' and typeof exports isnt 'undefined'       
    # Node.js environment                                                   
    factory(exports)

But perhaps a better approach is: https://gist.github.com/1663811

rudolf commented 12 years ago

Thanks, works great.