Permalink
Browse files

Fix "there is no any Buffer" error on browerified version.

  • Loading branch information...
1 parent f2b3ace commit e5720131b1a7700d4788a1b4451b240b54f1e309 @dervus dervus committed Feb 8, 2013
Showing with 7 additions and 5 deletions.
  1. +7 −5 lib/js-yaml/type/binary.js
View
@@ -4,9 +4,11 @@
'use strict';
-var common = require('../common');
-var NIL = common.NIL;
-var Type = require('../type');
+var NodeBuffer = require('buffer').Buffer; // A trick for browserified version.
+var common = require('../common');
+var NIL = common.NIL;
+var Type = require('../type');
+
var BASE64_PADDING = '=';
@@ -66,7 +68,7 @@ function resolveYamlBinary(object /*, explicit*/) {
if (leftbits) {
return NIL;
} else {
- return new Buffer(result);
+ return new NodeBuffer(result);
}
}
@@ -110,7 +112,7 @@ module.exports = new Type('tag:yaml.org,2002:binary', {
},
dumper: {
kind: 'object',
- instanceOf: Buffer,
+ instanceOf: NodeBuffer,
representer: representYamlBinary
}
});

0 comments on commit e572013

Please sign in to comment.