Home Core Concepts Contributing Fluent API(FluentMap)(FluentSet)Babel ESLint Jest Mdx Prettier TSLint Webpack Presets Runners (core)Runners (other)Starter Kits

# FluentSet API

Another of the core API interfaces in BeRun is a `FluentSet`. A `FluentSet` operates similar to a JavaScript Set, with some conveniences for chaining and generating configuration. If a property is marked as being a `FluentSet`, it will have an API and methods as described below:

Unless stated otherwise, these methods will return the `FluentSet`, allowing you to chain these methods.

    // Add/append a value to the end of a Set.
    // value: *
    add(value)

    // Add a value to the beginning of a Set.
    // value: *
    prepend(value)

    // Remove all values from a Set.
    clear()

    // Remove a specific value from a Set.
    // value: *
    delete(value)

    // Returns `true` or `false` based on whether or not the
    // backing Set contains the specified value.
    // value: *
    // returns: Boolean
    has(value)

    // Returns an array of values contained in the backing Set.
    // returns: Array
    values()

    // Concatenates the given array to the end of the backing Set.
    // arr: Array
    merge(arr)

    // Execute a function against the current configuration context
    // handler: Function -> FluentSet
      // A function which is given a single argument of the FluentSet instance
    batch(handler)

    // Conditionally execute a function to continue configuration
    // condition: Boolean
    // whenTruthy: Function -> FluentSet
      // invoked when condition is truthy, given a single argument of the FluentSet instance
    // whenFalsy: Optional Function -> FluentSet
      // invoked when condition is falsy, given a single argument of the FluentSet instance
    when(condition, whenTruthy, whenFalsy)

‹ previous
next ›