Returns a new stamp given a descriptor and a compose function implementation.
@param {Descriptor} [descriptor={}] The information about the object the stamp will be creating.
@returns {Stamp} The new stamp
439353
function createStamp(descriptor) {
    var1 = createFactory();

    var2 = descriptor[_staticDeepProperties];
    if (var2) merge(var1, var2);

    var2 = descriptor[_staticProperties];
    if (var2) assign(var1, var2);

    var2 = descriptor[_staticPropertyDescriptors];
    if (var2) defineProperties(var1, var2);

    var2 = isFunction(var1[_compose]) ? var1[_compose] : compose;
    assign(var1[_compose] = function() {
      return var2.apply(this, arguments);
    }, descriptor);

    return var1;
  }
622068
function Signature( options ) {
  
  if( !(this instanceof Signature) )
    return new Signature( options )
  
  // Signing algorithm
  this.algorithm     = 'rsa-sha256'
  // Headers canonicalization / normalization type
  this.canonical     = 'simple'
  this.copiedHeaders = []
  // Signing domain
  this.domain        = null
  this.expires       = null
  this.hash          = null
  // Headers
  this.headers       = []
  this.identity      = null
  this.length        = null
  this.query         = 'dns/txt'
  this.selector      = null
  // DKIM Signature data (base64)
  this.signature     = null
  this.timestamp     = null
  // DKIM version
  this.version       = '1'
  
  var self = this
  
  if( options != null ) {
    Object.keys( options ).forEach( function( k, v ) {
      if( Signature.fields.indexOf( k ) !== -1 ) {
        self[ k ] = options[ k ]
      }
    })
  }
  
}
817221
function createGetter(target, property, subject) {
  var targetDesc = {
    enumerable: subject.propertyIsEnumerable(property),
    get: function() {
      return subject[property];
    },
    set: function(value) {
      subject[property] = value;
    }
  };

  Object.defineProperty(target, property, targetDesc);
}
159005
function (def) {
	if (def) {
		var self = this,
			index,
			count,
			tmpDef,
			defNewKey,
			sigIndex,
			signatures;

		if (!(def instanceof Array)) {
			tmpDef = {};

			// Def is an object, make sure all prop names are devoid of spaces
			for (index in def) {
				if (def.hasOwnProperty(index)) {
					defNewKey = index.replace(/ /g, '');

					// Check if the definition array has a * string in it
					if (defNewKey.indexOf('*') === -1) {
						// No * found
						tmpDef[defNewKey] = def[index];
					} else {
						// A * was found, generate the different signatures that this
						// definition could represent
						signatures = this.generateSignaturePermutations(defNewKey);

						for (sigIndex = 0; sigIndex < signatures.length; sigIndex++) {
							if (!tmpDef[signatures[sigIndex]]) {
								tmpDef[signatures[sigIndex]] = def[index];
							}
						}
					}
				}
			}

			def = tmpDef;
		}

		return function () {
			var arr = [],
				lookup,
				type;

			// Check if we are being passed a key/function object or an array of functions
			if (def instanceof Array) {
				// We were passed an array of functions
				count = def.length;
				for (index = 0; index < count; index++) {
					if (def[index].length === arguments.length) {
						return self.callExtend(this, '$main', def, def[index], arguments);
					}
				}
			} else {
				// Generate lookup key from arguments
				// Copy arguments to an array
				for (index = 0; index < arguments.length; index++) {
					type = typeof arguments[index];

					// Handle detecting arrays
					if (type === 'object' && arguments[index] instanceof Array) {
						type = 'array';
					}

					// Handle been presented with a single undefined argument
					if (arguments.length === 1 && type === 'undefined') {
						break;
					}

					// Add the type to the argument types array
					arr.push(type);
				}

				lookup = arr.join(',');

				// Check for an exact lookup match
				if (def[lookup]) {
					return self.callExtend(this, '$main', def, def[lookup], arguments);
				} else {
					for (index = arr.length; index >= 0; index--) {
						// Get the closest match
						lookup = arr.slice(0, index).join(',');

						if (def[lookup + ',...']) {
							// Matched against arguments + "any other"
							return self.callExtend(this, '$main', def, def[lookup + ',...'], arguments);
						}
					}
				}
			}

			throw('Irrelon Overload: Overloaded method does not have a matching signature for the passed arguments: ' + JSON.stringify(arr));
		};
	}

	return function () {};
}
189017
def new(cls, rId, reltype, target, target_mode=RTM.INTERNAL):
        
        xml = '<Relationship xmlns="%s"/>' % nsmap['pr']
        relationship = parse_xml(xml)
        relationship.rId = rId
        relationship.reltype = reltype
        relationship.target_ref = target
        relationship.targetMode = target_mode
        return relationship
420888
function Documentation() {
  return {
    composes: [],
    descriptors: {},
    getPropDescriptor(name) {
      return this.descriptors[name] || (this.descriptors[name] = {});
    },
    addComposes(name) {
      this.composes.push(name);
    },
    set(key, value) {
      this[key] = value;
    },
  };
}
349711
function create_constructor(type_name) {

		if(Object.prototype.hasOwnProperty.call(constructors, type_name)) {
			return constructors[type_name];
		}

		if(!( Object.prototype.hasOwnProperty.call(_schema.definitions, type_name) && is.def(_schema.definitions[type_name]) )) {
			throw new TypeError("No definition for " + type_name);
		}
		var definition = _schema.definitions[type_name];

		// ParentType is either SchemaObject or another definition
		var ParentType = SchemaObject;
		if( is.obj(definition) && is.def(definition.$ref) && string_starts_with(definition.$ref, '#/definitions/') ) {
			ParentType = create_constructor( definition.$ref.split('/').slice(2).join('/') );
		}

		// FIXME: If a type has $refs, we should create a copy of schema which defines all those $refs.
		// Currently just copies schema and changes it to point our definition. Not ideal solution.
		var copy_definition = JSON.parse(JSON.stringify(_schema));
		copy_definition.oneOf = [{"$ref": '#/definitions/'+type_name }];

		/* This is our real constructor which will be called in `new Function()` */
		function _constructor(self, opts) {
			var tmp;

			// Check opts validity
			var validity = SchemaObject.validate(opts, copy_definition);
			if(!validity.valid) { throw new TypeError("bad argument: " + util.inspect(validity) ); }

			// Call parent constructors
			ParentType.call(self, opts);

			// Call custom constructors
			//util.debug( util.inspect( _user_defined_constructors ));
			if(Object.prototype.hasOwnProperty.call(_user_defined_constructors, type_name)) {
				tmp = _user_defined_constructors[type_name].call(self, opts);
				if(is.def(tmp)) {
					SchemaObject.prototype._setValueOf.call(self, tmp);
				}
				//util.debug( util.inspect( tmp ) );
			}

			// Setup getters and setters if schema has properties
			//util.debug( "\ndefinition = \n----\n" + util.inspect( definition ) + "\n----\n\n" );
			if(definition && definition.properties) {
				Object.getOwnPropertyNames(definition.properties).forEach(function(key) {
					self.__defineGetter__(key, function(){
						return self.valueOf()[key];
					});
					self.__defineSetter__(key, function(val){
						// FIXME: Implement value validation and do not use `.valueOf()`!
						self.valueOf()[key] = val;
					});
				});
			}

		}

		var func_name = escape_func_name(type_name);

		// JavaScript does not support better way to change function names...
		var code = [
			'function '+func_name+' (opts) {',
			'	if(!(this instanceof '+func_name+')) {',
			'		return new '+func_name+'(opts);',
			'	};',
			'	_constructor.call(this, this, opts);',
			'};'
		];

		var Type = (new Function('_constructor', 'return '+code.join('\n')))(_constructor);

		util.inherits(Type, ParentType);

		/* Returns source code for type */
		//Type.toSource = function() {
		//	return '(new Function(\'' + [''+_constructor, ''+Type].join('\n') + '))();';
		//};

		constructors[type_name] = Type;

		// User-defined methods
		function post_user_defines(context) {
			if(Object.prototype.hasOwnProperty.call(_user_defined_methods, type_name)) {
				_user_defined_methods[type_name].call(context, Type, context);
			}
		}

		post_user_defines({'constructors':constructors, 'schema':_schema});

		return constructors[type_name];
	}
720152
function setFunction(descriptor,key,set,update)
        {
          var _descriptor = descriptor,
              _descVal = _descriptor.value,
              _key = key,
              _set = set,
              _update = update,
              _action;
          return function functionSet()
          {
            if(_set(this,_key,null,null,arguments,this._stopChange))
            {
              _action = _descVal.apply(this,arguments);
            }
            if(!this._stopChange)
            {
              _update(this,_key,null,null,arguments,_action);
            }
            this._stopChange = undefined;
            return _action;
          }
        }
907022
function Schema(options, descriptors) {

    if (!descriptors) {
        descriptors = options;
        options = null;
    }

    function opt(name, type) {
        var value = options[name];
        if (value !== undefined) {
            if (typeof value === type) return value;
            else throw new TypeError(current + 'options : ' + name + ': "' +
                value + '" is not of type [' + type + ']');
        }
        else return false;
    }

    var current = 'Schema: arguments: ',
        defaults = { required: false };

    if (hasValue(options)) {
        if (type(options) === 'object') {
            defaults.required = opt('required', 'boolean');
            if (opt('validator', 'function')) defaults.validator = options.validator;
        }
        else throw new TypeError(current + 'options: must be of type [object]');
    }

    current += 'descriptors: ';
    if (typeof descriptors !== 'object')
        throw new TypeError(current + 'must be of type [object]');
    if (!Array.isArray(descriptors)) {
        descriptors = this.toDescriptors(descriptors, defaults);
    }
    if (options && options.extends instanceof Schema) {
        descriptors = this.extendDescriptors(descriptors, options.extends.descriptors);
    }
    if (!descriptors.length)
        throw new TypeError(current + 'contains no values');
    else if (!(descriptors[0] instanceof Descriptor)) {
        throw new TypeError(current + 'must be instances of Descriptor class');
    }
    var instance = this;
    this.descriptors = descriptors;

}
1001558
function(json){
  
  // Protect against forgetting the new keyword when calling the constructor
  if(!(this instanceof Address)){
    return new Address(json);
  }
  
  // If the given object is already an instance then just return it. DON'T copy it.
  if(Address.isInstance(json)){
    return json;
  }
  
  this.init(json);
}
527899
function createChain(descriptor, callback) {
    if (typeof descriptor !== 'object') {
        throw new TypeError('createChain: descriptor is not an object: ' +
                            descriptor);
    }

    //Create the Chain class.
    function CustomChain(callback) {
        if (!(this instanceof CustomChain)) {
            return new CustomChain(callback);
        }
        CustomChain.super_.call(this, callback);
        CustomChain._lists.forEach(function(listName) {
            this._result[listName] = [];
        }, this);
    }
    util.inherits(CustomChain, Chain);
    if (callback) {
        CustomChain.prototype._callback = callback;
    }

    //This will come to contain the names of all lists in the chain.
    CustomChain._lists = [];

    //Add descriptor properties to Chain prototype.
    var keys = Object.keys(descriptor);
    keys.forEach(function(key) {
        var property = descriptor[key];
        //When a chain method is called, a number of actions need to take place.
        var actionList = [
            //1. Decide what item to store from the arguments.
            getArgumentInterpreter(property.elem),
            //2. Decide whether to set or push the item to store to an array.
            getPropertySetter(CustomChain, key, property.plural),
            //3. End the chain or return `this` for further chaining.
            getChainEnder(CustomChain, property.end)
        ].reverse();
        CustomChain.prototype[key] = _.compose.apply(null, actionList);
    });

    return CustomChain;
}
90225
async function retrieveDescriptor(descriptor) {

  // Inline
  if (isPlainObject(descriptor)) {
    descriptor = cloneDeep(descriptor)

  // Remote
  } else if (isRemotePath(descriptor)) {
    const res = await axios.get(descriptor)
    descriptor = res.data

    // Loading error
    if (res.status >= 400) {
      throw new TableSchemaError(`Can't load descriptor at "${descriptor}"`)
    }

  // Local
  } else {

    // Browser error
    if (config.IS_BROWSER) {
      throw new TableSchemaError('Local paths are not supported in browser')
    }

    // Load/parse data
    try {
      descriptor = await new Promise((resolve, reject) => {
        fs.readFile(descriptor, 'utf-8', (error, data) => {
          if (error) reject(error)
          try {resolve(JSON.parse(data))} catch (error) {reject(error)}
        })
      })

    // Load/parse erorr
    } catch (error) {
      throw new TableSchemaError(`Can't load descriptor at "${descriptor}"`)
    }

  }

  return descriptor
}
1225196
def new(cls, ver_key: VerKey, sign_key: SignKey) -> 'ProofOfPossession':
        
        logger = logging.getLogger(__name__)
        logger.debug("ProofOfPossession::new: >>>")

        c_instance = c_void_p()
        do_call(cls.new_handler, ver_key.c_instance, sign_key.c_instance, byref(c_instance))

        res = cls(c_instance)

        logger.debug("ProofOfPossession::new: <<< res: %r", res)
        return res
909328
function init(obj = {}, prevName = '') {
    return new Proxy(obj, {
        get (target, name) {
            if (typeof name === 'symbol' || deflectedProperties.includes(name)) {
                return Reflect.get(target, name);
            }
            ns.resetTo(prevName);
            ns.push(name);
            let value = process.env[ns.serialize()];
            if (value) {
                ns.pop();
                return value;
            }
            return init(target, name);
        },
        set (target, name, val) {
            ns.resetTo(prevName);
            ns.push(name);
            let value = String(val);
            process.env[ns.serialize()] = value;
            ns.pop();
            return value;
        }
    });
}
1139011
Node createObjectDotAssignCall(Scope scope, JSType returnType, Node... args) {
    Node objAssign = createQName(scope, "Object.assign");
    Node result = createCall(objAssign, args);

    if (isAddingTypes()) {
      // Make a unique function type that returns the exact type we've inferred it to be.
      // Object.assign in the externs just returns !Object, which loses type information.
      JSType objAssignType =
          registry.createFunctionTypeWithVarArgs(
              returnType,
              registry.getNativeType(JSTypeNative.OBJECT_TYPE),
              registry.createUnionType(JSTypeNative.OBJECT_TYPE, JSTypeNative.NULL_TYPE));
      objAssign.setJSType(objAssignType);
      result.setJSType(returnType);
    }

    return result;
  }
156007
function isPropertyDescriptor(ES, Desc) {
    if (ES.Type(Desc) !== 'Object') {
      return false;
    }
    var allowed = {
      '[[Configurable]]': true,
      '[[Enumerable]]': true,
      '[[Get]]': true,
      '[[Set]]': true,
      '[[Value]]': true,
      '[[Writable]]': true
    };

    for (var key in Desc) { // eslint-disable-line
      if (has(Desc, key) && !allowed[key]) {
        return false;
      }
    }

    var isData = has(Desc, '[[Value]]');
    var IsAccessor = has(Desc, '[[Get]]') || has(Desc, '[[Set]]');
    if (isData && IsAccessor) {
      throw new $TypeError('Property Descriptors may not be both accessor and data descriptors');
    }
    return true;
  }
404248
def create(cls, obj, body, evaldict, defaults=None,
               doc=None, module=None, addsource=True, **attrs):
        
        if isinstance(obj, str): # "name(signature)"
            name, rest = obj.strip().split('(', 1)
            signature = rest[:-1] #strip a right parens
            func = None
        else: # a function
            name = None
            signature = None
            func = obj
        self = cls(func, name, signature, defaults, doc, module)
        ibody = '\n'.join('    ' + line for line in body.splitlines())
        return self.make('def %(name)s(%(signature)s):\n' + ibody,
                        evaldict, addsource, **attrs)