@amidevtech/easy-primitives.js
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

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);

Check out much more handy functions.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.2
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.2
    1
  • 0.0.1
    0

Package Sidebar

Install

npm i @amidevtech/easy-primitives.js

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

17.8 kB

Total Files

21

Last publish

Collaborators

  • amidevtech