-
Notifications
You must be signed in to change notification settings - Fork 451
Expand file tree
/
Copy patharrayBuffer.js
More file actions
29 lines (23 loc) · 970 Bytes
/
arrayBuffer.js
File metadata and controls
29 lines (23 loc) · 970 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'use strict'
const typedArray = require('./typedArray')
function describe (props) {
return new DescribedArrayBufferValue(Object.assign({
buffer: Buffer.from(props.value),
// Set isArray and isList so the property recursor excludes the byte accessors
isArray: true,
isList: true,
}, props))
}
exports.describe = describe
function deserialize (state, recursor) {
return new DeserializedArrayBufferValue(state, recursor)
}
exports.deserialize = deserialize
const tag = Symbol('ArrayBufferValue')
exports.tag = tag
// ArrayBuffers can be represented as regular Buffers, allowing them to be
// treated as TypedArrays for the purposes of this package.
class ArrayBufferValue extends typedArray.TypedArrayValue {}
Object.defineProperty(ArrayBufferValue.prototype, 'tag', { value: tag })
const DescribedArrayBufferValue = typedArray.DescribedMixin(ArrayBufferValue)
const DeserializedArrayBufferValue = typedArray.DeserializedMixin(ArrayBufferValue)