Custom instanceOf that also works on interfaces.

@param {Object}   instance The instance to be checked
@param {Function} target   The target

@return {Boolean} True if it is a valid instance of target, false otherwise
346184
function instanceOf(instance, target) {
        if (!isFunction(target)) {
            return false;
        }

        if (instance instanceof target) {
            return true;
        }

        if (instance && instance.$static && instance.$static[$class] && target && target[$interface]) {
            return instanceOfInterface(instance, target);
        }

        return false;
    }
1003527
function(target){
    target = target || {};
    var templateHelpers = Marionette.getOption(this, "templateHelpers");
    if (_.isFunction(templateHelpers)){
      templateHelpers = templateHelpers.call(this);
    }
    return _.extend(target, templateHelpers);
  }
1147465
function(input) {
		var needstesting = !this._matches.length;
		if (needstesting || this._matches.every(function(match) {
			return match.$instanceid !== input.$instanceid;
		})) {
			return this._maybeinput(input);
		}
		return false;
	}
20047
function makeInstanceOf(object) {
  var args = slice.call(arguments, 1);
  Object.defineProperties(object, getDescriptors([this.prototype]));
  this.apply(object, args);
  return object;
}
382598
function any(target, fn) {
  var keys = Object.keys(target);
  for(var i = 0, len = keys.length; i < len; i++) {
    var key = keys[i];
    var value = target[key];
    if(fn(value, key)) return true;
  }
  return false;
}
121576
function instance (data, prototype) {
    try {
      return instanceStrict(data, prototype) ||
        data.constructor.name === prototype.name ||
        Object.prototype.toString.call(data) === '[object ' + prototype.name + ']';
    } catch (error) {
      return false;
    }
  }
98949
function (/*util*/) {

      function compare(actual, expected) {
        return {
          pass: actual instanceof Error && ('' + actual).indexOf(expected) >= 0
        }
      }

      return {compare: compare}
    }
366763
function (target) {
  if (target) {
    var args = arguments
    if (target === true) {
      if (args.length > 1) {
        target = isArray(target[1]) ? [] : {}
        return extend(target, args, true)
      }
    } else {
      return objectAssignFns ? objectAssignFns.apply(Object, args) : extend(target, args)
    }
  }
  return target
}
1193660
function (obj, target) {
                    if (obj == null)
                        return false;
                    if (obj.length !== +obj.length)
                        obj = _.values(obj);

                    if (_.every(obj, function (item) {
                        return moment.isMoment(item);
                    })) {
                        return _.any(obj, function (item) {
                            return item.isSame(target);
                        });
                    } else {
                        return _.indexOf(obj, target) >= 0;
                    }
                }
1078165
function instanceIndex(context) {
  for (var i = 0; i < instances.length; i++) {
    var instance = instances[i];
    if (instance.conversionContext === context ||
        instance.executionContext === context) {
      return i;
    }
  }
  return -1;
}
649924
function (instance, instanceKey, type, json, jsonKey) {
    var jsonObject = (jsonKey !== undefined) ? (json[jsonKey] || []) : json;
    var jsonArraySize = jsonObject.length;
    var conversionFunctionsList = [];
    var arrayInstance = [];
    instance[instanceKey] = arrayInstance;
    if (jsonArraySize > 0) {
        for (var i = 0; i < jsonArraySize; i++) {
            if (jsonObject[i]) {
                var typeName = getTypeNameFromInstance(type);
                if (!isSimpleType(typeName)) {
                    var typeInstance = new type();
                    conversionFunctionsList.push({ functionName: Constants.OBJECT_TYPE, instance: typeInstance, json: jsonObject[i] });
                    arrayInstance.push(typeInstance);
                }
                else {
                    arrayInstance.push(conversionFunctions[Constants.FROM_ARRAY](jsonObject[i], typeName));
                }
            }
        }
    }
    return conversionFunctionsList;
}
903937
@Override
    public <Instance> boolean isInstance(Instance instance) {
        if (instance instanceof CompositeObject) {
            Object delegate = ((CompositeObject) instance).getDelegate();
            return isDatastoreType(delegate);
        }
        return false;
    }
568616
function extend(target,       // @arg Object - global
                constructors, // @arg ConstructorObject - { "Object": { keys: Object_keys, ... }, ... }
                override) {   // @arg Boolean = false
//{@dev
    if (!global["BENCHMARK"]) {
        $valid($type(constructors, "Object"),       extend, "constructors");
        $valid($type(override,     "Boolean|omit"), extend, "override");
    }
//}@dev

    override = override || false;

    for (var klass in constructors) { // Object, Array, String, Function, ...
        if ( !(klass in target) ) {
            target[klass] = constructors[klass];
        }
        _extend(target[klass], constructors[klass]);
    }

    function _extend(extendTarget, object) {
        for (var key in object) { // "keys", "prototype", ...
            if (key === "prototype") {
                // --- extend Object.property ---
                if (!(key in extendTarget)) { // extendTarget has prototype?
                    extendTarget[key] = {};   // extendTarget["prototype"] = {}
                }
                for (var prop in object[key]) {
                    _defineProperty(extendTarget[key], prop, object[key][prop]);
                }
            } else {
                _defineProperty(extendTarget, key, object[key]);
            }
        }
    }

    function _defineProperty(obj, key, value) {
        if ( override || !(key in obj) ) {
            Object.defineProperty(obj, key, {
                "configurable": true, // false is immutable
                "enumerable": false,  // false is invisible(for in loop)
                "writable": true,     // false is read-only
                "value": value
            });
        }
    }
}
1096783
function instanceOf(validatedObject, expectedClass, errorText) {
  if (!(validatedObject instanceof expectedClass)) {
    throw new ValidationError(
      errorText || `Validated object is not an instance of ${expectedClass.name}`
    );
  }
  return validatedObject;
}
44971
public static void isInstanceOf( Object argument,
                                     Class<?> expectedClass,
                                     String name ) {
        isNotNull(argument, name);
        if (!expectedClass.isInstance(argument)) {
            throw new IllegalArgumentException(CommonI18n.argumentMustBeInstanceOf.text(name, argument.getClass(),
                                                                                        expectedClass.getName()));
        }
    }
284679
function is( instance, Class ) {
		switch ( typeof Class ) {
			case 'function' : return instance instanceof Class;
			case 'string'   : return ( Class = get( Class ) ) ? ( instance instanceof Class ) : false;
		}
		return false;
	}
573659
public <T> void newInstance(Local<T> target, MethodId<T, Void> constructor, Local<?>... args) {
        if (target == null) {
            throw new IllegalArgumentException();
        }
        addInstruction(new ThrowingCstInsn(Rops.NEW_INSTANCE, sourcePosition,
                RegisterSpecList.EMPTY, catches, constructor.declaringType.constant));
        moveResult(target, true);
        invokeDirect(constructor, null, target, args);
    }