In order to keep compatibility through major versions we have to make kind of an cross major version instanceof
489189
function _looksLikeAYHTTPError(err) {
  return err instanceof YHTTPError || (
     err.constructor &&
     err.constructor.name &&
     err.constructor.name.endsWith('Error') &&
    'string' === typeof err.code && _looksLikeAYHTTPErrorCode(err.code) &&
    'number' === typeof err.httpCode &&
    err.params && err.params instanceof Array
  );
}
1209299
def raise_on_major_version_mismatch(work_request, local_version):
    
    request_major_version = get_major_version(work_request.version)
    local_major_version = get_major_version(local_version)
    if request_major_version != local_major_version:
        raise ValueError("Received major version mismatch. request:{} local:{}".format(
            work_request.version, local_version
        ))
    else:
        logging.info("Ignoring non-major version mismatch request:{} local:{}".format(
            work_request.version, local_version))
1359738
function compareComponents(a, b) {
  const [aNormalized, bNormalized] = normalizeVersions(a, b);

  for (let i = 0; i < bNormalized.length; i++) {
    const result = compareNumeric(aNormalized[i], bNormalized[i]);
    if (result) {
      return result;
    }
  }

  return 0;
}
154240
function addInstance(machineName, versionKey) {

        return co(function*() {
            debug("Adding a new instance to the " + versionKey + " of the '" + machineName + "' machine");
            let manifest = getManifest();

            let machine = manifest.machines[machineName];
            if (!machine) {
                throw new Error("Machine does not exists");
            }

            let version = machine.versions[versionKey];
            if (!version) {
                throw new Error("Version does not exists");
            }

            let versionInfo = getVersionInfo(machineName,  versionKey);
            if(!versionInfo.isSealed) {
                throw new Error("The version is not sealed yet");
            }

            let newInstanceKey = "instance" + (Object.keys(version.instances).length + 1);
            let instanceDirPath = version.route + "/instances/" + newInstanceKey;
            let instanceSnapshotsDirPath = instanceDirPath + "/snapshots";
            version.instances[newInstanceKey] = {
                "route": instanceDirPath,
                "snapshots": {}
            };

            let infoFile = instanceDirPath + "/info.json";

            debug("Creating the directories");
            fs.mkdirSync(repositoryPath + "/" + instanceDirPath);
            fs.mkdirSync(repositoryPath + "/" + instanceSnapshotsDirPath);

            debug("Creating the instance info.json file");
            let info = {
                "hasStarted": false,
                "hasEnded": false
            };
            jsonfile.writeFileSync(repositoryPath + "/" + infoFile, info);

            debug("Setting the manifest");
            setManifest(manifest);
            yield _commit(null, ["manifest.json", infoFile],
                "Created the "+newInstanceKey+" for the "+versionKey+" of the '" + machineName + "' machine");

            return newInstanceKey;
        });
    }
275219
@Override
  public boolean provablyNotInstanceOf(KbCollection col, Context ctx) {
    return wrapped().provablyNotInstanceOf(col, ctx);
  }
1165251
function mergeIntoWithNoDuplicateKeys(one, two) {
	  !(one && two && typeof one === 'object' && typeof two === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.') : _prodInvariant('80') : void 0;

	  for (var key in two) {
	    if (two.hasOwnProperty(key)) {
	      !(one[key] === undefined) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): Tried to merge two objects with the same key: `%s`. This conflict may be due to a mixin; in particular, this may be caused by two getInitialState() or getDefaultProps() methods returning objects with clashing keys.', key) : _prodInvariant('81', key) : void 0;
	      one[key] = two[key];
	    }
	  }
	  return one;
	}
505301
def canonicalize_version(version):
    

    try:
        version = Version(version)
    except InvalidVersion:
        # Legacy versions cannot be normalized
        return version

    parts = []

    # Epoch
    if version.epoch != 0:
        parts.append("{0}!".format(version.epoch))

    # Release segment
    # NB: This strips trailing '.0's to normalize
    parts.append(re.sub(r"(\.0)+$", "", ".".join(str(x) for x in version.release)))

    # Pre-release
    if version.pre is not None:
        parts.append("".join(str(x) for x in version.pre))

    # Post-release
    if version.post is not None:
        parts.append(".post{0}".format(version.post))

    # Development release
    if version.dev is not None:
        parts.append(".dev{0}".format(version.dev))

    # Local version segment
    if version.local is not None:
        parts.append("+{0}".format(version.local))

    return "".join(parts)
279586
function setVersion(versionType, versionFull) {
        versionType.version = versionFull;
        var versionArray = versionFull.split(".");
        if (versionArray.length > 0) {
            versionArray = versionArray.reverse();
            versionType.major = versionArray.pop();
            if (versionArray.length > 0) {
                versionType.minor = versionArray.pop();
                if (versionArray.length > 0) {
                    versionArray = versionArray.reverse();
                    versionType.patch = versionArray.join(".");
                } else {
                    versionType.patch = "0";
                }
            } else {
                versionType.minor = "0";
            }
        } else {
            versionType.major = "0";
        }
    }
1148146
def _CreateAllTypes(self, enumTypes, dataTypes, managedTypes):
      

      # Create versions
      for typeInfo in managedTypes:
         name = typeInfo[0]
         version = typeInfo[3]
         VmomiSupport.AddVersion(version, '', '1.0', 0, name)
         VmomiSupport.AddVersionParent(version, 'vmodl.version.version0')
         VmomiSupport.AddVersionParent(version, 'vmodl.version.version1')
         VmomiSupport.AddVersionParent(version, version)

      # Create partial types
      for fn, infos in (VmomiSupport.CreateEnumType, enumTypes), \
                       (VmomiSupport.CreateDataType, dataTypes), \
                       (VmomiSupport.CreateManagedType, managedTypes):
         for typeInfo in infos:
            try:
               fn(*typeInfo)
            except Exception as err:
               #Ignore errors due to duplicate importing
               pass
1000765
def _exceeds_version(self, major, minor, v_major, v_minor):
        """"""
        return (major > v_major or (major == v_major and minor > v_minor))
826300
static void makeVersionInfoBits(Version version, BitArray bits) throws WriterException {
    bits.appendBits(version.getVersionNumber(), 6);
    int bchCode = calculateBCHCode(version.getVersionNumber(), VERSION_INFO_POLY);
    bits.appendBits(bchCode, 12);

    if (bits.getSize() != 18) {  // Just in case.
      throw new WriterException("should not happen but we got: " + bits.getSize());
    }
  }
635193
@Override
    public int isCompatible(Class<?> target, Object actual) {
        int superCompat = super.isCompatible(target, actual);
        if (superCompat >= 0 && superCompat < 3) {
            return superCompat;
        }

        Class<?> actualClass = actual.getClass();
        if (actualClass == Types.UNDEFINED.getClass() || actualClass == Types.NULL.getClass()) {
            return 3;
        }

        if (JSFunction.class.isAssignableFrom(actualClass)) {
            if (isSingleAbstractMethod(target) != null) {
                return 3;
            }
        }

        return -1;
    }
683611
function isPropagatingVersion(uri) {
  const version = uri.split('@')[1];

  return !!version && _.includes(propagatingVersions, version);
}
537645
def match(self, other_version):
    
    major, minor, patch = _str_to_version(other_version, allow_wildcard=True)
    return (major in [self.major, "*"] and minor in [self.minor, "*"]
            and patch in [self.patch, "*"])
538673
function transformVersionInfo() {

		// get the transitive dependencies of the given libs from the sap.ui.versioninfo
		// only do this once if mKnownLibs is not created yet
		if (sap.ui.versioninfo && sap.ui.versioninfo.libraries && !mKnownLibs) {
			// flatten dependency lists for all libs
			mKnownLibs = {};
			sap.ui.versioninfo.libraries.forEach(function(oLib, i) {
				mKnownLibs[oLib.name] = {};

				var mDeps = oLib.manifestHints && oLib.manifestHints.dependencies &&
							oLib.manifestHints.dependencies.libs;
				for (var sDep in mDeps) {
					if (!mDeps[sDep].lazy) {
						mKnownLibs[oLib.name][sDep] = true;
					}
				}
			});
		}

		// get transitive dependencies for a component
		if (sap.ui.versioninfo && sap.ui.versioninfo.components && !mKnownComponents) {
			mKnownComponents = {};

			Object.keys(sap.ui.versioninfo.components).forEach(function(sComponentName) {
				var oComponentInfo = sap.ui.versioninfo.components[sComponentName];

				mKnownComponents[sComponentName] = {
					library: oComponentInfo.library,
					dependencies: []
				};

				var mDeps = oComponentInfo.manifestHints && oComponentInfo.manifestHints.dependencies &&
							oComponentInfo.manifestHints.dependencies.libs;
				for (var sDep in mDeps) {
					if (!mDeps[sDep].lazy) {
						mKnownComponents[sComponentName].dependencies.push(sDep);
					}
				}
			});
		}
	}
1331127
private void enforceVersionSupported()
    {
        if ( _versionSupported != null )
        {
            int majorSupported = _versionSupported.major();
            int minorSupported = _versionSupported.minor();

            if ( majorSupported < 0 )    // no real version support requirement
                return;

            AptControlInterface ci = getControlInterface();
            if ( ci == null )
                return;

            int majorPresent = -1;
            int minorPresent = -1;
            Version ciVersion = ci.getVersion();
            if ( ciVersion != null )
            {
                majorPresent = ciVersion.major();
                minorPresent = ciVersion.minor();

                if ( majorSupported >= majorPresent &&
                     (minorSupported < 0 || minorSupported >= minorPresent) )
                {
                    // Version requirement is satisfied
                    return;
                }
            }

            //
            // Version requirement failed
            //

            _ap.printError( _implDecl, "versionsupported.failed", _implDecl.getSimpleName(), majorSupported, minorSupported,
                            majorPresent, minorPresent );
        }
    }
7198
function toDrupalMajorVersion(version) {
    var regex = /^(\d+)\.\d+\.[x\d+]/;
    var match = version.match(regex)
    if (match) {
      return match[1] + '.x';
    }

    return version;
  }