Coder Social home page Coder Social logo

zame-haxe-miscutils's Introduction

Misc utils for Haxe

  • DynamicExt - pure haxe
  • DynamicTools - pure haxe
  • LambdaExt - pure haxe
  • XmlExt - pure haxe
  • UrlLoaderExt - for openfl

About

Installation

haxelib git zame-miscutils https://github.com/restorer/zame-haxe-miscutils.git

DynamicExt

Allow use Dynamic values like Map.

var node = new DynamicExt();

node["foo"] = "bar";
trace(node["foo"]);

trace(node.exists("foo"));
trace(node.exists("bar"));

node["bar"] = "baz";
trace(node.keys());

node.remove("foo");
trace(node.keys());

DynamicTools

Along with DynamicExt allows to parse json in a safe manner.

import org.zamedev.lib.DynamicExt;
using org.zamedev.lib.DynamicTools;

var node:DynamicExt = haxe.Json.parse('{"stringval":"haxe","arrayval":["haxe","cool"],"intval":42,"floatval":24.42,"boolval":true}');
trace(node["stringval"].asString());
trace(node["arrayval"].asArray());
trace(node["intval"].asInt());
trace(node["floatval"].asFloat());
trace(node["boolval"].asBool());
trace(node["nonexisting"].asString("defaultvalue"));
trace(node["nonexisting"].asNullInt());
trace(node["nonexisting"].asNullFloat());
trace(node["nonexisting"].asDynamic());

LambdaExt

Can be used as drop-in replacement of Lambda when you need to work with an Iterator (you should still use original Lambda for an Iterable).

var map = new Map<String, String>();
map["foo"] = "bar";
map["bar"] = "baz";

var arrayval:Array<String> = map.keys().array();
trace(arrayval);

var listval:List<String> = map.keys().map(function(v) { return v.toUpperCase(); });
trace(listval);

XmlExt

Allows to get inner text from xml node in an easy way.

var root = Xml.parse("<root><node>inner value</node><node /></root>");

for (node in root.firstElement().elements()) {
    trace(node.innerText("defaultvalue"));
}

UrlLoaderExt (for openfl)

Simplify work with json-based server API.

var loader = new UrlLoaderExt(function(loader:UrlLoaderExt) {
    trace("success");
    trace(loader.data);
}, function(_) {
    trace("error happened");
});

loader.load(UrlLoaderExt.createJsonRequest("http://domain.tld", { foo:"bar" }));

zame-haxe-miscutils's People

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.