index.js 994 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. const Zlib = module.exports = require('./zlib');
  2. // the least I can do is make error messages for the rest of the node.js/zlib api.
  3. // (thanks, dominictarr)
  4. function error () {
  5. var m = [].slice.call(arguments).join(' ')
  6. throw new Error([
  7. m,
  8. 'we accept pull requests',
  9. 'http://github.com/brianloveswords/zlib-browserify'
  10. ].join('\n'))
  11. }
  12. ;['createGzip'
  13. , 'createGunzip'
  14. , 'createDeflate'
  15. , 'createDeflateRaw'
  16. , 'createInflate'
  17. , 'createInflateRaw'
  18. , 'createUnzip'
  19. , 'Gzip'
  20. , 'Gunzip'
  21. , 'Inflate'
  22. , 'InflateRaw'
  23. , 'Deflate'
  24. , 'DeflateRaw'
  25. , 'Unzip'
  26. , 'inflateRaw'
  27. , 'deflateRaw'].forEach(function (name) {
  28. Zlib[name] = function () {
  29. error('sorry,', name, 'is not implemented yet')
  30. }
  31. });
  32. const _deflate = Zlib.deflate;
  33. const _gzip = Zlib.gzip;
  34. Zlib.deflate = function deflate(stringOrBuffer, callback) {
  35. return _deflate(Buffer(stringOrBuffer), callback);
  36. };
  37. Zlib.gzip = function gzip(stringOrBuffer, callback) {
  38. return _gzip(Buffer(stringOrBuffer), callback);
  39. };