return buffer;
};
+Buffer.isEncoding = function(encoding) {
+ switch ((encoding + '').toLowerCase()) {
+ case 'hex':
+ case 'utf8':
+ case 'utf-8':
+ case 'ascii':
+ case 'binary':
+ case 'base64':
+ case 'ucs2':
+ case 'ucs-2':
+ case 'utf16le':
+ case 'utf-16le':
+ case 'raw':
+ return true;
+
+ default:
+ return false;
+ }
+};
+
// helpers
function coerce(length) {
--- /dev/null
+
+var B = require('../index.js').Buffer;
+var test = require('tape');
+
+test('Buffer.isEncoding', function (t) {
+ t.equal(B.isEncoding('HEX'), true);
+ t.equal(B.isEncoding('hex'), true);
+ t.equal(B.isEncoding('bad'), false);
+});