1'use strict';
2
3const _ = require('lodash');
4
5/*----------------------------------------------------------------------------*/
6
7/**
8 * Creates a hash object. If a `properties` object is provided, its own
9 * enumerable properties are assigned to the created hash.
10 *
11 * @memberOf util
12 * @param {Object} [properties] The properties to assign to the hash.
13 * @returns {Object} Returns the new hash object.
14 */
15function Hash(properties) {
16  return _.transform(properties, (result, value, key) => {
17    result[key] = (_.isPlainObject(value) && !(value instanceof Hash))
18      ? new Hash(value)
19      : value;
20  }, this);
21}
22
23Hash.prototype = Object.create(null);
24
25/**
26 * This method throws any error it receives.
27 *
28 * @memberOf util
29 * @param {Object} [error] The error object.
30 */
31function pitch(error) {
32  if (error != null) {
33    throw error;
34  }
35}
36
37module.exports = {
38  Hash,
39  pitch
40};
41