# All files / list actions.js

77.78% Statements 7/9
100% Branches 1/1
87.5% Functions 7/8
77.78% Lines 7/9

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88

    1x

    1x

    1x

    1x

    1x

    1x

    2x

     import invariant from 'invariant'
    import * as ActionTypes from './actionTypes'

    export function lpush(target, value) {
      return {
        type: ActionTypes.LPUSH,
        payload: {
          target,
          value
        }
      }
    }

    export function rpush(target, value) {
      return {
        type: ActionTypes.RPUSH,
        payload: {
          target,
          value
        }
      }
    }

    export function lpop(target) {
      return {
        type: ActionTypes.LPOP,
        payload: {
          target
        }
      }
    }

    export function rpop(target) {
      return {
        type: ActionTypes.RPOP,
        payload: {
          target
        }
      }
    }

    export function lset(target, index, value) {
      return {
        type: ActionTypes.LSET,
        payload: {
          target,
          index,
          value
        }
      }
    }

    export function lreplace(target, elements) {
      invariant(
        Array.isArray(elements),
        'List.lreplace(target, elements) expects an Array of elements to replace the list with'
      )
      return {
        type: ActionTypes.LREPLACE,
        payload: {
          target,
          elements
        }
      }
    }

    export function lrem(target, count, value) {
      return {
        type: ActionTypes.LREM,
        payload: {
          target,
          count,
          value
        }
      }
    }

    export function ltrim(target, start, stop = -1) {
      return {
        type: ActionTypes.LTRIM,
        payload: {
          target,
          start,
          stop
        }
      }
    }