easy-primitives.js
Library which helps manages primitives in easy way!
Get rid of primitives boilerplate code.
Boolean
Change this:
const val: boolean = this.boolFun();
if (val === true) {
...
}
Into:
const val: EasyBoolean = EasyBoolean.of(this.boolFun());
val.ifTrue(() -> ... )
Or even
EasyBoolean.of(this.boolFun()).ifTrue(() -> ... )
Number
Change:
const val: number = ...
if (val > 0) {
this.selected = val;
}
Into:
const val: EasyNumber = ...
val.ifPositive(it => this.selected = it);
String
Change:
const text: string = ...
if (text !== undefined && text !== null && text.length > 1) {
this.selected = text;
}
Into:
const text: EasyString = ...
text.ifNotEmpty(it = > this.selected = it);
Arrays
Change:
const array: string[] = ...
if (array !== undefined && array !== null && array.length === 1) {
this.selected = array[0];
}
if (array !== undefined && array !== null && array.length > 0) {
this.selected = array;
}
Into:
const array: EasyArray<string> = ...
array.ifHasOneElement((elem) => this.selected = elem);
array.ifNotEmpty((arr) => this.selected = arr);