Standard library improvements: exceptions, string triming with a trimed chars specified, min/max for integers and so on.

To install, run:

haxelib install stdlib 2.2.2 

See using Haxelib in Haxelib documentation for more information.

stdlib haxe library

Light library with a basic stuff: events, dumps, regexps, exceptions, uuids.

stdlib.Std class

This class extends standard Std.

Std.parseInt(s, defaultValue)
Std.parseFloat(s, defaultValue)
Std.bool(v)           // return *true* except *v* is: false, null, 0, "", "0", "false", "off", "null"
Std.parseValue(s)     // return Bool, Int, Float or String
Std.hash(obj)         // make a map from object fields
Std.min(a, b)         // min for Int
Std.max(a, b)         // max for Int
Std.sign(f)           // return -1.0 / 0.0 / +1.0

stdlib.StringTools class

This class extends standard StringTools.

StringTools.ltrim(s, chars)
StringTools.rtrim(s, chars)
StringTools.trim(s, chars)
StringTools.addcslashes(s) // like addcslashes in php

stdlib.Exception class

   if (isBad1) throw new Exception("smart exception"); // guarantees you to have a call stack in the catch
   if (isBad2) throw "native exception";
catch (e:Dynamic)

stdlib.Event class

// define event with args a and b
var click = new Event<{ a:Int, b:String }>(this); // target = this

// attach handler
click.bind(function(target:Dynamic, e:{ a:Int, b:String })
    // handler code

// fire event{ a:10, b:"xyz" });

stdlib.Regex class

Full-form regex support like /search/replacement/flags. Substitutions $0-$9 in replacement are also supported.

var re = new Regex("/a(.)/$1z/g");
trace(re.replace("3ab4")); // output is: 3bz4
  • Note 1: flag "g" is always exists, so you can omit it.
  • Note 2: you can use nonestandard flag "r" to repeat search&replace while string changed.
  • Note 3: you can specify additional "except" part at the end: /a.c/123/g/a([xy])c - will replace "abc" to "123", but not "axc" or "ayc".
  • Note 4: change characters case is also supported (use $vN and $^N): /(.)b/$^1b/g - will replace "ab" to "Ab".
  • Note 5: you can use other delimiter than "/": new Regex("#abc#def#g").

stdlib.Utf8 class

This class extends standard haxe.Utf8.

Utf8.replace(text, from, to)
Utf8.htmlEscape(s, chars)

var buf = new Utf8();

stdlib.Uuid class

Safe generation of the unique IDs. On sys platforms IP+time+random is used. On the none-sys: counter+time+random.

var s = Uuid.newUuid();

stdlib.Debug class

Debug.assert(condition, message); // throw exception if condition is false

trace(Debug.getDump(obj)); // dump obj

stdlib.Lambda module

Use this module through "using" to get all bonuses: standard Lambda and additional methods:

using stdlib.Lambda;

arr.insertRange(pos, arr2)      // insert many items into specified position
arr.extract(item->Bool)         // remove items from array by predicate and return them

iterable.findIndex(item->Bool)  // find item index by predicate (from start)
iterable.sorted(?cmpFunc)       // return sorted array by the iterable (if `cmpFunc` is not specified then `` will be used)



A macro to support classic abstract classes. Example:

class MyBaseClass implements stdlib.AbstractClass
	function new() {} // private constructor to prevent class instantiating
	public function f() : Void; // no body!

class MyClass extends MyBaseClass
	public function new() super(); // allow class instantiating
	override public function f()
		// method implementataion

stdlib.Http class

This class extends standard haxe.Http.

http.addFile(...) // like fileTransfer(), but can be called many times to add many files

Timer class

This class extends standard haxe.Timer.

Timer.delayAsync(1000).then(function(_) trace("Wake up!"));
3 weeks ago

All libraries are free

Every month, more than thousand developers use haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser!

Join us on Github!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on Github