index.js
function(h, s, l, a) {
    h = (number(h) % 360) / 360;
    s = number(s); l = number(l); a = number(a);
    if ([h, s, l, a].some(isNaN)) return null;

    var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s,
    m1 = l * 2 - m2;

    return this.rgba(hue(h + 1 / 3) * 255,
      hue(h) * 255,
      hue(h - 1 / 3) * 255,
      a);

    function hue(h) {
      h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h);
      if (h * 6 < 1) return m1 + (m2 - m1) * h * 6;
      else if (h * 2 < 1) return m2;
      else if (h * 3 < 2) return m1 + (m2 - m1) * (2 / 3 - h) * 6;
      else return m1;
    }
  }
function(h, s, l, a) {
    h = (number(h) % 360) / 360;
    s = number(s); l = number(l); a = number(a);
    if ([h, s, l, a].some(isNaN)) return null;

    var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s,
    m1 = l * 2 - m2;

    return this.rgba(hue(h + 1 / 3) * 255,
      hue(h) * 255,
      hue(h - 1 / 3) * 255,
      a);

    function hue(h) {
      h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h);
      if (h * 6 < 1) return m1 + (m2 - m1) * h * 6;
      else if (h * 2 < 1) return m2;
      else if (h * 3 < 2) return m1 + (m2 - m1) * (2 / 3 - h) * 6;
      else return m1;
    }
  }
function ( h , s , l , a ) { h = ( number ( h ) % 360 ) / 360 ; s = number ( s ) ; l = number ( l ) ; a = number ( a ) ; if ( [ h , s , l , a ] . some ( isNaN ) ) return null ; var m2 = l <= 0.5 ? l * ( s + 1 ) : l + s - l * s , m1 = l * 2 - m2 ; return this . rgba ( hue ( h + 1 / 3 ) * 255 , hue ( h ) * 255 , hue ( h - 1 / 3 ) * 255 , a ) ; function hue ( h ) { h = h < 0 ? h + 1 : ( h > 1 ? h - 1 : h ) ; if ( h * 6 < 1 ) return m1 + ( m2 - m1 ) * h * 6 ; else if ( h * 2 < 1 ) return m2 ; else if ( h * 3 < 2 ) return m1 + ( m2 - m1 ) * ( 2 / 3 - h ) * 6 ; else return m1 ; } }
Given an HSL color as components, return an RGBA array

@param {number} h hue
@param {number} s saturation
@param {number} l luminosity
@param {number} a alpha
@returns {Array} rgba color
Given an HSL color as components return an RGBA array