Skip to content

Commit

Permalink
bind getByteWidth to the vector type
Browse files Browse the repository at this point in the history
  • Loading branch information
trxcllnt committed Jan 13, 2019
1 parent 9acfaa3 commit 2ef150f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion js/src/vector/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ BaseVector.prototype[Symbol.iterator] = function baseVectorSymbolIterator<T exte
VectorCtor.prototype['set'] = partial2(setVisitor.getVisitFn(typeId));
VectorCtor.prototype['indexOf'] = partial2(indexOfVisitor.getVisitFn(typeId));
VectorCtor.prototype['toArray'] = partial0(toArrayVisitor.getVisitFn(typeId));
VectorCtor.prototype['getByteWidth'] = partial0(byteWidthVisitor.getVisitFn(typeId));
VectorCtor.prototype['getByteWidth'] = partialType0(byteWidthVisitor.getVisitFn(typeId));
VectorCtor.prototype[Symbol.iterator] = partial0(iteratorVisitor.getVisitFn(typeId));
});
});
Expand All @@ -144,6 +144,11 @@ function partial0<T>(visit: (node: T) => any) {
return function(this: T) { return visit(this); };
}

/** @ignore */
function partialType0<T extends Vector>(visit: (node: T['type']) => any) {
return function(this: T) { return visit(this.type); };
}

/** @ignore */
function partial1<T>(visit: (node: T, a: any) => any) {
return function(this: T, a: any) { return visit(this, a); };
Expand Down

0 comments on commit 2ef150f

Please sign in to comment.