Takes schema language and optional backing and creates
a factory definition then merges that definition into the current
@param {*} definition
@param {*} source
@param {*} backing
@param {*} options
519258
function useLanguage(
  definition: SchemaDefinition,
  source: string,
  backing?: ?SchemaBacking | ?SchemaBackingConfig,
  prefix?: ?string
) {
  return useSchema(
    definition,
    buildSchema(source, backing),
    prefix
  );
}
1256111
function (model, options, callback) {
                var schema = model.schema,
                    subModels = [],
                    type,
                    subCollection,
                    subModel,
                    addSubModel = function (model) {
                        subModels.push(model);
                    };

                for (var reference in schema) {
                    if (schema.hasOwnProperty(reference)) {
                        type = schema[reference];
                        if (type.classof) {
                            // TODO: remove $nestedModels and use options to specify, which subModels should also be saved
                            // This depends on the changes of the model.
                            // If the submodels haven't changed, than there is no need to save sub models/collections.
                            if (type.classof(Model)) {
                                subModel = model.$[reference];
                                if (subModel && _.include(model.$nestedModels, reference)) {
                                    subModels.push(subModel);
                                }
                            } else if (type.classof(Collection)) {
                                subCollection = model.$[reference];
                                if (subCollection) {
                                    subCollection.each(addSubModel);
                                }
                            }
                        }

                    }
                }

                flow()
                    .parEach(subModels, function (model, cb) {
                        model.save(options, cb);
                    })
                    .exec(callback);
            }
1237386
function factory(name, schema = {}, options = {}) {
  class TangModel extends Model {
    constructor(data) {
      super(data, schema, options)
    }
  }

  TangModel.options = options
  TangModel.schema = schema

  Object.defineProperty(TangModel, 'name', { value: name })

  for (let name in schema.statics) {
    TangModel[name] = function() {
      return schema.statics[name].apply(TangModel, arguments)
    }
  }

  return TangModel
}
367080
function buildDependantsSourceTree(sourceFileName, sourcesObject) {
  const depsTree = buildDependencyTreeFromSources(Object.keys(sourcesObject), sourcesObject);

  return buildFlatSourcesObjectFromTreeObject(depsTree[sourceFileName]);
}
1052544
@Override
    protected void initInputSource(WstxInputSource newInput, boolean isExt, String entityId)
        throws XMLStreamException
    {
        if (mFlattenWriter != null) {
            // Anything to flush from previous buffer contents?
            mFlattenWriter.flush(mInputBuffer, mInputPtr);
            mFlattenWriter.disableOutput();
            try {
                /* Then let's let base class do the 'real' input source setup;
                 * this includes skipping of optional XML declaration that we
                 * do NOT want to output
                 */
                super.initInputSource(newInput, isExt, entityId);
            } finally {
                // This will effectively skip declaration
                mFlattenWriter.enableOutput(mInputPtr);
            }
        } else {
            super.initInputSource(newInput, isExt, entityId);
        }
    }
37830
function Mongo_schema(definition, options) {

        if (!options) {
            options = {};
        }
        if (!Type.assert(Type.OBJECT, options)) {
            throw new error.HttpError(500, {options: options}, 'Schema options must be object');
        } else if (!Type.assert(Type.OBJECT, definition)) {
            throw new error.HttpError(500, {definition: definition}, 'Schema definition must be object');
        }
        logger.info('Mongo.schema:', {
            definition: definition,
            options: options
        });
        return new mongoose.Schema(definition, options);
    }
466411
function factory(tree, options) {
  var settings = options || {}
  var dangerous = settings.allowDangerousHTML

  h.dangerous = dangerous
  h.definition = definitions(tree, settings)
  h.footnotes = []
  h.augment = augment
  h.handlers = xtend(handlers, settings.handlers || {})

  visit(tree, 'footnoteDefinition', visitor)

  return h

  // Finalise the created `right`, a hast node, from `left`, an mdast node.
  function augment(left, right) {
    var data
    var ctx

    // Handle `data.hName`, `data.hProperties, `hChildren`.
    if (left && 'data' in left) {
      data = left.data

      if (right.type === 'element' && data.hName) {
        right.tagName = data.hName
      }

      if (right.type === 'element' && data.hProperties) {
        right.properties = xtend(right.properties, data.hProperties)
      }

      if (right.children && data.hChildren) {
        right.children = data.hChildren
      }
    }

    ctx = left && left.position ? left : {position: left}

    if (!generated(ctx)) {
      right.position = {
        start: position.start(ctx),
        end: position.end(ctx)
      }
    }

    return right
  }

  // Create an element for a `node`.
  function h(node, tagName, props, children) {
    if (
      (children === undefined || children === null) &&
      typeof props === 'object' &&
      'length' in props
    ) {
      children = props
      props = {}
    }

    return augment(node, {
      type: 'element',
      tagName: tagName,
      properties: props || {},
      children: children || []
    })
  }

  function visitor(definition) {
    h.footnotes.push(definition)
  }
}
360587
function union(schema, defaults, options) {
  if (kindOf(schema) !== 'array') {
    if (process.env.NODE_ENV !== 'production') {
      throw new Error(
        `Union structs must be defined as an array, but you passed: ${schema}`
      )
    } else {
      throw new Error(`Invalid schema: ${schema}`)
    }
  }

  const kinds = schema.map(s => any(s, undefined, options))
  const name = 'union'
  const type = kinds.map(k => k.type).join(' | ')
  const validate = (value = resolveDefaults(defaults)) => {
    const errors = []

    for (const k of kinds) {
      const [e, r] = k.validate(value)

      if (!e) {
        return [undefined, r]
      }

      errors.push(e)
    }
    errors[0].type = type
    return errors
  }

  return new Kind(name, type, validate)
}
1348783
function (target, source) {
        'use strict';
        var keys = Object.keys(source),
            len = keys.length,
            i = 0,
            prop,
            isA, isB;
        while (i < len) {
            prop = keys[i];
            isA = isObj(target[prop]);
            isB = isObj(source[prop]);
            if (isA && isB) {
                deepMerge(target[prop], source[prop]);
            } else if (!isA && isB) {
                target[prop] = JSON.parse(JSON.stringify(source[prop]));
            } else {
                target[prop] = source[prop];
            }
            i += 1;
        }
    }
369453
function(source) {
    if (typeof source === 'object') {
      this.ast = source;
    }
    else if (typeof source === 'string') {
      // JSON source:
      if (isJSON(source)) {
        this.ast = JSON.parse(source);
      }
      // Sass source:
      else {
        this.ast = gonzales.parse(source, {syntax: 'scss'});
      }
    }
    else {
      throw 'Source could not be loaded.';
    }

    return this.resetMapping();
  }
27362
function toSourceNodeWhenNeeded(generated, node) {
        if (!sourceMap) {
            // with no source maps, generated is either an
            // array or a string.  if an array, flatten it.
            // if a string, just return it
            if (isArray(generated)) {
                return flattenToString(generated);
            } else {
                return generated;
            }
        }
        if (node == null) {
            if (generated instanceof SourceNode) {
                return generated;
            } else {
                node = {};
            }
        }
        if (node.loc == null) {
            return new SourceNode(null, null, sourceMap, generated, node.name || null);
        }
        return new SourceNode(node.loc.start.line, node.loc.start.column, (sourceMap === true ? node.loc.source || null : sourceMap), generated, node.name || null);
    }
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;

}
155492
function endCompiling(schema, root, baseId) {
  /* jshint validthis: true */
  var i = compIndex.call(this, schema, root, baseId);
  if (i >= 0) this._compilations.splice(i, 1);
}
956665
function init(options) {

    var fs = require('fs');
    var path = require('path');
    var rootdir = path.dirname(require.main);
    var options = options || {
        config: require(path.join(rootdir, 'config.json')),
        root: rootdir,
        callback: function (noop) {}
    };
    var def = {};
    function ModulePaths (moduledir) {
        this.moduledir = moduledir;
    }

    ModulePaths.prototype.then = function (accept, reject) {
      var moduledir = this.moduledir;
      fs.readdir(moduledir, function (err, files) {
        if (err) reject(err);
        files.forEach(function (file) {
            var name = path.basename(file, '.js');
            def[name] = path.join(moduledir, name);
        });
        accept();
      });
    };
    var pubpath = new ModulePaths(path.join(path.dirname(module.filename), '..', 'public', 'js'));
    var prvpath = new ModulePaths(path.join(path.dirname(module.filename), '..', 'private', 'js'));

    Promise.all([pubpath, prvpath])
        .then(function () {
            var requirejs = require('requirejs');
            requirejs.config({
                baseUrl: path.join(rootdir),
                paths: def
            });

            requirejs(['loader_factory'], function (LoaderFactory) {
                var fs = require('fs');
                var config = options.config;
                config.paths.push(path.dirname(pubpath.moduledir));
                var loader = 'loader_express';
                var db = 'db_mongo';
                if (config.loader) loader = config.loader;
                if (config.db) db = config.db;

                new LoaderFactory().create(loader, db, function (loader) {
                    loader.init(config, options.callback);
                });
            });
        })
    .catch(function (err) {
        console.error('err:', err);
    });
}
741834
def deeper_merge(source, options = {})
      default_opts = {:preserve_unmergeables => true}
      DeepMerge::deep_merge!(source, self, default_opts.merge(options))
    end
1037608
function merge(source, target) {
    if (target == null) {
        return clone(source);
    }
    if (source == null) {
        return clone(target);
    }
    if (typeof source !== 'object' || typeof target !== 'object') {
        return clone(target);
    }
    const merge = (source, target) => {
        Object.keys(target).forEach(key => {
            if (source[key] == null) {
                source[key] = target[key];
            } else if (typeof source[key] === 'object') {
                if (typeof target[key] === 'object') {
                    merge(source[key], target[key]);
                } else {
                    source[key] = target[key];
                }
            } else {
                source[key] = target[key];
            }
        });

        return source;
    };

    return merge(clone(source), clone(target));
}
756865
function exportResolverMap(backing: SchemaBacking) {
  backing.validate();
  return reduce(
    backing.types,
    (rmap, config, name) => {
      const fields = reduce(
        config.fields,
        (fmap, field, fieldName) => {
          if (_.isFunction(field.resolve)) {
            fmap[fieldName] = field.resolve;
          }
          return fmap;
        },
        {},
        true,
      );
      return _.keys(fields).length ? _.merge(rmap, { [name]: fields }) : rmap;
    },
    {},
    true,
  );
}