Skip to content

Commit

Permalink
Merge pull request #116 from Gama11/js.html
Browse files Browse the repository at this point in the history
Avoid deprecation warnings in Buffer with Haxe dev
  • Loading branch information
nadako authored Mar 12, 2019
2 parents 8e8f8dd + 4d306e0 commit 35c76fd
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/js/node/buffer/Buffer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,22 @@
*/
package js.node.buffer;

#if haxe4
import js.lib.ArrayBuffer;
import js.lib.Uint8Array;
#else
import js.html.ArrayBuffer;
import js.html.Uint8Array;
#end

/**
The Buffer class is a global type for dealing with binary data directly. It can be constructed in a variety of ways.
It supports array access syntax to get and set the octet at index. The values refer to individual bytes,
so the legal range is between 0x00 and 0xFF hex or 0 and 255.
**/
@:jsRequire("buffer", "Buffer")
extern class Buffer extends js.html.Uint8Array {
extern class Buffer extends Uint8Array {

/**
How many bytes will be returned when `buffer.inspect()` is called.
Expand Down Expand Up @@ -107,7 +115,7 @@ extern class Buffer extends js.html.Uint8Array {
**/
@:overload(function(string:String, ?encoding:String):Void {})
@:overload(function(buffer:Buffer):Void {})
@:overload(function(arrayBuffer:js.html.ArrayBuffer, ?byteOffset:Int, ?length:Int):Void {})
@:overload(function(arrayBuffer:ArrayBuffer, ?byteOffset:Int, ?length:Int):Void {})
@:overload(function(array:Array<Int>):Void {})
function new(size:Int):Void;

Expand Down Expand Up @@ -142,7 +150,7 @@ extern class Buffer extends js.html.Uint8Array {

@:overload(function(buffer:Buffer):Buffer {})
@:overload(function(str:String, ?encoding:String):Buffer {})
static function from(arrayBuffer:js.html.ArrayBuffer, ?byteOffset:Int, ?length:Int):Buffer;
static function from(arrayBuffer:ArrayBuffer, ?byteOffset:Int, ?length:Int):Buffer;

/**
Returns a JSON-representation of the `Buffer` instance.
Expand Down

0 comments on commit 35c76fd

Please sign in to comment.