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

    Casts a number to a SafeInt branded type.

    This function validates that the input is a safe integer (within ±(2^53 - 1)) and returns it with the SafeInt brand. This ensures type safety for operations that require precise integer arithmetic.

    Type Declaration

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

        • N extends number

        Parameters

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

        The value as a SafeInt branded type

    const branded = asSafeInt(123);

    assert(branded === 123);
    assert.ok(SafeInt.is(branded));

    If the value is not a safe integer