Sha256: ae2fda6a0c563a19f7351bc4ff2c1ae272de56a861ee1148ddf4d888cac9789e

Contents?: true

Size: 1.09 KB

Versions: 100

Compression:

Stored size: 1.09 KB

Contents

/*!
 * Chai - flag utility
 * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
 * MIT Licensed
 */

/*!
 * Module dependancies
 */

var inspect = require('./inspect');

/**
 * ### .objDisplay (object)
 *
 * Determines if an object or an array matches
 * criteria to be inspected in-line for error
 * messages or should be truncated.
 *
 * @param {Mixed} javascript object to inspect
 * @name objDisplay
 * @api public
 */

module.exports = function (obj) {
  var str = inspect(obj)
    , type = Object.prototype.toString.call(obj);

  if (str.length >= 40) {
    if (type === '[object Function]') {
      return !obj.name || obj.name === ''
        ? '[Function]'
        : '[Function: ' + obj.name + ']';
    } else if (type === '[object Array]') {
      return '[ Array(' + obj.length + ') ]';
    } else if (type === '[object Object]') {
      var keys = Object.keys(obj)
        , kstr = keys.length > 2
          ? keys.splice(0, 2).join(', ') + ', ...'
          : keys.join(', ');
      return '{ Object (' + kstr + ') }';
    } else {
      return str;
    }
  } else {
    return str;
  }
};

Version data entries

100 entries across 68 versions & 1 rubygems

Version Path
ende-0.2.18 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/objDisplay.js
ende-0.2.17 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/objDisplay.js
ende-0.2.16 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/objDisplay.js
ende-0.2.15 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/objDisplay.js
ende-0.2.14 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/objDisplay.js
ende-0.2.13 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/objDisplay.js
ende-0.2.12 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/objDisplay.js
ende-0.2.11 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/objDisplay.js
ende-0.2.10 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/objDisplay.js
ende-0.2.3 vendor/assets/components/chaijs-chai/lib/chai/utils/objDisplay.js
ende-0.2.3 vendor/components/chaijs-chai/lib/chai/utils/objDisplay.js
ende-0.2.3 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/objDisplay.js
ende-0.2.2 vendor/assets/components/chaijs-chai/lib/chai/utils/objDisplay.js
ende-0.2.2 vendor/components/chaijs-chai/lib/chai/utils/objDisplay.js
ende-0.2.2 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/objDisplay.js
ende-0.2.1 vendor/components/chaijs-chai/lib/chai/utils/objDisplay.js
ende-0.2.1 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/objDisplay.js
ende-0.2.1 vendor/assets/components/chaijs-chai/lib/chai/utils/objDisplay.js
ende-0.2.0 vendor/assets/components/chaijs-chai/lib/chai/utils/objDisplay.js
ende-0.2.0 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/objDisplay.js