I've been working with several js libs lately, patching them to work
inside the browser (inside a web worker thread) and also in node.js.

I would like to suggest the following "wrapper" to the current
openpgp.js lib. This would have several advantages.

1. It removes all members from the global scope.
2. It enables node.js support
3. Its very simple to do, since we would just have to add a prefix and
suffix js file to the build process like so:


var openpgp = (function (window, document) {

  var exports = {};

  // cat openpgp.js files here and append puplic api to 'exports'

  return exports;

})((typeof window !== 'undefined') ? window : null, (typeof document
!== 'undefined') ? document : null);

// for node.js support
if (typeof module !== 'undefined' && module.exports) {
  module.exports = openpgp;
}
_______________________________________________

http://openpgpjs.org

Reply via email to