require-blob

Turns arbitrary binary data into a CommonJS compatible module

npm install require-blob
4 downloads in the last month

require-blob

Turns arbitrary binary data into a CommonJS compatible module.

So this random test.jpg image:

Turns into this:

module.exports = function(){
  return "data:image/jpg;base64,/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAABGAAD/4QMtaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI/PiA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJBZG9iZSBYTVAgQ29yZSA1LjMtYzAxMSA2Ni4xNDU2NjEsIDIwMTIvMDIvMDYtMTQ6NTY6MjcgICAgICAgICI+IDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+IDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bXA6Q3JlYXRvclRvb2w9IkFkb2JlIFBob3Rvc2hvcCBDUzYgKE1hY2ludG9zaCkiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6REMyMjQ4RkQ1QTFFMTFFM0I1NjFDMzJDNTY4RTAxQzAiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6REMyMjQ4RkU1QTFFMTFFM0I1NjFDMzJDNTY4RTAxQzAiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpEQzIyNDhGQjVBMUUxMUUzQjU2MUMzMkM1NjhFMDFDMCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpEQzIyNDhGQzVBMUUxMUUzQjU2MUMzMkM1NjhFMDFDMCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pv/uAA5BZG9iZQBkwAAAAAH/2wCEAAQDAwMDAwQDAwQGBAMEBgcFBAQFBwgGBgcGBggKCAkJCQkICgoMDAwMDAoMDA0NDAwRERERERQUFBQUFBQUFBQBBAUFCAcIDwoKDxQODg4UFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFP/AABEIAAQACgMBEQACEQEDEQH/xABUAAEBAAAAAAAAAAAAAAAAAAAABwEBAQEAAAAAAAAAAAAAAAAAAAQFEAADAQAAAAAAAAAAAAAAAAAAYqIoEQACAwAAAAAAAAAAAAAAAAAAYWIjJf/aAAwDAQACEQMRAD8AqOs0oktRv58hrNKFqGfI/9k=";
};

Installation

Install with component(1):

$ component install TooTallNate/require-blob

API

requireBlob(Buffer buf[, String mime]) → String

License

MIT

npm loves you