import { as } from "https://deno.land/x/ayonli_jsext@v0.9.72/object/index.ts";
Checks if the value is an instance of the given type, returns the value itself if passed,
otherwise returns null
. This function is mainly used for the optional chaining syntax.
Examples
Example 1
Example 1
import { as } from "@ayonli/jsext/object";
try {
// ... do something
} catch (err) {
console.error(as(err, Error)?.message ?? String(err));
}