Skip to content

Add 'ensureGenerator' method #7

@CodeLenny

Description

@CodeLenny
  /**
   * Ensures that the input(s) are valid JSVerify generators.  Applies `jsc.constant()` to any non-generators given.
   * @param {Any|Any[]} input either a single value to potentially convert, or an array of values to convert.
   * @return {Any|Any[]} the input(s) given, with all non-generators converted via `jsc.constant()`
  */
  static ensureGenerator(input) {
    if(!Array.isArray(input)) {
      return this.isGenerator(input) ? input : jsc.constant(input);
    }
    return input.map(val => this.isGenerator(val) ? val : jsc.constant(val));
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions