Flags.set()

Syntax

function set(flags: number, ...flagsToSet: number[]): number

Returns a new number with the given flags set on the number.

Parameters
flags

The flags number which to augment with the other flags. This parameter only exists on the static method.

flagsToSet Rest

The flags to set on the number.

Example

import { Flags } from 'potence';

enum Options {
    None = 0,
    IncludeHotDogs = 1,
    CleanUpAfter = 2,
    PreventGlobalDisaster = 4,
    BlowUpTheWorld = 8
}

const flags = Options.IncludeHotDogs | Options.CleanUpAfter;  // -> 3
Flags.set(flags, Options.BlowUpTheWorld);                     // -> 11
new Flags(flags).set(Options.BlowUpTheWorld);                 // -> 11

Remarks

This function throws if any of the flagsToSet arguments are not valid flags. All flags must be non-zero finite positive integers.

If a flag is already set, this function does not change the number.