typescript-optional
Advanced tools
Comparing version 1.6.1 to 1.7.0
@@ -12,8 +12,8 @@ export default abstract class Optional<T> { | ||
abstract orElse(another: T): T; | ||
abstract orElseGet(another: () => T): T; | ||
abstract orElseThrow<U>(exception: () => U): T; | ||
abstract orElseGet(supplier: () => T): T; | ||
abstract orElseThrow<U>(errorSupplier: () => U): T; | ||
static of<T>(value: T): Optional<T>; | ||
static ofNonNull<T>(value: T): Optional<T>; | ||
static ofNullable<T>(nullable: T | null | undefined): Optional<T>; | ||
static ofNonNull<T>(payload: T): Optional<T>; | ||
static of<T>(payload: T): Optional<T>; | ||
static empty<T>(): Optional<T>; | ||
} |
@@ -23,2 +23,11 @@ "use strict"; | ||
}); | ||
Optional.of = function (value) { | ||
if (value !== null && value !== undefined) | ||
return new PresentOptional(value); | ||
else | ||
throw new TypeError("The passed value was null or undefined."); | ||
}; | ||
Optional.ofNonNull = function (value) { | ||
return Optional.of(value); | ||
}; | ||
Optional.ofNullable = function (nullable) { | ||
@@ -30,11 +39,2 @@ if (nullable !== null && nullable !== undefined) | ||
}; | ||
Optional.ofNonNull = function (payload) { | ||
return Optional.of(payload); | ||
}; | ||
Optional.of = function (payload) { | ||
if (payload !== null && payload !== undefined) | ||
return new PresentOptional(payload); | ||
else | ||
throw new TypeError("The passed value was null or undefined."); | ||
}; | ||
Optional.empty = function () { | ||
@@ -41,0 +41,0 @@ return new EmptyOptional(); |
{ | ||
"name": "typescript-optional", | ||
"version": "1.6.1", | ||
"version": "1.7.0", | ||
"description": "Optional (like Java) implementation in TypeScript", | ||
@@ -5,0 +5,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15203