/**
# describe

A simple function for describing the values of things.

    const description = describe(variable_name);

~~~~
const describe = _required_;
Test(() => describe(undefined)).shouldBe('undefined');
Test(() => describe(null)).shouldBe('null');
Test(() => describe(NaN)).shouldBe('NaN');
Test(() => describe(17)).shouldBe('17');
Test(() => describe('hello, world')).shouldBe('hello, world');
Test(() => describe([])).shouldBe('[]');
Test(() => describe({})).shouldBe('{}');
Test(() => describe([1,2,3])).shouldBe('[3 x 1]');
Test(() => describe([{x:0,y:0},{x:0,y:0},{x:0,y:0}])).shouldBe('[3 x {x,y}]');
Test(() => describe({a:0,b:1,c:2,d:3,e:4})).shouldBe('{a,b,c,d,…}');
~~~~
*/

// from https://stackoverflow.com/questions/1007981/how-to-get-function-parameter-names-values-dynamically
var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
var ARGUMENT_NAMES = /([^\s,]+)/g;
function getParamNames(func) {
  var fnStr = func.toString().replace(STRIP_COMMENTS, '');
  var result = fnStr.slice(fnStr.indexOf('(')+1, fnStr.indexOf(')')).match(ARGUMENT_NAMES);
  if(result === null)
     result = [];
  return result;
}

function describe(x) {
  if (x === undefined) {
    return 'undefined';
  } else if (Array.isArray(x)) {
    return x.length ? `[${describe(x[0])} × ${x.length}]` : '[]';
  } else if (x && x.constructor === Object) {
    const keys = Object.keys(x);
    if (keys.length > 4) {
      keys.splice(4);
      keys.push('…');
    }
    return `{${keys.join(',')}}`;
  } else if (typeof x === 'string') {
    return x;
  } else if (typeof x === 'function') {
    return `ƒ(${getParamNames(x).join(',')})`;
  } else if (isNaN(x)) {
    return 'NaN';
  } else {
    return JSON.stringify(x);
  }
}

module.exports = describe;

@@ -329,16 +329,25 @@
 ldBe('17
+ (number)
 ');%0ATest
@@ -389,16 +389,17 @@
 ouldBe('
+%22
 hello, w
@@ -402,16 +402,17 @@
 o, world
+%22
 ');%0ATest
@@ -534,13 +534,22 @@
 e('%5B
-3 x 1
+1 (number) %C3%97 3
 %5D');
@@ -618,17 +618,17 @@
 e('%5B
-3 x 
 %7Bx,y%7D
+ %C3%97 3
 %5D');
@@ -1557,17 +1557,24 @@
  return 
-x
+%60%22$%7Bx%7D%22%60
 ;%0A  %7D el
@@ -1697,16 +1697,82 @@
  'NaN';%0A
+  %7D else if (typeof x === 'number') %7B%0A    return %60$%7Bx%7D (number)%60;%0A
   %7D else

fix — unit tests were out-of-date new — added quotations marks to string description and (number) to number description