Home

Awesome

janicek-core-haxe

My personal collection of Haxe core libraries.

Functional style preferred:

Tested with Haxe 3.0, JavaScript, and Node.js.

See spec classes for examples of how to use the libraries.

API docs -> http://rjanicek.github.com/janicek-core-haxe/api

browser tests -> http://rjanicek.github.com/janicek-core-haxe

GitHub -> https://github.com/rjanicek/janicek-core-haxe

###Examples

using co.janicek.core.FamilyCore;
using co.janicek.core.LambdaCore;
using co.janicek.core.NullCore;
using co.janicek.core.StringCore;
using Lambda;

class MainDemo{
	public static function main() {
		
		trace("NullCore".isNull());							// false
		trace("NullCore".isNotNull());						// true
		trace(NullCore.coalesce(null, "Hobbit"));			// Hobbit
		trace([null, "Bilbo", "Hobbit"].coalesceIter());	// Bilbo
		
		var hobbit : {name : String, parent : Dynamic, children : Array<Dynamic>} = null;
		
		if (hobbit.isNull()) {
			hobbit = {
				name : "Drogo",
				parent : null,
				children: []
			};
		}
		
		var frodo = {
			name : "Frodo",
			parent : hobbit
		}
		
		hobbit.children.push(frodo);
		
		trace(hobbit.family().count());			// 2
		trace(hobbit.descendants().count());	// 1
		trace(frodo.lineage().count());			// 2
		trace(frodo.lineage().map(function(h) { return h.name; } ).array());				// [ 'Frodo', 'Drogo' ]
		trace(hobbit.family().first(function(h) { return h.name.contains("odo"); }).name);	// Frodo
		
	}
}