index.js
function descriptor(obj) {
  if (!obj || 'object' !== typeof obj || Array.isArray(obj)) return false;

  var keys = Object.keys(obj);

  //
  // A descriptor can only be a data or accessor descriptor, never both.
  // An data descriptor can only specify:
  //
  // - configurable
  // - enumerable
  // - (optional) value
  // - (optional) writable
  //
  // And an accessor descriptor can only specify;
  //
  // - configurable
  // - enumerable
  // - (optional) get
  // - (optional) set
  //
  if (
       ('value' in obj || 'writable' in obj)
    && ('function' === typeof obj.set || 'function' === typeof obj.get)
  ) return false;

  return !!keys.length && keys.every(function allowed(key) {
    var type = description[key]
      , valid = type === undefined || is(obj[key], type);

    return key in description && valid;
  });
}
function descriptor(obj) {
  if (!obj || 'object' !== typeof obj || Array.isArray(obj)) return false;

  var keys = Object.keys(obj);

  //
  // A descriptor can only be a data or accessor descriptor, never both.
  // An data descriptor can only specify:
  //
  // - configurable
  // - enumerable
  // - (optional) value
  // - (optional) writable
  //
  // And an accessor descriptor can only specify;
  //
  // - configurable
  // - enumerable
  // - (optional) get
  // - (optional) set
  //
  if (
       ('value' in obj || 'writable' in obj)
    && ('function' === typeof obj.set || 'function' === typeof obj.get)
  ) return false;

  return !!keys.length && keys.every(function allowed(key) {
    var type = description[key]
      , valid = type === undefined || is(obj[key], type);

    return key in description && valid;
  });
}
function descriptor ( obj ) { if ( ! obj || 'object' !== typeof obj || Array . isArray ( obj ) ) return false ; var keys = Object . keys ( obj ) ; // // A descriptor can only be a data or accessor descriptor, never both. // An data descriptor can only specify: // // - configurable // - enumerable // - (optional) value // - (optional) writable // // And an accessor descriptor can only specify; // // - configurable // - enumerable // - (optional) get // - (optional) set // if ( ( 'value' in obj || 'writable' in obj ) && ( 'function' === typeof obj . set || 'function' === typeof obj . get ) ) return false ; return ! ! keys . length && keys . every ( function allowed ( key ) { var type = description [ key ] , valid = type === undefined || is ( obj [ key ] , type ) ; return key in description && valid ; } ) ; }
Check if a given object is valid as an descriptor.

@param {Object} obj The object with a possible description.
@returns {Boolean}
@api public
Check if a given object is valid as an descriptor .