index.js
function predefine(obj, pattern) {
  pattern = pattern || predefine.READABLE;

  return function predefined(method, description, clean) {
    //
    // If we are given a description compatible Object, use that instead of
    // setting it as value. This allows easy creation of getters and setters.
    //
    if (
         !predefine.descriptor(description)
      || is(description, 'object')
         && !clean
         && !predefine.descriptor(predefine.mixin({}, pattern, description))
    ) { description = {
        value: description
      };
    }

    //
    // Prevent thrown errors when we attempt to override a readonly
    // property
    //
    var described = Object.getOwnPropertyDescriptor(obj, method);
    if (described && !described.configurable) {
      return predefined;
    }

    Object.defineProperty(obj, method, !clean
      ? predefine.mixin({}, pattern, description)
      : description
    );

    return predefined;
  };
}
function predefine(obj, pattern) {
  pattern = pattern || predefine.READABLE;

  return function predefined(method, description, clean) {
    //
    // If we are given a description compatible Object, use that instead of
    // setting it as value. This allows easy creation of getters and setters.
    //
    if (
         !predefine.descriptor(description)
      || is(description, 'object')
         && !clean
         && !predefine.descriptor(predefine.mixin({}, pattern, description))
    ) { description = {
        value: description
      };
    }

    //
    // Prevent thrown errors when we attempt to override a readonly
    // property
    //
    var described = Object.getOwnPropertyDescriptor(obj, method);
    if (described && !described.configurable) {
      return predefined;
    }

    Object.defineProperty(obj, method, !clean
      ? predefine.mixin({}, pattern, description)
      : description
    );

    return predefined;
  };
}
function predefine ( obj , pattern ) { pattern = pattern || predefine . READABLE ; return function predefined ( method , description , clean ) { // // If we are given a description compatible Object, use that instead of // setting it as value. This allows easy creation of getters and setters. // if ( ! predefine . descriptor ( description ) || is ( description , 'object' ) && ! clean && ! predefine . descriptor ( predefine . mixin ( { } , pattern , description ) ) ) { description = { value : description } ; } // // Prevent thrown errors when we attempt to override a readonly // property // var described = Object . getOwnPropertyDescriptor ( obj , method ) ; if ( described && ! described . configurable ) { return predefined ; } Object . defineProperty ( obj , method , ! clean ? predefine . mixin ( { } , pattern , description ) : description ) ; return predefined ; } ; }
Predefine, preconfigure an Object.defineProperty.

@param {Object} obj The context, prototype or object we define on.
@param {Object} pattern The default description.
@param {Boolean} override Override the pattern.
@returns {Function} The function definition.
@api public
Predefine preconfigure an Object . defineProperty .