# All files / hash actions.js

100% Statements 5/5
100% Branches 0/0
100% Functions 5/5
100% Lines 5/5

    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

    1x

    1x

    1x

    1x

    1x

     import { HSET, HDEL, HMSET, HINCRBY, HTOGGLE } from './actionTypes'

    /**
     * Sets a single value in a hash, specified by
     * domain and key
     * @param {String} domain
     * @param {String} keyPath
     * @param {any} value
     * @return {Object}
     */
    export function hset(domain, keyPath, value) {
      return {
        type: HSET,
        payload: {
          path: [domain, keyPath].join('.'),
          value
        }
      }
    }

    export function hdel(domain, keyPath) {
      return {
        type: HDEL,
        payload: {
          path: [domain, keyPath].join('.')
        }
      }
    }

    /**
     * Merges a Javascript object in an existing hash
     * @param {String} domain
     * @param {Object} map
     * @return {Object}
     */
    export function hmset(domain, map) {
      return {
        type: HMSET,
        payload: {
          path: domain,
          value: map
        }
      }
    }

    export function hincrby(domain, key, delta) {
      return {
        type: HINCRBY,
        payload: {
          path: [domain, key].join('.'),
          value: delta
        }
      }
    }

    /*
    Toggles a Boolean key in a hash. If key is not present, it will assumed to
    be false, so htoggle() will cause it to be true.
    */

    export function htoggle(domain, key) {
      return {
        type: HTOGGLE,
        payload: {
          path: [domain, key].join('.')
        }
      }
    }