native-buffer-browserify
Advanced tools
Comparing version 2.0.16 to 2.0.17
@@ -120,2 +120,6 @@ require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"SwUZZb":[function(require,module,exports){ | ||
case 'raw': | ||
case 'ucs2': | ||
case 'ucs-2': | ||
case 'utf16le': | ||
case 'utf-16le': | ||
return true | ||
@@ -132,16 +136,30 @@ default: | ||
Buffer.byteLength = function (str, encoding) { | ||
var ret | ||
str = str + '' | ||
switch (encoding || 'utf8') { | ||
case 'hex': | ||
return str.length / 2 | ||
ret = str.length / 2 | ||
break | ||
case 'utf8': | ||
case 'utf-8': | ||
return utf8ToBytes(str).length | ||
ret = utf8ToBytes(str).length | ||
break | ||
case 'ascii': | ||
case 'binary': | ||
return str.length | ||
case 'raw': | ||
ret = str.length | ||
break | ||
case 'base64': | ||
return base64ToBytes(str).length | ||
ret = base64ToBytes(str).length | ||
break | ||
case 'ucs2': | ||
case 'ucs-2': | ||
case 'utf16le': | ||
case 'utf-16le': | ||
ret = str.length * 2 | ||
break | ||
default: | ||
throw new Error('Unknown encoding') | ||
} | ||
return ret | ||
} | ||
@@ -262,2 +280,6 @@ | ||
case 'utf-8': | ||
case 'ucs2': // TODO: No support for ucs2 or utf16le encodings yet | ||
case 'ucs-2': | ||
case 'utf16le': | ||
case 'utf-16le': | ||
return _utf8Write(this, string, offset, length) | ||
@@ -293,2 +315,6 @@ case 'ascii': | ||
case 'utf-8': | ||
case 'ucs2': // TODO: No support for ucs2 or utf16le encodings yet | ||
case 'ucs-2': | ||
case 'utf16le': | ||
case 'utf-16le': | ||
return _utf8Slice(self, start, end) | ||
@@ -295,0 +321,0 @@ case 'ascii': |
34
index.js
@@ -119,2 +119,6 @@ var base64 = require('base64-js') | ||
case 'raw': | ||
case 'ucs2': | ||
case 'ucs-2': | ||
case 'utf16le': | ||
case 'utf-16le': | ||
return true | ||
@@ -131,16 +135,30 @@ default: | ||
Buffer.byteLength = function (str, encoding) { | ||
var ret | ||
str = str + '' | ||
switch (encoding || 'utf8') { | ||
case 'hex': | ||
return str.length / 2 | ||
ret = str.length / 2 | ||
break | ||
case 'utf8': | ||
case 'utf-8': | ||
return utf8ToBytes(str).length | ||
ret = utf8ToBytes(str).length | ||
break | ||
case 'ascii': | ||
case 'binary': | ||
return str.length | ||
case 'raw': | ||
ret = str.length | ||
break | ||
case 'base64': | ||
return base64ToBytes(str).length | ||
ret = base64ToBytes(str).length | ||
break | ||
case 'ucs2': | ||
case 'ucs-2': | ||
case 'utf16le': | ||
case 'utf-16le': | ||
ret = str.length * 2 | ||
break | ||
default: | ||
throw new Error('Unknown encoding') | ||
} | ||
return ret | ||
} | ||
@@ -261,2 +279,6 @@ | ||
case 'utf-8': | ||
case 'ucs2': // TODO: No support for ucs2 or utf16le encodings yet | ||
case 'ucs-2': | ||
case 'utf16le': | ||
case 'utf-16le': | ||
return _utf8Write(this, string, offset, length) | ||
@@ -292,2 +314,6 @@ case 'ascii': | ||
case 'utf-8': | ||
case 'ucs2': // TODO: No support for ucs2 or utf16le encodings yet | ||
case 'ucs-2': | ||
case 'utf16le': | ||
case 'utf-16le': | ||
return _utf8Slice(self, start, end) | ||
@@ -294,0 +320,0 @@ case 'ascii': |
{ | ||
"name": "native-buffer-browserify", | ||
"version": "2.0.16", | ||
"version": "2.0.17", | ||
"description": "buffer module compatibility for browserify (backed by ArrayBuffer so its fast!)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -39,9 +39,9 @@ # native-buffer-browserify | ||
## important Differences | ||
## important differences | ||
### Use `Buffer.isBuffer` instead of `instanceof Buffer`. | ||
### use `Buffer.isBuffer` instead of `instanceof Buffer` | ||
The Buffer constructor returns a `Uint8Array` (as discussed above) for performance reasons, so `instanceof Buffer` won't work. In node `Buffer.isBuffer` just does `instanceof Buffer`, but in browserify we use a `Buffer.isBuffer` shim that detects our special `Uint8Array`-based Buffers. | ||
### Don't rely on `slice()` to modify the memory of the parent buffer. | ||
### don't rely on `slice()` to modify the memory of the parent buffer | ||
@@ -48,0 +48,0 @@ If the browser is using the Typed Array implementation then modifying a buffer created by `slice()` will modify the original memory, [just like in Node](http://nodejs.org/api/buffer.html#buffer_buf_slice_start_end). But for the Object implementation (used in unsupported browsers), this is not possible. Therefore, do not rely on this behavior until browser support gets better. (Note: currently even Firefox isn't using the Typed Array implementation because of [this bug](https://bugzilla.mozilla.org/show_bug.cgi?id=952403).) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1249834
18893