@xylabs/exists
Advanced tools
Comparing version 2.7.6 to 2.8.0
@@ -5,13 +5,13 @@ "use strict"; | ||
/** | ||
* Used to type narrow an object which is possibly undefined. Works well | ||
* Used to type narrow an object which is possibly null or undefined. Works well | ||
* with functional Array methods. For example: | ||
* @example | ||
* const payloads: XyoPayload[] = boundWitness._payloads?.filter(exists) || [] | ||
* @param x The object which is potentially undefined | ||
* @returns True if the object is defined, false otherwise | ||
* @param x The object which is potentially undefined or null | ||
* @returns False if the object is null/undefined, true otherwise | ||
*/ | ||
const exists = (x) => { | ||
return !!x; | ||
return x === undefined || x === null ? false : true; | ||
}; | ||
exports.exists = exists; | ||
//# sourceMappingURL=index.js.map |
@@ -20,3 +20,3 @@ { | ||
"character": 13, | ||
"url": "https://github.com/xylabs/sdk-js/blob/8d1441a/packages/exists/src/index.ts#L9" | ||
"url": "https://github.com/xylabs/sdk-js/blob/9ad4029/packages/exists/src/index.ts#L9" | ||
} | ||
@@ -35,3 +35,3 @@ ], | ||
"kind": "text", | ||
"text": "Used to type narrow an object which is possibly undefined. Works well\nwith functional Array methods. For example:" | ||
"text": "Used to type narrow an object which is possibly null or undefined. Works well\nwith functional Array methods. For example:" | ||
} | ||
@@ -54,3 +54,3 @@ ], | ||
"kind": "text", | ||
"text": "True if the object is defined, false otherwise" | ||
"text": "False if the object is null/undefined, true otherwise" | ||
} | ||
@@ -83,3 +83,3 @@ ] | ||
"kind": "text", | ||
"text": "The object which is potentially undefined" | ||
"text": "The object which is potentially undefined or null" | ||
} | ||
@@ -131,5 +131,5 @@ ] | ||
"character": 0, | ||
"url": "https://github.com/xylabs/sdk-js/blob/8d1441a/packages/exists/src/index.ts#L9" | ||
"url": "https://github.com/xylabs/sdk-js/blob/9ad4029/packages/exists/src/index.ts#L9" | ||
} | ||
] | ||
} |
/** | ||
* Used to type narrow an object which is possibly undefined. Works well | ||
* Used to type narrow an object which is possibly null or undefined. Works well | ||
* with functional Array methods. For example: | ||
* @example | ||
* const payloads: XyoPayload[] = boundWitness._payloads?.filter(exists) || [] | ||
* @param x The object which is potentially undefined | ||
* @returns True if the object is defined, false otherwise | ||
* @param x The object which is potentially undefined or null | ||
* @returns False if the object is null/undefined, true otherwise | ||
*/ | ||
export const exists = (x) => { | ||
return !!x; | ||
return x === undefined || x === null ? false : true; | ||
}; | ||
//# sourceMappingURL=index.js.map |
/** | ||
* Used to type narrow an object which is possibly undefined. Works well | ||
* Used to type narrow an object which is possibly null or undefined. Works well | ||
* with functional Array methods. For example: | ||
* @example | ||
* const payloads: XyoPayload[] = boundWitness._payloads?.filter(exists) || [] | ||
* @param x The object which is potentially undefined | ||
* @returns True if the object is defined, false otherwise | ||
* @param x The object which is potentially undefined or null | ||
* @returns False if the object is null/undefined, true otherwise | ||
*/ | ||
export declare const exists: <T>(x?: T | null | undefined) => x is T; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -44,3 +44,3 @@ { | ||
"devDependencies": { | ||
"@xylabs/ts-scripts-yarn3": "^2.16.1" | ||
"@xylabs/ts-scripts-yarn3": "^2.17.13" | ||
}, | ||
@@ -55,3 +55,3 @@ "publishConfig": { | ||
"sideEffects": false, | ||
"version": "2.7.6" | ||
"version": "2.8.0" | ||
} |
/** | ||
* Used to type narrow an object which is possibly undefined. Works well | ||
* Used to type narrow an object which is possibly null or undefined. Works well | ||
* with functional Array methods. For example: | ||
* @example | ||
* const payloads: XyoPayload[] = boundWitness._payloads?.filter(exists) || [] | ||
* @param x The object which is potentially undefined | ||
* @returns True if the object is defined, false otherwise | ||
* @param x The object which is potentially undefined or null | ||
* @returns False if the object is null/undefined, true otherwise | ||
*/ | ||
export const exists = <T>(x?: T | null): x is T => { | ||
return !!x | ||
return x === undefined || x === null ? false : true | ||
} |
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
16464