import { def } from "https://deno.land/x/ahh@v0.14.0/src/default.ts";
Returns the default value for a Default
object.
Examples
Example 1
Example 1
import { assertEquals } from "../test_deps.ts";
import { def } from "./default.ts";
class Vec2 {
x: number;
y: number;
constructor();
constructor(v: number);
constructor(x?: number, y?: number) {
this.x = x ?? 0;
this.y = y ?? x ?? 0;
}
}
assertEquals(def(Vec2), new Vec2());
Returns the default value for the undefined
primitive.
Examples
Example 1
Example 1
import { assert } from "../test_deps.ts";
import { def } from "./default.ts";
assert(def("undefined") === undefined);
Returns the default value for the null
object.
Examples
Example 1
Example 1
import { assertEquals } from "../test_deps.ts";
import { def } from "./default.ts";
assertEquals(def("null"), null);
Returns the default value for the boolean
primitive.
Examples
Example 1
Example 1
import { assert } from "../test_deps.ts";
import { def } from "./default.ts";
assert(def("boolean") === false);
Returns the default value for the number
primitive.
Examples
Example 1
Example 1
import { assert } from "../test_deps.ts";
import { def } from "./default.ts";
assert(def("number") === 0);
Returns the default value for the bigint
primitive.
Examples
Example 1
Example 1
import { assert } from "../test_deps.ts";
import { def } from "./default.ts";
assert(def("bigint") === 0n);
Returns the default value for the string
primitive.
Examples
Example 1
Example 1
import { assert } from "../test_deps.ts";
import { def } from "./default.ts";
assert(def("string") === "");