I need to convert some hex in my angularjs web program. We are using a version of lineman
that supports including of single js files into angularjs. I have packaged the Buffer into a single file for this purpose. I'm a little lost on how to define this in Angular though.
Here is what I have so far:
echo exports.Buffer=Buffer > buffer.js
browserify -s buffer buffer.js > vendor/js/buffer.js
rm buffer.js
And now to test it:
nodejs
> b=require('./vendor/js/buffer.js')
{ Buffer:
{ [Function: Buffer]
poolSize: 8192,
TYPED_ARRAY_SUPPORT: true,
isBuffer: [Function],
compare: [Function],
isEncoding: [Function],
concat: [Function],
byteLength: [Function],
_augment: [Function] } }
> b.Buffer
{ [Function: Buffer]
poolSize: 8192,
TYPED_ARRAY_SUPPORT: true,
isBuffer: [Function],
compare: [Function],
isEncoding: [Function],
concat: [Function],
byteLength: [Function],
_augment: [Function] }
Now it would be nice to define it in app.coffee like this:
angular.module("app").service("Buffer", [Buffer])
This is the error:
Uncaught ReferenceError: Buffer is not defined