ToBigUint64Array converts the value to uint64 slice if it's a BigUint64Array.
()
| 1052 | |
| 1053 | // ToBigUint64Array converts the value to uint64 slice if it's a BigUint64Array. |
| 1054 | func (v *Value) ToBigUint64Array() ([]uint64, error) { |
| 1055 | if !v.IsBigUint64Array() { |
| 1056 | return nil, errors.New("value is not a BigUint64Array") |
| 1057 | } |
| 1058 | |
| 1059 | buffer, byteOffset, byteLength, _ := v.getTypedArrayInfo() |
| 1060 | defer buffer.Free() |
| 1061 | |
| 1062 | totalSize := uint(byteOffset + byteLength) |
| 1063 | bytes, err := buffer.ToByteArray(totalSize) |
| 1064 | if err != nil { |
| 1065 | return nil, err |
| 1066 | } |
| 1067 | |
| 1068 | data := bytes[byteOffset : byteOffset+byteLength] |
| 1069 | result := make([]uint64, len(data)/8) |
| 1070 | for i := 0; i < len(result); i++ { |
| 1071 | result[i] = binary.LittleEndian.Uint64(data[i*8:]) |
| 1072 | } |
| 1073 | return result, nil |
| 1074 | } |
| 1075 | |
| 1076 | // ============================================================================= |
| 1077 | // BASIC TYPE CHECKING METHODS |