/**
 * Create a new instance.
 * @function create
 * @param {object} data - Apemanfile data.
 * @param {object} options - Optional settings.
 * @returns {Apemanfile}
 */

'use strict'

const Apemanfile = require('./apemanfile')

/** @lends create */
function create (data, options = {}) {
  let cacheKey = data && data.$name
  let cached = cacheKey && create._cache[ cacheKey ]
  if (cached) {
    return cached
  }
  let configuration = new Apemanfile(data, options)
  if (cacheKey) {
    create._cache[ cacheKey ] = configuration
  }
  return configuration
}
create._cache = {}

module.exports = create
