'use strict';

var chroma = require('chroma-js');
var cdiff = require('color-diff');
var palette = [];

function closest(color, palette) {
    palette.map(function (paletteColor, index, palette) {
        palette[index] = {
            'R': paletteColor.rgb()[0],
            'G': paletteColor.rgb()[1],
            'B': paletteColor.rgb()[2]
        };
    });

    color = {
        'R': color.rgb()[0],
        'G': color.rgb()[1],
        'B': color.rgb()[2]
    };

    console.log(color, palette);

    var bestMatch = cdiff.closest(color, palette);

    return new chroma(bestMatch.R, bestMatch.G, bestMatch.B);
}

var L = {
    'xx-low': 15,
    'low': 25,
    'medium': 50,
    'high': 75,
    'xx-high': 95
};

var c = {
    'x-low': 15,
    'low': 33,
    'medium': 50,
    'high': 67,
    'x-high': 85,
};

var h = {
    'red':     276 + 120 - 15, // triad
    'orange':  51,             // locked BASE
    'yellow':  276 - 180,      // locked complementary
    'green':   276 - 120 - 15, // triad
    'cyan':    276 - 60 - 15,  // complement triad
    'blue':    276,            // locked BASE
    'violet':  51 + 270 - 15,       //
    'magenta': 276 + 60 - 15,  // complement triad
};

var black = new chroma.lch(15, 15, h['blue']);
var white = new chroma.lch(95, 15, h['yellow']);
var orange = new chroma.lch(L['medium'], c['high'], h['orange']);
var greyscale = chroma.scale([black, white]);

var whiteHighlight = chroma.scale([ white, chroma.lch(L['xx-low'], c['high'], h['orange']) ]);
console.log('hlwhite', whiteHighlight(1).hex());
var blackHighlight = chroma.scale([ black, chroma.lch(L['xx-high'], c['high'], h['orange']) ]);
console.log('hlblack', blackHighlight(1).hex());

Object.keys(h).map(function (color, index) {
    palette.push(new chroma.lch(
        L['medium'],
        c['low'],
        h[color]
    ));
});

console.log(closest(new chroma('navy'), palette));

@@ -632,17 +632,17 @@
 %0A    'xx
--
+_
 low': 15
@@ -699,17 +699,17 @@
 %0A    'xx
--
+_
 high': 9
@@ -730,17 +730,17 @@
 %7B%0A    'x
--
+_
 low': 15
@@ -796,17 +796,17 @@
 ,%0A    'x
--
+_
 high': 8
@@ -1234,16 +1234,13 @@
 5, h
-%5B'
+.
 blue
-'%5D
 );%0Av
@@ -1278,18 +1278,15 @@
 5, h
-%5B'
+.
 yellow
-'%5D
 );%0Av
@@ -1317,42 +1317,33 @@
 ch(L
-%5B'
+.
 medium
-'%5D
 , c
-%5B'
+.
 high
-'%5D
 , h
-%5B'
+.
 orange
-'%5D
 );%0Av
@@ -1447,42 +1447,33 @@
 ch(L
-%5B'xx-
+.xx_
 low
-'%5D
 , c
-%5B'
+.
 high
-'%5D
 , h
-%5B'
+.
 orange
-'%5D
 ) %5D)
@@ -1582,43 +1582,34 @@
 ch(L
-%5B'xx-
+.xx_
 high
-'%5D
 , c
-%5B'
+.
 high
-'%5D
 , h
-%5B'
+.
 orange
-'%5D
 ) %5D)
@@ -1751,18 +1751,15 @@
    L
-%5B'
+.
 medium
-'%5D
 ,%0A  
@@ -1769,15 +1769,12 @@
    c
-%5B'
+.
 low
-'%5D
 ,%0A  

Use dot notation