Code coverage report for nodash/lib/Tuple.js

Statements: 100% (26 / 26)      Branches: 100% (2 / 2)      Functions: 100% (11 / 11)      Lines: 100% (26 / 26)      Ignored: none     

All files » nodash/lib/ » Tuple.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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65      1   5   1 478 1     477 477   477   5   1 473     1 123     1 94     5       7       7               1 1 2   1       2 2 1   2          
/* vim: set et sw=2 ts=2: */
'use strict';
 
module.exports = [ 'freeze', function (freeze) {
 
  var Nodash = this;
  
  function Tuple(fst, snd) {
    if (!(this instanceof Tuple)) {
      return new Tuple(fst, snd);
    }
 
    this.fst = Nodash.idf(fst);
    this.snd = Nodash.idf(snd);
 
    freeze(this);
  }
  Tuple.__type = 'tuple';
 
  function tuple(first, second) {
    return new Tuple(first, second);
  }
 
  function tuple3(first, second, third) {
    return tuple(first, tuple(second, third));
  }
 
  function tuple4(first, second, third, fourth) {
    return tuple3(first, second, tuple(third, fourth));
  }
 
  return {
    Tuple: Tuple,
    
    fst: function (t) {
      return t.fst();
    },
 
    snd: function (t) {
      return t.snd();
    },
 
    ', tuple': tuple,
    ',, tuple3': tuple3,
    ',,, tuple4': tuple4,
 
    tuplesToObject: function (xs) {
      var obj = {};
      Nodash.each(function (t) {
        obj[t.fst()] = t.snd();
      }, xs);
      return obj;
    },
 
    objectToArray: function (obj) {
      var arr = [];
      Nodash.each(function (val, key) {
        arr.push(new Tuple(key, val));
      }, obj);
      return arr;
    }
 
  };  
}];