code: function slice(v, releaseType) {
    if (!semver.valid(v, /* loose */ true)) {
      return null
    }
  
    const major = semver.major(v, /* loose */ true)
    const minor = semver.minor(v, /* loose */ true)
    const patch = semver.patch(v, /* loose */ true)
    const prerelease = semver.prerelease(v, /* loose */ true)
  
    const dottedParts = {
      major: [major],
      minor: [major, minor],
      patch: [major, minor, patch],
    }[releaseType]
  
    if (dottedParts === undefined) {
      throw Error(`Unknown releaseType: ${releaseType}`)
    }
  
    const dotted = dottedParts.join('.')
    if (prerelease) {
      return `${dotted}-${prerelease.join('.')}`
    } else {
      return dotted
    }
  }
docs: Slice the specified number of dotted parts from the given semver version. e.g. slice('2.4.7', 'minor') -> '2.4'