If "old" or "current" doesn't exist, make sure we compare the other one to a reasonable value. This is currently only an issue for areas, arrays and objects. TODO: should probably be something we ask schemas to generate for us so it's extensible. -Tom
519477
function synth(type, existing) {
          var value;
          if (existing && (existing.type === 'area')) {
            value = { type: 'area', items: [] };
          } else if (Array.isArray(existing)) {
            value = [];
          } else if (typeof (existing) === 'object') {
            value = {};
          }
          return value;
        }
263894
function validateRequiredPropertiesExist (schema, schemaId) {
  /**
   * Recursively collects all properties of the schema and its ancestors. They are added to the props object.
   */
  function collectProperties (schemaObj, props) {
    if (schemaObj.properties) {
      for (var property in schemaObj.properties) {
        if (schemaObj.properties.hasOwnProperty(property)) {
          props[property] = schemaObj.properties[property];
        }
      }
    }
    if (schemaObj.allOf) {
      schemaObj.allOf.forEach(function (parent) {
        collectProperties(parent, props);
      });
    }
  }

  if (schema.required && Array.isArray(schema.required)) {
    var props = {};
    collectProperties(schema, props);
    schema.required.forEach(function (requiredProperty) {
      if (!props[requiredProperty]) {
        throw ono.syntax("Validation failed. Property '%s' listed as required but does not exist in '%s'",
          requiredProperty, schemaId);
      }
    });
  }
}
205003
function objectExtendDeep(extended) {
  var currentObject;
  var currentType;
  var extendedType;
  var currentItem;
  var currentTypeInner;

  for (var i = 1, c = arguments.length; i < c; i++) {
    currentObject = arguments[i];
    if (!currentObject)
      continue;
    currentType = type(currentObject);
    extendedType = type(extended);
    // type mismatch
    if (currentType !== extendedType) {
      if (currentType === 'array') {
        extended = [];
      } else if (currentType === 'object' && extendedType !== 'function') {
        extended = {};
      }
      // else copy, primitive, date, regexp, function ...
    }
    // extend arrays
    if (currentType === 'array') {
      extended = extended.concat(currentObject);
    } else {
      // or objects ;)
      for (var key in currentObject) {
        if (ownProperty.call(currentObject, key)) {
          currentTypeInner = type(currentObject[key]);
          currentItem = currentObject[key];
          if (/^(object|array)$/.test(currentTypeInner)) {
            extended[key] = objectExtendDeep(extended[key], currentItem);
          } else if (currentTypeInner === 'date') {
            extended[key] = new Date(currentItem.getTime());
          } else if (currentTypeInner === 'regexp') {
            extended[key] = cloneRegExp(currentItem);
          } else {
            extended[key] = currentItem;
          }
        }
      }
    }
  }
  return extended;
}
976078
def old_values(self):
        ''''''
        def get_old_values_and_key(item):
            values = item.old_values
            values.update({self._key: item.past_dict[self._key]})
            return values

        return [get_old_values_and_key(el)
                for el in self._get_recursive_difference('all')
                if el.diffs and el.past_dict]
1207815
function(recentEntryArray, value) {
			var indexOfElement = -1;
			
			recentEntryArray.some(function(entry, index){
				if (entry.value === value) {
					indexOfElement = index;
					return true;
				}
				return false;
			});
			
			return indexOfElement;
		}
63688
private void diffRecursively(CatalogType prevType, CatalogType newType)
    {
        assert(prevType != null) : "Null previous object found in catalog diff traversal.";
        assert(newType != null) : "Null new object found in catalog diff traversal";

        Object materializerValue = null;
        // Consider shifting into the strict more required within materialized view definitions.
        if (prevType instanceof Table) {
            // Under normal circumstances, it's highly unlikely that another (nested?) table will
            // appear in the details of a materialized view table. So, when it does (!?), be sure to
            // complain -- and don't let it throw off the accounting of the strict diff mode.
            // That is, don't set the local "materializerValue".
            if (m_inStrictMatViewDiffMode) {
                // Maybe this should log or append to m_errors?
                System.out.println("ERROR: unexpected nesting of a Table in CatalogDiffEngine.");
            } else {
                materializerValue = prevType.getField("materializer");
                if (materializerValue != null) {
                    // This table is a materialized view, so the changes to it and its children are
                    // strictly limited, e.g. no adding/dropping columns.
                    // In a future development, such changes may be allowed, but they may be implemented
                    // differently (get different catalog commands), such as through a wholesale drop/add
                    // of the entire view and materialized table definitions.
                    // The non-null local "materializerValue" is a reminder to pop out of this mode
                    // before returning from this level of the recursion.
                    m_inStrictMatViewDiffMode = true;
                    if (m_triggeredVerbosity) {
                        System.out.println("DEBUG VERBOSE diffRecursively entering strict mat view mode");
                    }
                }
            }
        }

        // diff local fields
        for (String field : prevType.getFields()) {
            // this field is (or was) set at runtime, so ignore it for diff purposes
            if (field.equals("isUp"))
            {
                continue;
            }

            boolean verbosityTriggeredHere = false;
            if (( ! m_triggeredVerbosity) && field.equals(m_triggerForVerbosity)) {
                System.out.println("DEBUG VERBOSE diffRecursively verbosity (triggered by field '" + field + "' is ON");
                verbosityTriggeredHere = true;
                m_triggeredVerbosity = true;
            }
            // check if the types are different
            // options are: both null => same
            //              one null and one not => different
            //              both not null => check Object.equals()
            Object prevValue = prevType.getField(field);
            Object newValue = newType.getField(field);
            if ((prevValue == null) != (newValue == null)) {
                if (m_triggeredVerbosity) {
                    if (prevValue == null) {
                        System.out.println("DEBUG VERBOSE diffRecursively found new '" + field + "' only.");
                    } else {
                        System.out.println("DEBUG VERBOSE diffRecursively found prev '" + field + "' only.");
                    }
                }
                writeModification(newType, prevType, field);
            }
            // if they're both not null (above/below ifs implies this)
            else if (prevValue != null) {
                // if comparing CatalogTypes (both must be same)
                if (prevValue instanceof CatalogType) {
                    assert(newValue instanceof CatalogType);
                    String prevPath = ((CatalogType) prevValue).getCatalogPath();
                    String newPath = ((CatalogType) newValue).getCatalogPath();
                    if (prevPath.compareTo(newPath) != 0) {
                        if (m_triggeredVerbosity) {
                            int padWidth = StringUtils.indexOfDifference(prevPath, newPath);
                            String pad = StringUtils.repeat(" ", padWidth);
                            System.out.println("DEBUG VERBOSE diffRecursively found a path change to '" + field + "':");
                            System.out.println("DEBUG VERBOSE prevPath=" + prevPath);
                            System.out.println("DEBUG VERBOSE diff at->" + pad + "^ position:" + padWidth);
                            System.out.println("DEBUG VERBOSE  newPath=" + newPath);
                        }
                        writeModification(newType, prevType, field);
                    }
                }
                // if scalar types
                else {
                    if (prevValue.equals(newValue) == false) {
                        if (m_triggeredVerbosity) {
                            System.out.println("DEBUG VERBOSE diffRecursively found a scalar change to '" + field + "':");
                            System.out.println("DEBUG VERBOSE diffRecursively prev: " + prevValue);
                            System.out.println("DEBUG VERBOSE diffRecursively new : " + newValue);
                            if (field.equals("plannodetree")) {
                                try {
                                    System.out.println("DEBUG VERBOSE where prev plannodetree expands to: " +
                                            new String(CompressionService.decodeBase64AndDecompressToBytes((String)prevValue), "UTF-8"));
                                }
                                catch (Exception e) {
                                    try {
                                        System.out.println("DEBUG VERBOSE where prev plannodetree expands to: " +
                                                new String(Encoder.decodeBase64AndDecompressToBytes((String)prevValue), "UTF-8"));
                                    }
                                    catch (UnsupportedEncodingException e2) {}
                                }
                                try {
                                    System.out.println("DEBUG VERBOSE where new plannodetree expands to: " +
                                            new String(CompressionService.decodeBase64AndDecompressToBytes((String)newValue), "UTF-8"));
                                }
                                catch (Exception e) {
                                    try {
                                        System.out.println("DEBUG VERBOSE where new plannodetree expands to: " +
                                                new String(Encoder.decodeBase64AndDecompressToBytes((String)newValue), "UTF-8"));
                                    }
                                    catch (UnsupportedEncodingException e2) {}
                                }
                            }
                        }
                        writeModification(newType, prevType, field);
                    }
                }
            }
            if (verbosityTriggeredHere) {
                System.out.println("DEBUG VERBOSE diffRecursively verbosity is OFF");
                m_triggeredVerbosity = false;
            }
        }

        // recurse
        for (String field : prevType.getChildCollections()) {
            boolean verbosityTriggeredHere = false;
            if (field.equals(m_triggerForVerbosity)) {
                System.out.println("DEBUG VERBOSE diffRecursively verbosity ON");
                m_triggeredVerbosity = true;
                verbosityTriggeredHere = true;
            }
            CatalogMap<? extends CatalogType> prevMap = prevType.getCollection(field);
            CatalogMap<? extends CatalogType> newMap = newType.getCollection(field);
            getCommandsToDiff(field, prevMap, newMap);
            if (verbosityTriggeredHere) {
                System.out.println("DEBUG VERBOSE diffRecursively verbosity OFF");
                m_triggeredVerbosity = false;
            }
        }

        if (materializerValue != null) {
            // Just getting back from recursing into a materialized view table,
            // so drop the strictness required only in that context.
            // It's safe to assume that the prior mode to which this must pop back is the non-strict
            // mode because nesting of table definitions is unpossible AND we guarded against its
            // potential side effects, above, anyway.
            m_inStrictMatViewDiffMode = false;
        }

    }
405995
function (values, schema, options) {
    var virtualList = find(schema, 'virtual');

    //Set default value for virtual if not exists in values
    if (options && options.query === true) {
    }
    else {
        for (var virtual in virtualList) {

            if (_.isArray(virtualList[virtual])) {

                for (var thisVirtual in virtualList[virtual]) {

                    if (_.isArray(values[virtual])) {
                        for (var thisValue in values[virtual]) {
                            setVirtuals(values[virtual][thisValue], virtualList[virtual][thisVirtual], options);
                        }
                    }
                }
            }
            else {
                if (values[virtual] === undefined && virtualList[virtual] && virtualList[virtual].hasOwnProperty('default') && options && options.partial !== true) {
                    values[virtual] = (virtualList[virtual]).default;
                }
            }
        }
    }

    for (var value in values) {

        if (virtualList[value] && virtualList[value].virtual) {

            var setFunction = virtualList[value].virtual;

            //Check for setter and getter
            if (virtualList[value].virtual.set) {
                setFunction = virtualList[value].virtual.set;
            }

            //Check conditions and apply virtual
            rulesMatch(value, values[value], setFunction, null, function (err, data) {
                if (!err) {
                    if (_.isFunction(setFunction)) {
                        var virtualResult = setFunction(values[value]);
                        if (_.isObject(virtualResult) && !_.isEmpty(virtualResult)) {
                            //Check if virtual values does not exists in given values list. Do not overwrite given
                            for (var vValue in virtualResult) {
                                {
                                    if (vValue == 'this') {
                                        virtualResult[value] = virtualResult[vValue];
                                        delete(virtualResult[vValue]);
                                    }
                                    else {
                                        // Prevent overwrite of given values
                                        if (values[vValue] !== undefined) {
                                            delete(virtualResult[vValue]);
                                        }
                                    }
                                }
                            }
                            values = _.assign(values, virtualResult);
                        }
                    }
                }
            });
        }
    }
    return values;
}
443646
function checkProp(value, schema, path,i){

         var l;
         path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i;
         function addError(message){
           errors.push({property:path,message:message});
         }

         if((typeof schema != 'object' || schema instanceof Array) &&
             (path || typeof schema != 'function') && !(schema && getType(schema))){
             if(typeof schema == 'function'){
                 if(!(value instanceof schema)){
                     addError("is not an instance of the class/constructor " + schema.name);
                 }
             }else if(schema){
                 addError("Invalid schema/property definition " + schema);
             }
             return null;
         }
         if(_changing && schema.readonly){
             addError("is a readonly field, it can not be changed");
         }
         if(schema['extends']){ // if it extends another schema, it must pass that schema as well
             checkProp(value,schema['extends'],path,i);
         }
         // validate a value against a type definition
         function checkType(type,value){
             if(type){
                 if(typeof type == 'string' && type != 'any' &&
                         (type == 'null' ? value !== null : typeof value != type) &&
                         !(value instanceof Array && type == 'array') &&
                         !(value instanceof Date && type == 'date') &&
                         !(type == 'integer' && value%1===0)){
                     return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}];
                 }
                 if(type instanceof Array){
                     var unionErrors=[];
                     for(var j = 0; j < type.length; j++){ // a union type
                         if(!(unionErrors=checkType(type[j],value)).length){
                             break;
                         }
                     }
                     if(unionErrors.length){
                         return unionErrors;
                     }
                 }else if(typeof type == 'object'){
                     var priorErrors = errors;
                     errors = [];
                     checkProp(value,type,path);
                     var theseErrors = errors;
                     errors = priorErrors;
                     return theseErrors;
                 }
             }
             return [];
         }
         if(value === undefined){
             if(schema.required){
                 addError("is missing and it is required");
             }
         } else{
             errors = errors.concat(checkType(getType(schema),value));
             if(schema.disallow && !checkType(schema.disallow,value).length){
                 addError(" disallowed value was matched");
             }
             if(value !== null){
                 if(value instanceof Array){
                     if(schema.items){
                         var itemsIsArray = schema.items instanceof Array;
                         var propDef = schema.items;
                         for (i = 0, l = value.length; i < l; i += 1) {
                             if (itemsIsArray)
                                 propDef = schema.items[i];
                             if (options.coerce)
                                 value[i] = options.coerce(value[i], propDef);
                             errors.concat(checkProp(value[i],propDef,path,i));
                         }
                     }
                     if(schema.minItems && value.length < schema.minItems){
                         addError("There must be a minimum of " + schema.minItems + " in the array");
                     }
                     if(schema.maxItems && value.length > schema.maxItems){
                         addError("There must be a maximum of " + schema.maxItems + " in the array");
                     }
                 }else if(schema.properties || schema.additionalProperties){
                     errors.concat(checkObj(value, schema.properties, path, schema.additionalProperties));
                 }
                 if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){
                     addError("does not match the regex pattern " + schema.pattern);
                 }
                 if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){
                     addError("may only be " + schema.maxLength + " characters long");
                 }
                 if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){
                     addError("must be at least " + schema.minLength + " characters long");
                 }
                 if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum &&
                         schema.minimum > value){
                     addError("must have a minimum value of " + schema.minimum);
                 }
                 if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum &&
                         schema.maximum < value){
                     addError("must have a maximum value of " + schema.maximum);
                 }
                 if(schema['enum']){
                     var enumer = schema['enum'];
                     l = enumer.length;
                     var found;
                     for(var j = 0; j < l; j++){
                         if(enumer[j]===value){
                             found=1;
                             break;
                         }
                     }
                     if(!found){
                         addError("does not have a value in the enumeration " + enumer.join(", "));
                     }
                 }
                 if(typeof schema.maxDecimal == 'number' &&
                     (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){
                     addError("may only have " + schema.maxDecimal + " digits of decimal places");
                 }
             }
         }
         return null;
      }
107742
function (collection, settings, elements, element, oldIndex, newIndex) {
            if (1 === Math.abs(newIndex - oldIndex)) {
                elements = swapElements(collection, elements, oldIndex, newIndex);
                if (!(newIndex - oldIndex > 0 ? trueOrUndefined(settings.after_up(collection, element)) : trueOrUndefined(settings.after_down(collection, element)))) {
                    elements = swapElements(collection, elements, newIndex, oldIndex);
                }
            } else {
                if (oldIndex < newIndex) {
                    elements = swapElementsUp(collection, elements, settings, oldIndex, newIndex);
                    if (!(newIndex - oldIndex > 0 ? trueOrUndefined(settings.after_up(collection, element)) : trueOrUndefined(settings.after_down(collection, element)))) {
                        elements = swapElementsDown(collection, elements, settings, newIndex, oldIndex);
                    }
                } else {
                    elements = swapElementsDown(collection, elements, settings, oldIndex, newIndex);
                    if (!(newIndex - oldIndex > 0 ? trueOrUndefined(settings.after_up(collection, element)) : trueOrUndefined(settings.after_down(collection, element)))) {
                        elements = swapElementsUp(collection, elements, settings, newIndex, oldIndex);
                    }
                }
            }
            dumpCollectionActions(collection, settings, false);

            if (settings.position_field_selector) {
                return doRewritePositions(settings, elements);
            }

            return elements;
        }
844378
function schemaType(schema) {
    let type;
    if (schema.hasOwnProperty('type')) {
        type = schema.type;
    } else if (schema.hasOwnProperty('properties') || schema.hasOwnProperty('allOf') || schema.hasOwnProperty('additionalProperties')) {
        type = 'object';
    } else if (schema.hasOwnProperty('items')) {
        type = 'array';
    }

    switch (type) {
        case 'array':
        case 'boolean':
        case 'file':
        case 'integer':
        case 'number':
        case 'object':
        case 'string':
            return type;
    }
}
1313378
void compareRecordTypes(Schema oldSchema,
                                                 Schema newSchema,
                                                 List<Message> messages,
                                                 String name) {
        if(oldSchema == null || newSchema == null || oldSchema.getType() != Schema.Type.RECORD) {
            throw new IllegalArgumentException("Old schema must be RECORD type. Name=" + name
                                               + ". Type=" + oldSchema);
        }

        if(newSchema.getType() != Schema.Type.RECORD) {
            messages.add(new Message(Level.ERROR, "Illegal type change from " + oldSchema.getType()
                                                  + " to " + newSchema.getType() + " for field "
                                                  + name));
            return;
        }

        // Check all of the fields in the new schema
        for(Field newField: newSchema.getFields()) {
            String fieldName = newField.name();
            Field oldField = oldSchema.getField(fieldName);

            if(oldField == null) {
                // This is a new field that did not exist in the original
                // schema.
                // Check if it is optional or has a default value.
                if(isOptional(newField)) {
                    if(newField.defaultValue() == null) {
                        messages.add(new Message(Level.INFO, "Added optional field " + name + "."
                                                             + fieldName
                                                             + " with no default value."));
                    } else {
                        messages.add(new Message(Level.INFO, "Added optional field " + name + "."
                                                             + fieldName + " with default value: "
                                                             + newField.defaultValue()));
                    }
                } else {
                    if(newField.defaultValue() == null) {
                        messages.add(new Message(Level.ERROR, "Added required field " + name + "."
                                                              + fieldName
                                                              + " with no default value."));
                    } else {
                        messages.add(new Message(Level.INFO, "Added required field " + name + "."
                                                             + fieldName + " with default value: "
                                                             + newField.defaultValue()));
                    }
                }
            } else {
                // This is a field that existed in the original schema.

                // Check if the field was changed from optional to required or
                // vice versa.
                boolean newFieldIsOptional = isOptional(newField);
                boolean oldFieldIsOptional = isOptional(oldField);

                if(oldFieldIsOptional != newFieldIsOptional) {
                    if(oldFieldIsOptional) {
                        messages.add(new Message(Level.ERROR,
                                                 "Existing field " + name + "." + fieldName
                                                         + " was optional and is now required."));
                    } else {
                        messages.add(new Message(Level.WARN, "Existing field " + name + "."
                                                             + fieldName
                                                             + " was required and is now optional."));
                    }
                }

                // Recursively compare the nested field types
                compareTypes(oldField.schema(), newField.schema(), messages, name + "." + fieldName);

                // Check if the default value has been changed
                if(newField.defaultValue() == null) {
                    if(oldField.defaultValue() != null) {
                        messages.add(new Message(Level.WARN,
                                                 "Removed default value for existing field " + name
                                                         + "." + fieldName
                                                         + ". The old default was: "
                                                         + oldField.defaultValue()));
                    }
                } else // newField.defaultValue() != null
                {
                    if(oldField.defaultValue() == null) {
                        messages.add(new Message(Level.WARN,
                                                 "Added a default value for existing field " + name
                                                         + "." + fieldName
                                                         + ". The new default is: "
                                                         + newField.defaultValue()));
                    } else if(!newField.defaultValue().equals(oldField.defaultValue())) {
                        messages.add(new Message(Level.INFO,
                                                 "Changed the default value for existing field "
                                                         + name + "." + fieldName
                                                         + ". The old default was: "
                                                         + oldField.defaultValue()
                                                         + ". The new default is: "
                                                         + newField.defaultValue()));
                    }
                }
            }

            // For all fields in the new schema (whether or not it existed in
            // the old schema), if there is a default value for this field, make
            // sure it is legal.
            if(newField.defaultValue() != null) {
                checkDefaultValueIsLegal(newField, messages, name + "." + fieldName);
            }
        }

        // Check if any fields were removed.
        for(Field oldField: newSchema.getFields()) {
            String fieldName = oldField.name();
            Field newField = newSchema.getField(fieldName);

            if(newField == null) {
                if(isOptional(oldField)) {
                    messages.add(new Message(Level.INFO, "Removed optional field " + name + "."
                                                         + fieldName));
                } else {
                    messages.add(new Message(Level.WARN, "Removed required field " + name + "."
                                                         + fieldName));
                }
            }
        }

        // Check if indexing was modified or added to any old fields.
        for(Field oldField: oldSchema.getFields()) {
            if(newSchema.getField(oldField.name()) != null) {
                String oldIndexType = oldField.getProp("indexType");
                String newIndexType = newSchema.getField(oldField.name()).getProp("indexType");

                // Check if added indexing.
                if(oldIndexType == null && newIndexType != null) {
                    messages.add(new Message(Level.ERROR,
                                             "Cannot add indexing to "
                                                     + oldField.name()
                                                     + ". Adding indexing to fields created without indexing is not supported."));
                }

                // Check if changed indexing
                if(oldIndexType != null && !oldIndexType.equals(newIndexType)) {
                    messages.add(new Message(Level.ERROR,
                                             "Cannot change indexing from "
                                                     + oldIndexType
                                                     + " to "
                                                     + newIndexType
                                                     + " for "
                                                     + oldField.name()
                                                     + ". Changing indexing method is not supported."));
                }
            }
        }
    }
4756
function validateArrayTypeItemsExistence (api, response, schema, path) {
  if (schema.type === 'array' && _.isUndefined(schema.items)) {
    response.errors.push({
      code: 'OBJECT_MISSING_REQUIRED_PROPERTY',
      message: 'Missing required property: items',
      path: path
    });
  }
}
957299
function(root,new$,old,caret) {
	var k = new$.length;
	var i = k;
	var last = new$[k - 1];
	
	
	if (k == old.length && new$[0] === old[0]) {
		// running through to compare
		while (i--){
			if (new$[i] !== old[i]) { break; };
		};
	};
	
	if (i == -1) {
		return last && last._slot_ || last || caret;
	} else {
		return reconcileCollectionChanges(root,new$,old,caret);
	};
}
465281
void compareMapTypes(Schema oldSchema,
                                              Schema newSchema,
                                              List<Message> messages,
                                              String name) {
        if(oldSchema == null || newSchema == null || oldSchema.getType() != Schema.Type.MAP) {
            throw new IllegalArgumentException("Old schema must be MAP type. Name=" + name
                                               + ". Type=" + oldSchema);
        }

        if(newSchema.getType() != Schema.Type.MAP) {
            messages.add(new Message(Level.ERROR, "Illegal type change from " + oldSchema.getType()
                                                  + " to " + newSchema.getType() + " for field "
                                                  + name));
            return;
        }

        // Compare the array element types
        compareTypes(oldSchema.getValueType(),
                     newSchema.getValueType(),
                     messages,
                     name + ".<map element>");
    }
801217
function getValueToValidate (schema, value) {
  // Is the value empty?
  if (value === undefined || value === "" ||
    (schema.type === "object" && _.isObject(value) && _.isEmpty(value))) {

    // It's blank, so return the default/example value (if there is one)
    if (schema.default !== undefined) {
      value = schema.default;
    }
    else if (schema.example !== undefined) {
      value = schema.example;
    }
  }

  // Special case for Buffers
  if (value && value.type === "Buffer" && _.isArray(value.data)) {
    value = new Buffer(value.data);
  }

  // It's not empty, so return the existing value
  return value;
}
379953
def old_properties_names_to_new(self):  # pragma: no cover, never called
        
        for i in itertools.chain(iter(list(self.items.values())),
                                 iter(list(self.templates.values()))):
            i.old_properties_names_to_new()
420432
function checkSchemaHasReferences(schema) {
  if (schema.$ref) {
    return true;
  }

  return Object.values(schema).some((value) => {
    if (_.isArray(value)) {
      return value.some(checkSchemaHasReferences);
    } else if (_.isObject(value)) {
      return checkSchemaHasReferences(value);
    }

    return false;
  });
}