@saberhq/option-utils
Advanced tools
Comparing version 1.14.11 to 1.15.0
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
export declare type Maybe<T> = T | null | undefined; | ||
export type Maybe<T> = T | null | undefined; | ||
/** | ||
@@ -11,0 +11,0 @@ * Applies a function to a list of null/undefined values, unwrapping the null/undefined value or passing it through. |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
export declare type Maybe<T> = T | null | undefined; | ||
export type Maybe<T> = T | null | undefined; | ||
/** | ||
@@ -11,0 +11,0 @@ * Applies a function to a list of null/undefined values, unwrapping the null/undefined value or passing it through. |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
/** | ||
@@ -5,6 +6,8 @@ * [[include:option-utils/README.md]] | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.exists = exports.isNotUndefined = exports.isNotNull = exports.mapSome = exports.mapN = void 0; | ||
/** | ||
* Applies a function to a list of null/undefined values, unwrapping the null/undefined value or passing it through. | ||
*/ | ||
export const mapN = (fn, ...args) => { | ||
const mapN = (fn, ...args) => { | ||
if (!args.every((arg) => arg !== undefined)) { | ||
@@ -18,2 +21,3 @@ return undefined; | ||
}; | ||
exports.mapN = mapN; | ||
/** | ||
@@ -30,3 +34,4 @@ * Applies a function to a null/undefined inner value if it is null or undefined, | ||
*/ | ||
export const mapSome = (obj, fn) => (exists(obj) ? fn(obj) : obj); | ||
const mapSome = (obj, fn) => ((0, exports.exists)(obj) ? fn(obj) : obj); | ||
exports.mapSome = mapSome; | ||
/** | ||
@@ -40,5 +45,6 @@ * Checks to see if the provided value is not null. | ||
*/ | ||
export const isNotNull = (value) => { | ||
const isNotNull = (value) => { | ||
return value !== null; | ||
}; | ||
exports.isNotNull = isNotNull; | ||
/** | ||
@@ -50,5 +56,6 @@ * Checks to see if the provided value is not undefined. | ||
*/ | ||
export const isNotUndefined = (value) => { | ||
const isNotUndefined = (value) => { | ||
return value !== undefined; | ||
}; | ||
exports.isNotUndefined = isNotUndefined; | ||
/** | ||
@@ -60,5 +67,6 @@ * Checks to see if the provided value is not null or undefined. | ||
*/ | ||
export const exists = (value) => { | ||
const exists = (value) => { | ||
return value !== null && value !== undefined; | ||
}; | ||
exports.exists = exists; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@saberhq/option-utils", | ||
"version": "1.14.11", | ||
"version": "1.15.0", | ||
"description": "Utilities for handling optional values in TypeScript.", | ||
@@ -36,8 +36,8 @@ "homepage": "https://github.com/saber-hq/saber-common/tree/master/packages/option-utils#readme", | ||
"dependencies": { | ||
"tslib": "^2.4.0" | ||
"tslib": "^2.6.2" | ||
}, | ||
"devDependencies": { | ||
"@saberhq/tsconfig": "^2.1.0", | ||
"typescript": "^4.8.4" | ||
"@saberhq/tsconfig": "^3.1.1", | ||
"typescript": "^5.3.2" | ||
} | ||
} |
@@ -31,3 +31,3 @@ /** | ||
[K in keyof T]: NonNullable<T[K]>; | ||
}) | ||
}), | ||
); | ||
@@ -49,3 +49,3 @@ }; | ||
obj: NonNullable<T> | null | undefined, | ||
fn: (obj: NonNullable<T>) => U | ||
fn: (obj: NonNullable<T>) => U, | ||
): U | null | undefined => (exists(obj) ? fn(obj) : obj); | ||
@@ -72,3 +72,3 @@ | ||
export const isNotUndefined = <TValue>( | ||
value: TValue | undefined | ||
value: TValue | undefined, | ||
): value is TValue => { | ||
@@ -85,5 +85,5 @@ return value !== undefined; | ||
export const exists = <TValue>( | ||
value: TValue | null | undefined | ||
value: TValue | null | undefined, | ||
): value is TValue => { | ||
return value !== null && value !== undefined; | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
36593
303
Updatedtslib@^2.6.2