Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ArrayConverter

Converts arbitrary values into array objects.

Example

let value1 = ArrayConverter.toArray([1, 2]);         // Result: [1, 2]
let value2 = ArrayConverter.toArray(1);              // Result: [1]
let value2 = ArrayConverter.listToArray("1,2,3");    // Result: ["1", "2", "3"]

Hierarchy

  • ArrayConverter

Index

Methods

Static listToArray

  • listToArray(value: any): any[]
  • Converts value into array object with empty array as default. Strings with comma-delimited values are split into array of strings.

    see

    toArray

    Parameters

    • value: any

      the list to convert.

    Returns any[]

    array object or empty array when value is null

Static toArray

  • toArray(value: any): any[]
  • Converts value into array object with empty array as default. Single values are converted into arrays with single element.

    see

    toNullableArray

    Parameters

    • value: any

      the value to convert.

    Returns any[]

    array object or empty array when value is null.

Static toArrayWithDefault

  • toArrayWithDefault(value: any, defaultValue: any[]): any[]
  • Converts value into array object with specified default. Single values are converted into arrays with single element.

    see

    toNullableArray

    Parameters

    • value: any

      the value to convert.

    • defaultValue: any[]

      default array object.

    Returns any[]

    array object or default array when value is null.

Static toNullableArray

  • toNullableArray(value: any): any[]
  • Converts value into array object. Single values are converted into arrays with a single element.

    Parameters

    • value: any

      the value to convert.

    Returns any[]

    array object or null when value is null.

Generated using TypeDoc