Variadic joinPath. Close #20

This commit is contained in:
2021-07-23 14:58:36 -06:00
parent d073f819fa
commit a18a4d8150
6 changed files with 30 additions and 22 deletions

View File

@@ -60,6 +60,7 @@ class Kiss {
"pairs" => Symbol("Prelude.pairs"), // TODO test pairs
"reversed" => Symbol("Prelude.reversed"), // TODO test reversed
"memoize" => Symbol("Prelude.memoize"), // TODO test memoize
"joinPath" => Symbol("Prelude.joinPath"),
"symbolName" => Symbol("Prelude.symbolName"),
"symbolNameValue" => Symbol("Prelude.symbolNameValue"),
"symbol" => Symbol("Prelude.symbol"),

View File

@@ -12,6 +12,7 @@ import js.node.Buffer;
import sys.io.Process;
#end
import uuid.Uuid;
import haxe.io.Path;
using StringTools;
using uuid.Uuid;
@@ -239,7 +240,7 @@ class Prelude {
// Ranges with a min, exclusive max, and step size, just like Python.
public static function range(min, max, step):Iterator<Int> {
if (step <= 0)
if (step <= 0 || max < min)
throw "(range...) can only count up";
var count = min;
return {
@@ -254,6 +255,12 @@ class Prelude {
};
}
static function _joinPath(parts:Array<Dynamic>) {
return Path.join([for (part in parts) cast(part, String)]);
}
public static var joinPath:Function = Reflect.makeVarArgs(_joinPath);
public static dynamic function truthy<T>(v:T) {
return switch (Type.typeof(v)) {
case TNull: false;