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

    Casts a number to a NonPositiveInt branded type.

    This function validates that the input is a non-positive integer (<= 0) and returns it with the NonPositiveInt brand. This ensures type safety for operations that require non-positive integer values.

    Type Declaration

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

        • N extends number

        Parameters

        Returns number & {
            "< 2^15": true;
            "< 2^16": true;
            "< 2^31": true;
            "< 2^32": true;
            "<=0": true;
            Finite: true;
            Int: true;
            NaNValue: false;
        } & Readonly<
            {
                "TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3": unknown;
            },
        > & N

        The value as a NonPositiveInt branded type

    const branded = asNonPositiveInt(-7);

    assert.isTrue(branded === -7);

    assert.isTrue(NonPositiveInt.is(branded));

    If the value is not a non-positive integer