# Code coverage report for Livewire/lib/respond.js

## Statements: 61.54% (16 / 26) Branches: 47.06% (8 / 17) Functions: 44.44% (4 / 9) Lines: 61.54% (16 / 26) Ignored: none

All files » Livewire/lib/ » respond.js

    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
    421
    1
    1
    1
    1

    1

    1
    9
    9

    1
    1

    10
    9
    9
    9

    1

     (function(){
      var ref$, Some, None, compilePath, guard, respond, i$, len$, m, out$ = typeof exports != 'undefined' && exports || this;
      ref$ = require('fantasy-options'), Some = ref$.Some, None = ref$.None;
      compilePath = require('./compiler').compilePath;
      guard = function(cond){
        if (cond) {
          return Some(null);
        } else {
          return None;
        }
      };
      out$.respond = respond = curry$(function(method, path, responder){
        var lower, extract;
        lower = method.toLowerCase();
        extract = compilePath(path);
        return function(request){
          return guard(lower === method.toLowerCase()).chain(function(){
            return extract(request.url).chain(function(params){
              return Some(responder((request.params = params, request)));
            });
          });
        };
      });
      for (i$ = 0, len$ = (ref$ = ['get', 'post', 'put', 'delete', 'patch', 'options', 'head', 'trace', 'connect']).length; i$ < len$; ++i$) {
        m = ref$[i$];
        exports[m] = respond(m);
      }
      function curry$(f, bound){
        var context,
        _curry = function(args) {
          return f.length > 1 ? function(){
            var params = args ? args.concat() : [];
            context = bound ? context || this : this;
            return params.push.apply(params, arguments) <
                f.length && arguments.length ?
              _curry.call(context, params) : f.apply(context, params);
          } : f;
        };
        return _curry();
      }
    }).call(this);