0.4.3 • Published 8 months ago

@raccoons-co/ethics v0.4.3

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

npm version Maintainability Rating codecov CircleCI

Clean Code Ethics

Install library

% npm i @raccoons-co/ethics

Strict

Strict.notNull(...)

public static notNull\(reference: T, message?: string): NonNullable\

Ensures that an object reference is not null. Returns the non-null reference that was validated. Throws NullPointerException if reference is null.

Strict.checkArgument(...)

public static checkArgument(expression: boolean, message?: string): void

Ensures the truth of an expression. Throws IllegalArgumentException if expression is false.

Optional

Optional.empty()

public static empty\(): Optional<Exclude<T, undefined>>

Returns an empty optional with no present value to get.

Optional.of(...)

public static of\(value: T): Optional<NonNullable\>

Returns an optional of given non-null value.

Optional.ofNullable(...)

public static ofNullable\(value: T): Optional<NonNullable\>

Returns an optional of given non-null value, otherwise an empty optional.

Optional isEmpty()

public isEmpty(): boolean

Returns status of value absence.

Optional isPresent()

public isPresent(): boolean

Returns status of value presence.

Optional get()

public get(): T

Returns the value if present or empty optional throws NoSuchElementException.

Optional orElseThrow()

public orElseThrow(): T

Returns the value if present or empty optional throws NoSuchElementException.

Optional orElse(...)

public orElse(otherValue: T): T

Returns the value if present or else returns other value.

Optional ifPresent(...)

public ifPresent(performAction: (value: T) => void): void

Performs the given action with the value, otherwise does nothing.

Optional ifPresentOrElse(...)

public ifPresentOrElse(action: (value: T) => void, emptyAction: () => void): void

Performs the given action with the value, otherwise performs the given empty-based action.

Immutable

Class Annotation @Immutable

Encapsulates instance of annotated class into ImmutableObject instance which prevents mutation of the original class instance.

0.4.3

8 months ago

0.4.2

8 months ago

0.4.1

8 months ago

0.4.0

9 months ago

0.3.1

10 months ago

0.3.0

10 months ago

0.2.4

10 months ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.0

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago