<reponame>ZhivkoTringov/SoftUni---Software-Engineering-program<filename>JS-Front-End/05. HTTP and REST - Exercise/01.Bus-Stop/node_modules/chai/lib/chai/utils/getProperties.js<gh_stars>0/*!
 * Chai - getProperties utility
 * Copyright(c) 2012-2014 Jake Luer <kenaa@example.com>
 * MIT Licensed
 */

/**
 * ### .getProperties(object)
 *
 * This allows the retrieval of property names of an object, enumerable or not,
 * inherited or not.
 *
 * @param {Object} object
 * @returns {Array}
 * @namespace Utils
 * @name getProperties
 * @api public
 */

module.exports = function getProperties(object) {
  var result = Object.getOwnPropertyNames(object);

  function addProperty(property) {
    if (result.indexOf(property) === -1) {
      result.push(property);
    }
  }

  var proto = Object.getPrototypeOf(object);
  while (proto !== null) {
    Object.getOwnPropertyNames(proto).forEach(addProperty);
    proto = Object.getPrototypeOf(proto);
  }

  return result;
};
