func newRangeByShortcut(str []byte) (Range, error) {
	t := bytes.TrimLeft(str, "~^")
	num, err := NewVersion(t)
	if err != nil {
		return Range{}, err
	}
	if bytes.HasPrefix(t, []byte("0.0.")) {
		return NewRange(t)
	}

	r := Range{lower: num, hasLower: true, equalsLower: true, hasUpper: true, upper: Version{}}

	switch {
	case bytes.HasPrefix(t, []byte("0.")):
		r.upper.version[0] = r.lower.version[0]
		r.upper.version[1] = r.lower.version[1] + 1
	case str[0] == '^' || bytes.IndexByte(t, '.') <= -1:
		r.upper.version[0] = r.lower.version[0] + 1
	case str[0] == '~':
		r.upper.version[0] = r.lower.version[0]
		r.upper.version[1] = r.lower.version[1] + 1
	}

	return r, nil
}
// newRangeByShortcut covers the special case of Ranges whose boundaries
// are declared using prefixes.
newRangeByShortcut covers the special case of Ranges whose boundaries
are declared using prefixes.
// newRangeByShortcut covers the special case of Ranges whose boundaries // are declared using prefixes .
func newRangeByShortcut(str []byte) (Range, error) {
	t := bytes.TrimLeft(str, "~^")
	num, err := NewVersion(t)
	if err != nil {
		return Range{}, err
	}
	if bytes.HasPrefix(t, []byte("0.0.")) {
		return NewRange(t)
	}
	r := Range{lower: num, hasLower: true, equalsLower: true, hasUpper: true, upper: Version{}}
	switch {
	case bytes.HasPrefix(t, []byte("0.")):
		r.upper.version[0] = r.lower.version[0]
		r.upper.version[1] = r.lower.version[1] + 1
	case str[0] == '^' || bytes.IndexByte(t, '.') <= -1:
		r.upper.version[0] = r.lower.version[0] + 1
	case str[0] == '~':
		r.upper.version[0] = r.lower.version[0]
		r.upper.version[1] = r.lower.version[1] + 1
	}
	return r, nil
}
func newRangeByShortcut ( str [ ] byte ) ( Range , error ) { t := bytes . TrimLeft ( str , " " ) num , err := NewVersion ( t ) if err != nil { return Range { } , err } if bytes . HasPrefix ( t , [ ] byte ( " " ) ) { return NewRange ( t ) } r := Range { lower : num , hasLower : true , equalsLower : true , hasUpper : true , upper : Version { } } switch { case bytes . HasPrefix ( t , [ ] byte ( " " ) ) : r . upper . version [ 0 ] = r . lower . version [ 0 ] r . upper . version [ 1 ] = r . lower . version [ 1 ] + 1 case str [ 0 ] == '^' || bytes . IndexByte ( t , '.' ) <= - 1 : r . upper . version [ 0 ] = r . lower . version [ 0 ] + 1 case str [ 0 ] == '~' : r . upper . version [ 0 ] = r . lower . version [ 0 ] r . upper . version [ 1 ] = r . lower . version [ 1 ] + 1 } return r , nil }
newRangeByShortcut covers the special case of Ranges whose boundaries
are declared using prefixes.
newRangeByShortcut covers the special case of Ranges whose boundaries are declared using prefixes .