@aurelia/metadata
Advanced tools
Comparing version 2.0.0-beta.21 to 2.0.0-beta.22
@@ -6,2 +6,7 @@ # Change Log | ||
<a name="2.0.0-beta.22"></a> | ||
# 2.0.0-beta.22 (2024-09-30) | ||
**Note:** Version bump only for package @aurelia/metadata | ||
<a name="2.0.0-beta.21"></a> | ||
@@ -8,0 +13,0 @@ # 2.0.0-beta.21 (2024-08-08) |
@@ -8,61 +8,2 @@ /** | ||
export declare function initializeTC39Metadata(): void; | ||
/** | ||
* Determine whether a value is an object. | ||
* | ||
* Uses `typeof` to guarantee this works cross-realm, which is where `instanceof Object` might fail. | ||
* | ||
* Some environments where these issues are known to arise: | ||
* - same-origin iframes (accessing the other realm via `window.top`) | ||
* - `jest`. | ||
* | ||
* The exact test is: | ||
* ```ts | ||
* typeof value === 'object' && value !== null || typeof value === 'function' | ||
* ``` | ||
* | ||
* @param value - The value to test. | ||
* @returns `true` if the value is an object, otherwise `false`. | ||
* Also performs a type assertion that defaults to `value is Object | Function` which, if the input type is a union with an object type, will infer the correct type. | ||
* This can be overridden with the generic type argument. | ||
* | ||
* @example | ||
* | ||
* ```ts | ||
* class Foo { | ||
* bar = 42; | ||
* } | ||
* | ||
* function doStuff(input?: Foo | null) { | ||
* input.bar; // Object is possibly 'null' or 'undefined' | ||
* | ||
* // input has an object type in its union (Foo) so that type will be extracted for the 'true' condition | ||
* if (isObject(input)) { | ||
* input.bar; // OK (input is now typed as Foo) | ||
* } | ||
* } | ||
* | ||
* function doOtherStuff(input: unknown) { | ||
* input.bar; // Object is of type 'unknown' | ||
* | ||
* // input is 'unknown' so there is no union type to match and it will default to 'Object | Function' | ||
* if (isObject(input)) { | ||
* input.bar; // Property 'bar' does not exist on type 'Object | Function' | ||
* } | ||
* | ||
* // if we know for sure that, if input is an object, it must be a specific type, we can explicitly tell the function to assert that for us | ||
* if (isObject<Foo>(input)) { | ||
* input.bar; // OK (input is now typed as Foo) | ||
* } | ||
* } | ||
* ``` | ||
*/ | ||
export declare function isObject<T extends object = Object | Function>(value: unknown): value is T; | ||
/** | ||
* Determine whether a value is `null` or `undefined`. | ||
* | ||
* @param value - The value to test. | ||
* @returns `true` if the value is `null` or `undefined`, otherwise `false`. | ||
* Also performs a type assertion that ensures TypeScript treats the value appropriately in the `if` and `else` branches after this check. | ||
*/ | ||
export declare function isNullOrUndefined(value: unknown): value is null | undefined; | ||
export declare const Metadata: { | ||
@@ -69,0 +10,0 @@ get<T>(key: string, type: any): T | undefined; |
{ | ||
"name": "@aurelia/metadata", | ||
"version": "2.0.0-beta.21", | ||
"version": "2.0.0-beta.22", | ||
"main": "dist/cjs/index.cjs", | ||
@@ -5,0 +5,0 @@ "module": "dist/esm/index.mjs", |
@@ -0,1 +1,3 @@ | ||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/** | ||
@@ -13,68 +15,3 @@ * TODO: add description. | ||
} | ||
/** | ||
* Determine whether a value is an object. | ||
* | ||
* Uses `typeof` to guarantee this works cross-realm, which is where `instanceof Object` might fail. | ||
* | ||
* Some environments where these issues are known to arise: | ||
* - same-origin iframes (accessing the other realm via `window.top`) | ||
* - `jest`. | ||
* | ||
* The exact test is: | ||
* ```ts | ||
* typeof value === 'object' && value !== null || typeof value === 'function' | ||
* ``` | ||
* | ||
* @param value - The value to test. | ||
* @returns `true` if the value is an object, otherwise `false`. | ||
* Also performs a type assertion that defaults to `value is Object | Function` which, if the input type is a union with an object type, will infer the correct type. | ||
* This can be overridden with the generic type argument. | ||
* | ||
* @example | ||
* | ||
* ```ts | ||
* class Foo { | ||
* bar = 42; | ||
* } | ||
* | ||
* function doStuff(input?: Foo | null) { | ||
* input.bar; // Object is possibly 'null' or 'undefined' | ||
* | ||
* // input has an object type in its union (Foo) so that type will be extracted for the 'true' condition | ||
* if (isObject(input)) { | ||
* input.bar; // OK (input is now typed as Foo) | ||
* } | ||
* } | ||
* | ||
* function doOtherStuff(input: unknown) { | ||
* input.bar; // Object is of type 'unknown' | ||
* | ||
* // input is 'unknown' so there is no union type to match and it will default to 'Object | Function' | ||
* if (isObject(input)) { | ||
* input.bar; // Property 'bar' does not exist on type 'Object | Function' | ||
* } | ||
* | ||
* // if we know for sure that, if input is an object, it must be a specific type, we can explicitly tell the function to assert that for us | ||
* if (isObject<Foo>(input)) { | ||
* input.bar; // OK (input is now typed as Foo) | ||
* } | ||
* } | ||
* ``` | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
export function isObject<T extends object = Object | Function>(value: unknown): value is T { | ||
return typeof value === 'object' && value !== null || typeof value === 'function'; | ||
} | ||
/** | ||
* Determine whether a value is `null` or `undefined`. | ||
* | ||
* @param value - The value to test. | ||
* @returns `true` if the value is `null` or `undefined`, otherwise `false`. | ||
* Also performs a type assertion that ensures TypeScript treats the value appropriately in the `if` and `else` branches after this check. | ||
*/ | ||
export function isNullOrUndefined(value: unknown): value is null | undefined { | ||
return value === null || value === void 0; | ||
} | ||
export const Metadata = { | ||
@@ -81,0 +18,0 @@ get<T>(key: string, type: any): T | 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
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
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
34980
393