format
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { memcpy } from "./mem"
|
||||
import { Type } from "./Type"
|
||||
import { memcpy } from './mem'
|
||||
import { Type } from './Type'
|
||||
|
||||
export function ConstString(size) {
|
||||
const obj = { _size: size }
|
||||
@ -7,7 +7,7 @@ export function ConstString(size) {
|
||||
obj.new(ConstString, arguments)
|
||||
return obj
|
||||
}
|
||||
ConstString.prototype.serialize = function(dv, src) {
|
||||
ConstString.prototype.serialize = function (dv, src) {
|
||||
const encoder = new TextEncoder('utf-8')
|
||||
const encoded = new DataView(encoder.encode(src).buffer, 0, this._size)
|
||||
|
||||
@ -21,15 +21,15 @@ ConstString.prototype.serialize = function(dv, src) {
|
||||
memcpy(dv, encoded)
|
||||
return
|
||||
}
|
||||
ConstString.prototype.parse = function(dv) {
|
||||
ConstString.prototype.parse = function (dv) {
|
||||
const frame = new DataView(dv.buffer, dv.byteOffset, this._size)
|
||||
const decoder = new TextDecoder('utf-8')
|
||||
return decoder.decode(frame)
|
||||
}
|
||||
ConstString.prototype.isHeadless = function() {
|
||||
ConstString.prototype.isHeadless = function () {
|
||||
return false
|
||||
}
|
||||
ConstString.prototype.sizeof = function() {
|
||||
ConstString.prototype.sizeof = function () {
|
||||
return this._size
|
||||
}
|
||||
Object.setPrototypeOf(ConstString.prototype, Type.prototype)
|
||||
|
||||
Reference in New Issue
Block a user