Skip to content

Commit 5079fc7

Browse files
committed
bvals -> buffer
1 parent 7233f34 commit 5079fc7

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/lib/array.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ exports.decodeTypedArraySpec = function(v) {
8686
v = coerceTypedArraySpec(v);
8787
var T = typedArrays[v.dtype];
8888
var buffer;
89-
if(v.bvals.constructor === ArrayBuffer) {
89+
if(v.buffer.constructor === ArrayBuffer) {
9090
// Already an ArrayBuffer
91-
buffer = v.bvals;
91+
buffer = v.buffer;
9292
} else {
9393
// Decode, assuming a string
94-
buffer = b64.decode(v.bvals);
94+
buffer = b64.decode(v.buffer);
9595
}
9696

9797
// Check if 1d shape. If so, we're done
@@ -143,7 +143,7 @@ exports.decodeTypedArraySpec = function(v) {
143143

144144
function isTypedArraySpec(v) {
145145
// Assume v has not passed through
146-
return isPlainObject(v) && typedArrays[v.dtype] && v.bvals && (
146+
return isPlainObject(v) && typedArrays[v.dtype] && v.buffer && (
147147
Number.isInteger(v.shape) ||
148148
(isArrayOrTypedArray(v.shape) &&
149149
v.shape.length > 0 &&
@@ -154,7 +154,7 @@ exports.isTypedArraySpec = isTypedArraySpec;
154154

155155
function coerceTypedArraySpec(v) {
156156
// Assume isTypedArraySpec passed
157-
var coerced = {dtype: v.dtype, bvals: v.bvals};
157+
var coerced = {dtype: v.dtype, buffer: v.buffer};
158158

159159
// Normalize shape to a list
160160
if(Number.isInteger(v.shape)) {

src/lib/coerce.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ exports.valObjectMeta = {
3232
'The value could be an {array}',
3333
'noting that typed arrays (e.g. Float32Array) are also supported.',
3434
'It could also be an object in the form of',
35-
'v: {, dtype: \'float32\', bvals: [/* ... */]}, shape: [dim0 (, dim1, (dim3))]',
35+
'v: {, dtype: \'float32\', buffer: [/* ... */]}, shape: [dim0 (, dim1, (dim3))]',
3636
'otherwise, it would be ignored.'
3737
].join(' '),
3838
requiredOpts: [],
@@ -50,7 +50,7 @@ exports.valObjectMeta = {
5050
var uid = propOut.obj.uid;
5151
var module = propOut.obj._module;
5252

53-
if(v.bvals.constructor === ArrayBuffer || !uid || !module) {
53+
if(v.buffer.constructor === ArrayBuffer || !uid || !module) {
5454
// Already an ArrayBuffer
5555
// decoding is cheap
5656
propOut.set(decodeTypedArraySpec(v));
@@ -59,11 +59,11 @@ exports.valObjectMeta = {
5959
var cache = module._b64BufferCache || {};
6060

6161
// Check cache
62-
var cachedBuffer = ((cache[uid] || {})[prop] || {})[v.bvals];
62+
var cachedBuffer = ((cache[uid] || {})[prop] || {})[v.buffer];
6363
if(cachedBuffer !== undefined) {
6464
// Use cached array buffer instead of base64 encoded
6565
// string
66-
v.bvals = cachedBuffer;
66+
v.buffer = cachedBuffer;
6767
propOut.set(decodeTypedArraySpec(v));
6868
} else {
6969
// Not in so cache decode
@@ -76,7 +76,7 @@ exports.valObjectMeta = {
7676
// Clear any prior cache value (only store one per
7777
// trace property
7878
cache[uid][prop] = {};
79-
cache[uid][prop][v.bvals] = decoded.buffer;
79+
cache[uid][prop][v.buffer] = decoded.buffer;
8080
module._b64BufferCache = cache;
8181
}
8282
}

0 commit comments

Comments
 (0)