ts-data-forge
    Preparing search index...
    asInt: <N extends number>(
        x: N,
    ) => number & { Finite: true; Int: true; NaNValue: false } & Readonly<
        {
            "TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3": unknown;
        },
    > & N = castType

    Casts a number to an Int branded type.

    This function validates that the input is an integer and returns it with the Int brand. Throws a TypeError if the value has a fractional component or is not a finite number.

    Type Declaration

      • <N extends number>(
            x: N,
        ): number & { Finite: true; Int: true; NaNValue: false } & Readonly<
            {
                "TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3": unknown;
            },
        > & N
      • Type Parameters

        • N extends number

        Parameters

        Returns number & { Finite: true; Int: true; NaNValue: false } & Readonly<
            {
                "TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3": unknown;
            },
        > & N

        The value as an Int branded type

    const branded = asInt(42);

    assert(branded === 42);
    assert.ok(Int.is(branded));

    If the value is not an integer