Source File
base64vlq.go
Belonging Package
github.com/go-sourcemap/sourcemap/internal/base64vlq
package base64vlqimportconst encodeStd = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"const (vlqBaseShift = 5vlqBase = 1 << vlqBaseShiftvlqBaseMask = vlqBase - 1vlqSignBit = 1vlqContinuationBit = vlqBase)var decodeMap [256]bytefunc init() {for := 0; < len(encodeStd); ++ {decodeMap[encodeStd[]] = byte()}}func toVLQSigned( int32) int32 {if < 0 {return -<<1 + 1}return << 1}func fromVLQSigned( int32) int32 {:= &vlqSignBit != 0>>= 1if {return -}return}type Encoder struct {w io.ByteWriter}func ( io.ByteWriter) *Encoder {return &Encoder{w: ,}}func ( Encoder) ( int32) error {= toVLQSigned()for := int32(vlqContinuationBit); &vlqContinuationBit != 0; {= & vlqBaseMask>>= vlqBaseShiftif > 0 {|= vlqContinuationBit}:= .w.WriteByte(encodeStd[])if != nil {return}}return nil}type Decoder struct {r io.ByteReader}func ( io.ByteReader) Decoder {return Decoder{r: ,}}func ( Decoder) () ( int32, error) {:= uint(0)for := true; ; {, := .r.ReadByte()if != nil {return 0,}= decodeMap[]= &vlqContinuationBit != 0+= int32(&vlqBaseMask) <<+= vlqBaseShift}return fromVLQSigned(), nil}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |