<commit_before>/* Same license as Node.js
   Maintainer: <NAME>, <EMAIL>

   Node.js 0.6 api without haXe embellishments.
   
*/

package js;

typedef NodeListener = Dynamic;
typedef NodeErr = Null<String>;

/* 
   emits: newListener
 */
typedef NodeEventEmitter = {
  function addListener(event:String,fn:NodeListener):Dynamic;
  function on(event:String,fn:NodeListener):Dynamic;
  function once(event:String,fn:NodeListener):Void;
  function removeListener(event:String,listener:NodeListener):Void;
  function removeAllListeners(event:String):Void;
  function listeners(event:String):Array<NodeListener>;
  function setMaxListeners(m:Int):Void;
  function emit(event:String,?arg1:Dynamic,?arg2:Dynamic,?arg3:Dynamic):Void;
}

typedef NodeWatchOpt = {persistant:Bool,interval:Int};

typedef NodeExecOpt = {
  var encoding:String;
  var timeout:Int;
  var maxBuffer:Int;
  var killSignal:String;
  var env:Dynamic;
  var cwd:String;
}

typedef NodeSpawnOpt = {
  var cwd:String;
  var env:Dynamic;
  var customFds:Array<Int>;
  var setsid:Bool;
}

/* note:can't spec multiple optional args, so adding an arbitrary 3 */
typedef NodeConsole = {
  function log(s:String,?a1:Dynamic,?a2:Dynamic,?a3:Dynamic):Void;
  function info(s:String,?a1:Dynamic,?a2:Dynamic,?a3:Dynamic):Void;
  function warn(s:String,?a1:Dynamic,?a2:Dynamic,?a3:Dynamic):Void;
  function error(s:String,?a1:Dynamic,?a2:Dynamic,?a3:Dynamic):Void;
  function time(label:String):Void;
  function timeEnd(label:String):Void;
  function dir(obj:Dynamic):Void;
  function trace():Void;
  function assert():Void;
}
  
typedef NodePath = {
  function join(?p1:String,?p2:String,?p3:String):String;
  function normalize(p:String):String;
  function resolve(from:Array<String>,to:String):Void;
  function dirname(p:String):String;
  function basename(p:String,?ext:String):String;
  function extname(p:String):String;
  function exists(p:String,cb:Bool->Void):Void;
  function existsSync(p:String):Bool;
}

typedef NodeUrlObj = {
  var href:String;
  var host:String;
  var protocol:String;
  var auth:String;
  var hostname:String;
  var port:String;
  var pathname:String;
  var search:String;
  var query:Dynamic;
  var hash:String;
}

typedef NodeUrl = {
  function parse(p:String,?andQueryString:Bool):NodeUrlObj;
  function format(o:NodeUrlObj):String;
  function resolve(from:Array<String>,to:String):String;
}

typedef NodeQueryString = {
  function parse(s:String,?sep:String,?eq:String):Dynamic;
  function escape(s:String):String;
  function unescape(s:String):String;
  function stringify(obj:Dynamic,?sep:String,?eq:String):String;
}

@:native("Buffer") extern class NodeBuffer implements ArrayAccess<Int> {

   @:overload(function(str:String,enc:String):Void {})
   @:overload(function(arr:Array<Int>):Void {})
  function new(size:Int):Void;

  var length(default,null) : Int;
  var INSPECT_MAX_BYTES:Int;
  
  function copy(targetBuffer:NodeBuffer,targetStart:Int,sourceStart:Int,sourceEnd:Int):Void;
  function slice(start:Int,end:Int):NodeBuffer;
  function write(s:String,?offset:Int,?length:Int,?enc:String):Void;
  function toString(enc:String,?start:Int,?end:Int):String;
  function fill(value:Float,offset:Int,?end:Int):Void;
  static function isBuffer(o:Dynamic):Bool;
  static function byteLength(s:String,?enc:String):Int;

  function readUInt8(offset:Int,?noAssert:Bool):Int;
  function readUInt16LE(offset:Int,?noAssert:Bool):Int;
  function readUInt16BE(offset:Int,?noAssert:Bool):Int;
  function readUInt32LE(offset:Int,?noAssert:Bool):Int;
  function readUInt32BE(offset:Int,?noAssert:Bool):Int;

  function readInt8(offset:Int,?noAssert:Bool):Int;
  function readInt16LE(offset:Int,?noAssert:Bool):Int;<commit_msg>make encoding optional of buffer creation<commit_after>/* Same license as Node.js
   Maintainer: <NAME>, <EMAIL>

   Node.js 0.6 api without haXe embellishments.
   
*/

package js;

typedef NodeListener = Dynamic;
typedef NodeErr = Null<String>;

/* 
   emits: newListener
 */
typedef NodeEventEmitter = {
  function addListener(event:String,fn:NodeListener):Dynamic;
  function on(event:String,fn:NodeListener):Dynamic;
  function once(event:String,fn:NodeListener):Void;
  function removeListener(event:String,listener:NodeListener):Void;
  function removeAllListeners(event:String):Void;
  function listeners(event:String):Array<NodeListener>;
  function setMaxListeners(m:Int):Void;
  function emit(event:String,?arg1:Dynamic,?arg2:Dynamic,?arg3:Dynamic):Void;
}

typedef NodeWatchOpt = {persistant:Bool,interval:Int};

typedef NodeExecOpt = {
  var encoding:String;
  var timeout:Int;
  var maxBuffer:Int;
  var killSignal:String;
  var env:Dynamic;
  var cwd:String;
}

typedef NodeSpawnOpt = {
  var cwd:String;
  var env:Dynamic;
  var customFds:Array<Int>;
  var setsid:Bool;
}

/* note:can't spec multiple optional args, so adding an arbitrary 3 */
typedef NodeConsole = {
  function log(s:String,?a1:Dynamic,?a2:Dynamic,?a3:Dynamic):Void;
  function info(s:String,?a1:Dynamic,?a2:Dynamic,?a3:Dynamic):Void;
  function warn(s:String,?a1:Dynamic,?a2:Dynamic,?a3:Dynamic):Void;
  function error(s:String,?a1:Dynamic,?a2:Dynamic,?a3:Dynamic):Void;
  function time(label:String):Void;
  function timeEnd(label:String):Void;
  function dir(obj:Dynamic):Void;
  function trace():Void;
  function assert():Void;
}
  
typedef NodePath = {
  function join(?p1:String,?p2:String,?p3:String):String;
  function normalize(p:String):String;
  function resolve(from:Array<String>,to:String):Void;
  function dirname(p:String):String;
  function basename(p:String,?ext:String):String;
  function extname(p:String):String;
  function exists(p:String,cb:Bool->Void):Void;
  function existsSync(p:String):Bool;
}

typedef NodeUrlObj = {
  var href:String;
  var host:String;
  var protocol:String;
  var auth:String;
  var hostname:String;
  var port:String;
  var pathname:String;
  var search:String;
  var query:Dynamic;
  var hash:String;
}

typedef NodeUrl = {
  function parse(p:String,?andQueryString:Bool):NodeUrlObj;
  function format(o:NodeUrlObj):String;
  function resolve(from:Array<String>,to:String):String;
}

typedef NodeQueryString = {
  function parse(s:String,?sep:String,?eq:String):Dynamic;
  function escape(s:String):String;
  function unescape(s:String):String;
  function stringify(obj:Dynamic,?sep:String,?eq:String):String;
}

@:native("Buffer") extern class NodeBuffer implements ArrayAccess<Int> {

   @:overload(function(str:String,?enc:String):Void {})
   @:overload(function(arr:Array<Int>):Void {})
  function new(size:Int):Void;

  var length(default,null) : Int;
  var INSPECT_MAX_BYTES:Int;
  
  function copy(targetBuffer:NodeBuffer,targetStart:Int,sourceStart:Int,sourceEnd:Int):Void;
  function slice(start:Int,end:Int):NodeBuffer;
  function write(s:String,?offset:Int,?length:Int,?enc:String):Void;
  function toString(enc:String,?start:Int,?end:Int):String;
  function fill(value:Float,offset:Int,?end:Int):Void;
  static function isBuffer(o:Dynamic):Bool;
  static function byteLength(s:String,?enc:String):Int;

  function readUInt8(offset:Int,?noAssert:Bool):Int;
  function readUInt16LE(offset:Int,?noAssert:Bool):Int;
  function readUInt16BE(offset:Int,?noAssert:Bool):Int;
  function readUInt32LE(offset:Int,?noAssert:Bool):Int;
  function readUInt32BE(offset:Int,?noAssert:Bool):Int;

  function readInt8(offset:Int,?noAssert:Bool):Int;
  function readInt16LE(offset:Int,?noAssert:Bool):Int;
{'fraction_non_alphanumeric': 0.14155128377470091, 'fraction_numerical': 0.00887216023659094, 'mean_word_length': 7.611111111111111, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6087260', 'n_tokens_mistral': 2603, 'n_tokens_neox': 2581, 'n_words': 408}