Creates object creator

@param {string}    factoryName Factory name
@param {*|factory} object      Object or its factory function
@returns {Function} Object     creator

@this {Injector}
@private
765179
function(factoryName, object) {
                        if (_.isUndefined(object)) {
                            object = factoryName;
                            factoryName = undefined;
                        }

                        var that = this;

                        return function() {

                            var factory = !_.isUndefined(factoryName) ? that.getFactory(factoryName) : that.getDefaultFactory();

                            var params = _.isFunction(object) ? object.call(that) : object;

                            return _.isFunction(factory) ? factory(params) : factory.create(params);
                        }
                    }
1259706
public static Object buildNewObjectInstance(ClassDescriptor cld)
    {
        Object result = null;

        // If either the factory class and/or factory method is null,
        // just follow the normal code path and create via constructor
        if ((cld.getFactoryClass() == null) || (cld.getFactoryMethod() == null))
        {
            try
            {
                // 1. create an empty Object (persistent classes need a public default constructor)
                Constructor con = cld.getZeroArgumentConstructor();
                if(con == null)
                {
                    throw new ClassNotPersistenceCapableException(
                    "A zero argument constructor was not provided! Class was '" + cld.getClassNameOfObject() + "'");
                }
                result = ConstructorHelper.instantiate(con);
            }
            catch (InstantiationException e)
            {
                throw new ClassNotPersistenceCapableException(
                        "Can't instantiate class '" + cld.getClassNameOfObject()+"'");
            }
        }
        else
        {
            try
            {
                // 1. create an empty Object by calling the no-parms factory method
                Method method = cld.getFactoryMethod();

                if (Modifier.isStatic(method.getModifiers()))
                {
                    // method is static so call it directly
                    result = method.invoke(null, null);
                }
                else
                {
                    // method is not static, so create an object of the factory first
                    // note that this requires a public no-parameter (default) constructor
                    Object factoryInstance = cld.getFactoryClass().newInstance();

                    result = method.invoke(factoryInstance, null);
                }
            }
            catch (Exception ex)
            {
                throw new PersistenceBrokerException("Unable to build object instance of class '"
                        + cld.getClassNameOfObject() + "' from factory:" + cld.getFactoryClass()
                        + "." + cld.getFactoryMethod(), ex);
            }
        }
        return result;
    }
1118538
function(json){
  
  // Protect against forgetting the new keyword when calling the constructor
  if(!(this instanceof NamePart)){
    return new NamePart(json);
  }
  
  // If the given object is already an instance then just return it. DON'T copy it.
  if(NamePart.isInstance(json)){
    return json;
  }
  
  this.init(json);
}
477952
function (name) {
            var utility = utilities[name];

            if (utility) {
                if (!utility.instance) {
                    utility.instance = utility.creator(this);
                }

                return utility.instance;
            }

            return null;
        }
599590
function create(objectName) {

        // for resources we need to load them the first time they are referenced
        if (objectName === 'resources' && this.internalObjects[objectName] === true) {
            this.internalObjects[objectName] = this.loadResources();
        }

        // for reactors we need to load them the first time they are referenced
        else if (objectName === 'reactors' && this.internalObjects[objectName] === true) {
            this.internalObjects[objectName] = this.loadReactors();
        }

        // for reactors we need to load them the first time they are referenced
        else if (objectName === 'appConfigs' && this.internalObjects[objectName] === true) {
            this.internalObjects[objectName] = this.loadAppConfigs();
        }

        // for adapters we need to load them the first time they are referenced
        else if (objectName === 'adapters' && this.internalObjects[objectName] === true) {
            this.internalObjects[objectName] = this.loadAdapters();
        }

        return this.internalObjects[objectName];
    }
654453
function factory() {
        var utilx = {};

        $forEach(objectKeys($), function (key1) {
            if (!pHasOwn.call(utilx, 'methods')) {
                defineProperty(utilx, 'methods', assign({
                    value: []
                }, propNotEnumerable));
            }

            defineProperty(utilx, key1, assign({
                value: $[key1]
            }, propNotEnumerable));

            if (isPlainObject($[key1])) {
                if (!pHasOwn.call(utilx[key1], 'methods')) {
                    defineProperty(utilx[key1], 'methods', assign({
                        value: []
                    }, propNotEnumerable));
                }

                $forEach(objectKeys($[key1]), function (key2) {
                    defineProperty(utilx[key1], key2, assign({
                        value: $[key1][key2]
                    }, propNotEnumerable));

                    if (isPlainObject($[key1][key2])) {
                        if (!pHasOwn.call(utilx[key1][key2], 'methods')) {
                            defineProperty(utilx[key1][key2], 'methods', assign({
                                value: []
                            }, propNotEnumerable));
                        }

                        $forEach(objectKeys($[key1][key2]), function (key3) {
                            defineProperty(utilx[key1][key2], key3, assign({
                                value: $[key1][key2][key3]
                            }, propNotEnumerable));

                            $push(utilx[key1][key2].methods, key3);
                        });
                    } else {
                        $push(utilx[key1].methods, key2);
                    }
                });
            } else {
                $push(utilx.methods, key1);
            }
        });

        defineProperties(utilx.Number, {
            POSITIVE_ZERO: propConstant,

            NEGATIVE_ZERO: propConstant,

            UNSAFE_INTEGER: propConstant,

            WORD8: propConstant,

            UWORD8: propConstant,

            WORD16: propConstant,

            UWORD16: propConstant,

            WORD32: propConstant,

            UWORD32: propConstant,

            MAX_UINT32: propConstant,

            MAX_INT32: propConstant,

            MIN_INT32: propConstant,

            MAX_UINT16: propConstant,

            MAX_INT16: propConstant,

            MIN_INT16: propConstant,

            MAX_UINT8: propConstant,

            MAX_INT8: propConstant,

            MIN_INT8: propConstant,

            MAX_SAFE_INTEGER: propConstant,

            MIN_SAFE_INTEGER: propConstant,

            MAX_VALUE: propConstant,

            MIN_VALUE: propConstant,

            EPSILON: propConstant,

            NaN: propConstant,

            POSITIVE_INFINITY: propConstant,

            NEGATIVE_INFINITY: propConstant
        });

        return utilx;
    }
497977
function(json){
  
  // Protect against forgetting the new keyword when calling the constructor
  if(!(this instanceof SourceReference)){
    return new SourceReference(json);
  }
  
  // If the given object is already an instance then just return it. DON'T copy it.
  if(SourceReference.isInstance(json)){
    return json;
  }
  
  this.init(json);
}
18338
public static Function.Factory factory(final Function fun)
    {
        return new Function.Factory()
        {
            public Function create(String ksName, String cfName)
            {
                return fun;
            }
        };
    }
237668
protected function createFactory()
    {
        $factory = Str::studly(class_basename($this->argument('name')));

        $this->call('make:factory', [
            'name' => "{$factory}Factory",
            '--model' => $this->argument('name'),
        ]);
    }
349763
function construct(constructor) {
            // Create constructor
            var c = function () {
                return constructor.apply(this);
            };
            // Assign prototype
            c.prototype = constructor.prototype;
            // Create new instance
            return service_factory_1.ServiceFactory.export(c, name, context);
        }
1361745
function SchemaObjectInstanceFactory(schema, options) {
        // Represents an actual instance of an object.
        class SchemaObjectInstance {
            // Extend instance factory.
            static extend(extendSchema, extendOptions = {}) {
                // Extend requires reflection.
                if (_isProxySupported === false) {
                    throw new Error('[schema-object] Extending object requires --harmony flag.');
                }

                // Merge schema and options together.
                const mergedSchema = _.merge({}, schema, extendSchema);
                const mergedOptions = _.merge({}, options, extendOptions);

                // Allow method and constructor to call `this.super()`.
                const methodHomes = ['methods', 'constructors'];
                for (const methodHome of methodHomes) {
                    // Ensure object containing methods exists on both provided and original options.
                    if (_.size(options[methodHome]) && _.size(extendOptions[methodHome])) {
                        // Loop through each method in the original options.
                        // It's not necessary to bind `this.super()` for options that didn't already exist.
                        _.each(options[methodHome], (method, name) => {
                            // The original option may exist, but was it extended?
                            if (extendOptions[methodHome][name]) {
                                // Extend method by creating a binding that takes the `this` context given and adds `self`.
                                // `self` is a reference to the original method, also bound to the correct `this`.
                                mergedOptions[methodHome][name] = function () {
                                    this[_privateKey]._reservedFields.super = () => {
                                        return method.apply(this, arguments);
                                    };
                                    const ret = extendOptions[methodHome][name].apply(this, arguments);
                                    delete this[_privateKey]._reservedFields.super;
                                    return ret;
                                };
                            }
                        });
                    }
                }

                return new SchemaObject(mergedSchema, mergedOptions);
            }

            // Construct new instance pre-populated with values.
            constructor(values, _root) {
                // Object used to store internals.
                const _private = this[_privateKey] = {};

                //
                _private._root = options.inheritRootThis ? _root || this : this;

                // Object with getters and setters bound.
                _private._getset = this;

                // Public version of ourselves.
                // Overwritten with proxy if available.
                _private._this = this;

                // Object used to store raw values.
                const obj = _private._obj = {};

                // Schema as defined by constructor.
                _private._schema = schema;

                // Errors, retrieved with getErrors().
                _private._errors = [];

                // Options need to be accessible. Shared across ALL INSTANCES.
                _private._options = options;

                // Reserved keys for storing internal properties accessible from outside.
                _private._reservedFields = {};

                // Normalize schema properties to allow for shorthand declarations.
                _.each(schema, (properties, index) => {
                    schema[index] = normalizeProperties.call(this, properties, index);
                });

                // Define getters/typecasts based off of schema.
                _.each(schema, (properties, index) => {
                    // Use getter / typecast to intercept and re-route, transform, etc.
                    defineGetter.call(_private._getset, index, properties);
                    defineSetter.call(_private._getset, index, properties);
                });

                // Proxy used as interface to object allows to intercept all access.
                // Without Proxy we must register individual getter/typecasts to put any logic in place.
                // With Proxy, we still use the individual getter/typecasts, but also catch values that aren't in the schema.
                if (_isProxySupported === true) {
                    const proxy = this[_privateKey]._this = new Proxy(this, {
                        // Ensure only public keys are shown.
                        ownKeys: (target) => {
                            return Object.keys(this.toObject());
                        },

                        // Return keys to iterate.
                        enumerate: (target) => {
                            return Object.keys(this[_privateKey]._this)[Symbol.iterator]();
                        },

                        // Check to see if key exists.
                        has: (target, key) => {
                            return !!_private._getset[key];
                        },

                        // Ensure correct prototype is returned.
                        getPrototypeOf: () => {
                            return _private._getset;
                        },

                        // Ensure readOnly fields are not writeable.
                        getOwnPropertyDescriptor: (target, key) => {
                            return {
                                value: proxy[key],
                                writeable: !schema[key] || schema[key].readOnly !== true,
                                enumerable: true,
                                configurable: true
                            };
                        },

                        // Intercept all get calls.
                        get: (target, name, receiver) => {
                            // First check to see if it's a reserved field.
                            if (_reservedFields.includes(name)) {
                                return this[_privateKey]._reservedFields[name];
                            }

                            // Support dot notation via lodash.
                            if (options.dotNotation && typeof name === 'string' && name.indexOf('.') !== -1) {
                                return _.get(this[_privateKey]._this, name);
                            }

                            // Use registered getter without hitting the proxy to avoid creating an infinite loop.
                            return this[name];
                        },

                        // Intercept all set calls.
                        set: (target, name, value, receiver) => {
                            // Support dot notation via lodash.
                            if (options.dotNotation && typeof name === 'string' && name.indexOf('.') !== -1) {
                                return _.set(this[_privateKey]._this, name, value);
                            }

                            // Find real keyname if case sensitivity is off.
                            if (options.keysIgnoreCase && !schema[name]) {
                                name = getIndex.call(this, name);
                            }

                            if (!schema[name]) {
                                if (options.strict) {
                                    // Strict mode means we don't want to deal with anything not in the schema.
                                    // TODO: SetterError here.
                                    return true;
                                } else {
                                    // Add index to schema dynamically when value is set.
                                    // This is necessary for toObject to see the field.
                                    addToSchema.call(this, name, {
                                        type: 'any'
                                    });
                                }
                            }

                            // This hits the registered setter but bypasses the proxy to avoid an infinite loop.
                            this[name] = value;

                            // Necessary for Node v6.0. Prevents error: 'set' on proxy: trap returned falsish for property 'string'".
                            return true;
                        },

                        // Intercept all delete calls.
                        deleteProperty: (target, property) => {
                            this[property] = undefined;
                            return true;
                        }
                    });
                }

                // Populate schema defaults into object.
                _.each(schema, (properties, index) => {
                    if (properties.default !== undefined) {
                        // Temporarily ensure readOnly is turned off to prevent the set from failing.
                        const readOnly = properties.readOnly;
                        properties.readOnly = false;
                        this[index] = _.isFunction(properties.default) ? properties.default.call(this) : properties.default;
                        properties.readOnly = readOnly;
                    }
                });

                // Call default constructor.
                _private._options.constructors.default.call(this, values);

                // May return actual object instance or Proxy, depending on harmony support.
                return _private._this;
            }

            // Populate values.
            populate(values) {
                for (const key in values) {
                    this[_privateKey]._this[key] = values[key];
                }
            }

            // Clone and return SchemaObject.
            clone() {
                return new SchemaObjectInstance(this.toObject(), this[_privateKey]._root);
            }

            // Return object without getter/typecasts, extra properties, etc.
            toObject() {
                const options = this[_privateKey]._options;
                let getObj = {};

                // Populate all properties in schema.
                _.each(this[_privateKey]._schema, (properties, index) => {
                    // Do not write values to object that are marked as invisible.
                    if (properties.invisible) {
                        return;
                    }

                    // Fetch value through the public interface.
                    let value = this[_privateKey]._this[index];

                    // Do not write undefined values to the object because of strange behavior when using with MongoDB.
                    // MongoDB will convert undefined to null and overwrite existing values in that field.
                    if (value === undefined && options.setUndefined !== true) {
                        return;
                    }

                    // Clone objects so they can't be modified by reference.
                    if (_.isObject(value)) {
                        if (value._isSchemaObject) {
                            value = value.toObject();
                        } else if (value._isSchemaArray) {
                            value = value.toArray();
                        } else if (_.isArray(value)) {
                            value = value.splice(0);
                        } else if (_.isDate(value)) {
                            // https://github.com/documentcloud/underscore/pull/863
                            // _.clone doesn't work on Date object.
                            getObj[index] = new Date(value.getTime());
                        } else {
                            value = _.clone(value);
                        }

                        // Don't write empty objects or arrays.
                        if (!_.isDate(value) && !options.setUndefined && !_.size(value)) {
                            return;
                        }
                    }

                    // Write to object.
                    getObj[index] = value;
                });

                // If options contains toObject, pass through before returning final object.
                if (_.isFunction(options.toObject)) {
                    getObj = options.toObject.call(this, getObj);
                }

                return getObj;
            }

            // toJSON is an interface used by JSON.stringify.
            // Return the raw object if called.
            toJSON() {
                return this.toObject();
            }

            // Clear all values.
            clear() {
                _.each(this[_privateKey]._schema, (properties, index) => {
                    clearField.call(this[_privateKey]._this, index, properties);
                });
            }

            // Get all errors.
            getErrors() {
                const errors = [];
                for (let error of this[_privateKey]._errors) {
                    error = _.cloneDeep(error);
                    error.schemaObject = this;
                    errors.push(error);
                }

                _.each(this[_privateKey]._schema, (properties, index) => {
                    let required = properties.required;
                    let message = `${index} is required but not provided`;

                    //If required is an array, set custom message
                    if (Array.isArray(required)) {
                      message = required[1] || message;
                      required = required[0];
                    }
                    //Skip if required does not exist
                    if (!required) {
                        return;
                    }
                    //Skip if required is a function, but returns false
                    else if (typeof required === 'function' && !required.call(this)) {
                        return;
                    }

                    //Skip if property has a value, is a boolean set to false, or if it's falsy and falsy values are allowed
                    if (
                      this[index] ||
                      typeof this[index] === 'boolean' ||
                      this[_privateKey]._options.allowFalsyValues && this[index] !== undefined
                    ) {
                      return;
                    }

                    const error = new SetterError(message, this[index], this[index], properties);
                    error.schemaObject = this;
                    errors.push(error);
                });

                // Look for sub-SchemaObjects.
                for (const name in this[_privateKey]._schema) {
                    const field = this[_privateKey]._schema[name];
                    if (field.type === 'object' && typeof field.objectType === 'function') {
                        const subErrors = this[name].getErrors();
                        for (const subError of subErrors) {
                            subError.fieldSchema.name = `${name}.${subError.fieldSchema.name}`;
                            subError.schemaObject = this;
                            errors.push(subError);
                        }
                    }
                }

                return errors;
            }

            // Clear all errors
            clearErrors() {
                this[_privateKey]._errors.length = 0;

                // Look for sub-SchemaObjects.
                for (const name in this[_privateKey]._schema) {
                    const field = this[_privateKey]._schema[name];
                    if (field.type === 'object' && typeof field.objectType === 'function') {
                        this[name].clearErrors();
                    }
                }
            }

            // Has errors?
            isErrors() {
                return this.getErrors().length > 0;
            }

            // Used to detect instance of schema object internally.
            _isSchemaObject() {
                return true;
            }
        }

        // Add custom methods to factory-generated class.
        _.each(options.methods, (method, key) => {
            if (SchemaObjectInstance.prototype[key]) {
                throw new Error(`Cannot overwrite existing ${key} method with custom method.`);
            }
            SchemaObjectInstance.prototype[key] = method;
        });

        return SchemaObjectInstance;
    }
910538
function(name) {
			var args = [].slice.call(arguments, 1);
			var factory = this.get(name);
			return factory ? factory.apply(this, args) : null;
		}
1365442
function Builder(baseURL, cfg) {
  if (typeof baseURL == 'object') {
    cfg = baseURL;
    baseURL = null;
  }

  this.loader = null;
  this.resetConfig = function() {};

  this.reset();

  if (baseURL)
    this.config({ baseURL: baseURL });

  // config passed to constructor will
  // be saved for future .reset() calls
  if (typeof cfg == 'object')
    this.config(cfg, true, !!baseURL);
  else if (typeof cfg == 'string')
    this.loadConfigSync(cfg, true, !!baseURL);
}
1060898
function createPlatformFactory(parentPlatformFactory, name, providers) {
    if (providers === void 0) { providers = []; }
    var /** @type {?} */ marker = new InjectionToken("Platform: " + name);
    return function (extraProviders) {
        if (extraProviders === void 0) { extraProviders = []; }
        var /** @type {?} */ platform = getPlatform();
        if (!platform || platform.injector.get(ALLOW_MULTIPLE_PLATFORMS, false)) {
            if (parentPlatformFactory) {
                parentPlatformFactory(providers.concat(extraProviders).concat({ provide: marker, useValue: true }));
            }
            else {
                createPlatform(ReflectiveInjector.resolveAndCreate(providers.concat(extraProviders).concat({ provide: marker, useValue: true })));
            }
        }
        return assertPlatform(marker);
    };
}
931978
function createPlatformFactory(parentPlatformFactory, name, providers) {
    if (providers === void 0) { providers = []; }
    var desc = "Platform: " + name;
    var marker = new InjectionToken(desc);
    return function (extraProviders) {
        if (extraProviders === void 0) { extraProviders = []; }
        var platform = getPlatform();
        if (!platform || platform.injector.get(ALLOW_MULTIPLE_PLATFORMS, false)) {
            if (parentPlatformFactory) {
                parentPlatformFactory(providers.concat(extraProviders).concat({ provide: marker, useValue: true }));
            }
            else {
                var injectedProviders = providers.concat(extraProviders).concat({ provide: marker, useValue: true });
                createPlatform(Injector.create({ providers: injectedProviders, name: desc }));
            }
        }
        return assertPlatform(marker);
    };
}
1298923
function createProviderInjector(cache) {
	const injector = createInjector(cache, function(name) {
		throw new Error(`Unknown provider: ${name}`);
	});

	injector.cache = cache;

	cache.$injector = injector;

	return injector;
}
955645
function factory(BaseClass, mapFunction) {
  function subject(value) {
    if (typeof mapFunction === 'function') {
      value = mapFunction.apply(undefined, arguments);
    } else if (typeof mapFunction !== 'undefined') {
      value = mapFunction;
    }
    subject.onNext(value);
    return value;
  }
  
  for (var key in BaseClass.prototype) {
    subject[key] = BaseClass.prototype[key];
  }

  BaseClass.apply(subject, [].slice.call(arguments, 2));

  return subject;
}