From be58ed1c05338d2a16eb697dcec1826738ae8293 Mon Sep 17 00:00:00 2001 From: Niklas Kapelle Date: Tue, 13 Aug 2024 00:10:47 +0200 Subject: [PATCH] removed unused files --- src/lib/Extender.hx | 69 --------------------------- src/lib/ObjMerge.hx | 24 ---------- src/lib/observable/DummyObservable.hx | 27 ----------- src/lib/observable/IObservable.hx | 9 ---- src/lib/observable/ObservableArray.hx | 56 ---------------------- src/lib/observable/ObservableValue.hx | 28 ----------- 6 files changed, 213 deletions(-) delete mode 100644 src/lib/Extender.hx delete mode 100644 src/lib/ObjMerge.hx delete mode 100644 src/lib/observable/DummyObservable.hx delete mode 100644 src/lib/observable/IObservable.hx delete mode 100644 src/lib/observable/ObservableArray.hx delete mode 100644 src/lib/observable/ObservableValue.hx diff --git a/src/lib/Extender.hx b/src/lib/Extender.hx deleted file mode 100644 index e613c7d..0000000 --- a/src/lib/Extender.hx +++ /dev/null @@ -1,69 +0,0 @@ -package lib; - -import haxe.Exception; - -class LambdaExtender { - /** - Returns the first element if there are exectly one element present. - Throws exception if not. - **/ - static public function single(it:Iterable):T { - var elem:T = null; - for (t in it) { - if (elem != null) { - throw new Exception("Multiple elements found"); - } - elem = t; - } - - if (elem == null) { - throw new Exception("No element found"); - } - - return elem; - } - - /** - Like `single` but when no element was found return the default value. - **/ - static public function singleOrDefault(it:Iterable, defaultValue:T):T { - var elem:T = null; - for (t in it) { - if (elem != null) { - throw new Exception("Multiple elements found"); - } - elem = t; - } - - if (elem == null) { - return defaultValue; - } - - return elem; - } - - /** - Returns the first element. - Throws execption if no first element found. - **/ - static public function first(it:Iterable):T { - for (t in it) { - return t; - } - - throw new Exception("No element found"); - } - - /** - Like `first` only if no first element was found it returns the defalt value. - **/ - static public function firstOrDefault(it:Iterable, defaultValue:T):T { - var iter = it.iterator(); - - if (iter.hasNext()) { - return iter.next(); - } - - return defaultValue; - } -} diff --git a/src/lib/ObjMerge.hx b/src/lib/ObjMerge.hx deleted file mode 100644 index d5695c9..0000000 --- a/src/lib/ObjMerge.hx +++ /dev/null @@ -1,24 +0,0 @@ -package lib; - -class ObjMerge { - public static function merge(obj1:T, obj2:T):T { - if (obj1 == null) { - return obj2; - } - - if (obj2 == null) { - return obj1; - } - - var rtn:T = Reflect.copy(obj1); - var fields = Reflect.fields(obj2); - - for (field in fields) { - if (Reflect.getProperty(obj1, field) == null) { - Reflect.setProperty(rtn, field, Reflect.getProperty(obj2, field)); - } - } - - return (rtn : T); - } -} diff --git a/src/lib/observable/DummyObservable.hx b/src/lib/observable/DummyObservable.hx deleted file mode 100644 index f2d4edc..0000000 --- a/src/lib/observable/DummyObservable.hx +++ /dev/null @@ -1,27 +0,0 @@ -package lib.observable; - -using tink.CoreApi; - -class DummyObservable implements IObservable { - private var value:T; - - private function new(value:T) { - this.value = value; - } - - public function set(value:T) { - throw new haxe.exceptions.NotImplementedException(); - } - - public function get():T { - return this.value; - } - - public function subscribe(callback:Callback):CallbackLink { - return null; - } - - public static function dummy(value:T):IObservable { - return new DummyObservable(value); - } -} diff --git a/src/lib/observable/IObservable.hx b/src/lib/observable/IObservable.hx deleted file mode 100644 index 475cc15..0000000 --- a/src/lib/observable/IObservable.hx +++ /dev/null @@ -1,9 +0,0 @@ -package lib.observable; - -using tink.CoreApi; - -interface IObservable { - public function set(value:T):Void; - public function get():T; - public function subscribe(callback:Callback):CallbackLink; -} diff --git a/src/lib/observable/ObservableArray.hx b/src/lib/observable/ObservableArray.hx deleted file mode 100644 index b01a279..0000000 --- a/src/lib/observable/ObservableArray.hx +++ /dev/null @@ -1,56 +0,0 @@ -package lib.observable; - -class ObservableArray extends ObservableValue> { - public function new(value:Array) { - super(value); - } - - public function insert(pos:Int, x:T):Void { - this.value.insert(pos, x); - this.callbacks.invoke(this.value); - } - - public function pop():Null { - var poped = this.pop(); - this.callbacks.invoke(this.value); - return poped; - } - - public function push(x:T):Int { - var i = this.value.push(x); - this.callbacks.invoke(this.value); - return i; - } - - public function remove(x:T):Bool { - var b = this.value.remove(x); - this.callbacks.invoke(this.value); - return b; - } - - public function resize(len:Int) { - this.value.resize(len); - this.callbacks.invoke(this.value); - } - - public function reverse() { - this.value.reverse(); - this.callbacks.invoke(this.value); - } - - public function shift():Null { - var e = this.value.shift(); - this.callbacks.invoke(this.value); - return e; - } - - public function sort(f:(T, T) -> Int):Void { - this.value.sort(f); - this.callbacks.invoke(this.value); - } - - public function unshift(x:T):Void { - this.value.unshift(x); - this.callbacks.invoke(this.value); - } -} diff --git a/src/lib/observable/ObservableValue.hx b/src/lib/observable/ObservableValue.hx deleted file mode 100644 index 2932a39..0000000 --- a/src/lib/observable/ObservableValue.hx +++ /dev/null @@ -1,28 +0,0 @@ -package lib.observable; - -using tink.CoreApi; - -class ObservableValue implements IObservable { - private var value:T; - private var callbacks:CallbackList = new CallbackList(); - - public function new(value:T) { - this.value = value; - } - - public function set(value:T) { - if (value != this.value) { - this.value = value; - callbacks.invoke(value); - } - } - - public function get():T { - return value; - } - - public function subscribe(callback:Callback):CallbackLink { - callback.invoke(value); - return callbacks.add(callback); - } -}