Fix ByteArray resize and type-check on Node.js
This commit is contained in:
@@ -59,9 +59,9 @@ class ByteArray #if !js extends Bytes implements ArrayAccess<Int> implements IDa
|
|||||||
|
|
||||||
var factory = function (length:Int) { return new ByteArray (length); };
|
var factory = function (length:Int) { return new ByteArray (length); };
|
||||||
|
|
||||||
#if js
|
#if nodejs
|
||||||
var resize = function (bytes:ByteArray, length:Int) {
|
var resize = function (bytes:ByteArray, length:Int) {
|
||||||
bytes.___resizeBuffer(length);
|
bytes.length = length;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
var resize = function (bytes:ByteArray, length:Int) {
|
var resize = function (bytes:ByteArray, length:Int) {
|
||||||
@@ -73,9 +73,7 @@ class ByteArray #if !js extends Bytes implements ArrayAccess<Int> implements IDa
|
|||||||
};
|
};
|
||||||
#end
|
#end
|
||||||
|
|
||||||
#if html5
|
#if nodejs
|
||||||
var bytes = function (bytes:ByteArray) { return bytes == null ? null : bytes.byteView; }
|
|
||||||
#elseif nodejs
|
|
||||||
var bytes = function (bytes:Dynamic) {
|
var bytes = function (bytes:Dynamic) {
|
||||||
if (Std.is (bytes, ByteArray))
|
if (Std.is (bytes, ByteArray))
|
||||||
return untyped bytes.byteView;
|
return untyped bytes.byteView;
|
||||||
@@ -94,7 +92,10 @@ class ByteArray #if !js extends Bytes implements ArrayAccess<Int> implements IDa
|
|||||||
return untyped bytes.length;
|
return untyped bytes.length;
|
||||||
else if (Std.is (bytes, UInt8Array) ||
|
else if (Std.is (bytes, UInt8Array) ||
|
||||||
Std.is (bytes, UInt16Array) ||
|
Std.is (bytes, UInt16Array) ||
|
||||||
|
Std.is (bytes, UInt32Array) ||
|
||||||
|
Std.is (bytes, Int8Array) ||
|
||||||
Std.is (bytes, Int16Array) ||
|
Std.is (bytes, Int16Array) ||
|
||||||
|
Std.is (bytes, Int32Array) ||
|
||||||
Std.is (bytes, Float32Array))
|
Std.is (bytes, Float32Array))
|
||||||
return untyped bytes.byteLength;
|
return untyped bytes.byteLength;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user