Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
build() {
const builder = new flatbuffers.Builder(1);
// Create vectors
const signatureVector = MosaicCreationTransactionBuffer
.createSignatureVector(builder, Array(...Array(64)).map(Number.prototype.valueOf, 0));
const signerVector = MosaicCreationTransactionBuffer
.createSignerVector(builder, Array(...Array(32)).map(Number.prototype.valueOf, 0));
const deadlineVector = MosaicCreationTransactionBuffer
.createDeadlineVector(builder, this.deadline);
const feeVector = MosaicCreationTransactionBuffer
.createFeeVector(builder, this.maxFee);
const nonceVector = MosaicCreationTransactionBuffer
.createNonceVector(builder, this.nonce);
const mosaicIdVector = MosaicCreationTransactionBuffer
.createMosaicIdVector(builder, this.mosaicId);
const durationVector = MosaicCreationTransactionBuffer
build() {
const builder = new flatbuffers.Builder(1);
// Create vectors
const signatureVector = AccountLinkTransactionBuffer
.createSignatureVector(builder, Array(...Array(64)).map(Number.prototype.valueOf, 0));
const signerVector = AccountLinkTransactionBuffer.createSignerVector(builder, Array(...Array(32)).map(Number.prototype.valueOf, 0));
const deadlineVector = AccountLinkTransactionBuffer.createDeadlineVector(builder, this.deadline);
const feeVector = AccountLinkTransactionBuffer.createFeeVector(builder, this.fee);
const remoteAccountKeyVector = AccountLinkTransactionBuffer.createRemoteAccountKeyVector(builder, this.remoteAccountKey);
AccountLinkTransactionBuffer.startAccountLinkTransactionBuffer(builder);
AccountLinkTransactionBuffer.addSize(builder, 153);
AccountLinkTransactionBuffer.addSignature(builder, signatureVector);
AccountLinkTransactionBuffer.addSigner(builder, signerVector);
AccountLinkTransactionBuffer.addVersion(builder, this.version);
AccountLinkTransactionBuffer.addType(builder, this.type);
AccountLinkTransactionBuffer.addFee(builder, feeVector);
function encodeMatrix(columns, colIndex = undefined) {
/*
IMPORTANT: this is not a general purpose encoder. in particular,
it doesn't correctly handle all column index types, nor does it
handle all column typedarray types.
encodeMatrixFBS in matrix.py is more general. This is used only
as a testing santity check (alt implementation).
*/
const utf8Encoder = new TextEncoder("utf-8");
const builder = new flatbuffers.Builder(1024);
const cols = _.map(columns, carr => {
let uType;
let tarr;
if (_.every(carr, _.isNumber)) {
uType = NetEncoding.TypedArray.Float32Array;
tarr = encodeTypedArray(builder, uType, new Float32Array(carr));
} else {
uType = NetEncoding.TypedArray.JSONEncodedArray;
const json = JSON.stringify(carr);
const jsonUTF8 = utf8Encoder.encode(json);
tarr = encodeTypedArray(builder, uType, jsonUTF8);
}
NetEncoding.Column.startColumn(builder);
NetEncoding.Column.addUType(builder, uType);
NetEncoding.Column.addU(builder, tarr);
return NetEncoding.Column.endColumn(builder);
public async removeConnection(graphId: Id, source: Socket, target: Socket): Promise {
const connection = Connection.create(source, target, false);
const builder = new flatbuffers.Builder(356);
const offGraphId = builder.createString(graphId.toString());
sz.RemoveConnectionRequest.startRemoveConnectionRequest(builder);
sz.RemoveConnectionRequest.addGraphId(builder, offGraphId);
sz.RemoveConnectionRequest.addSocketLink(
builder,
sz.SocketLinkDescription.createSocketLinkDescription(
builder,
conversions.toFbLong(connection.outputSocket.parent.id),
conversions.toFbLong(connection.outputSocket.index),
conversions.toFbLong(connection.inputSocket.parent.id),
conversions.toFbLong(connection.inputSocket.index),
connection.isWriteLink
)
);
const off = sz.RemoveConnectionRequest.endRemoveConnectionRequest(builder);
export function buildFeature(feature: IGeoJsonFeature, header: HeaderMeta) {
const columns = header.columns
const builder = new flatbuffers.Builder(0)
const propertiesArray = new Uint8Array(100000)
let offset = 0;
if (columns) {
const view = new DataView(propertiesArray.buffer)
for (let i = 0; i < columns.length; i++) {
const column = columns[i]
const value = feature.properties[column.name]
if (value === null)
continue
view.setUint16(offset, i, true)
offset += 2
switch (column.type) {
case ColumnType.Bool:
view.setUint8(offset, value as number)
offset += 1
function _createDictionaryField(id, field) {
const builder = new flatbuffers.Builder();
const nameOffset = builder.createString("dict-" + id);
const typeType = field.typeType();
let typeOffset;
if (typeType === Type.Int) {
const type = field.type(new org.apache.arrow.flatbuf.Int());
org.apache.arrow.flatbuf.Int.startInt(builder);
org.apache.arrow.flatbuf.Int.addBitWidth(builder, type.bitWidth());
org.apache.arrow.flatbuf.Int.addIsSigned(builder, type.isSigned());
typeOffset = org.apache.arrow.flatbuf.Int.endInt(builder);
} else if (typeType === Type.FloatingPoint) {
const type = field.type(new org.apache.arrow.flatbuf.FloatingPoint());
org.apache.arrow.flatbuf.FloatingPoint.startFloatingPoint(builder);
org.apache.arrow.flatbuf.FloatingPoint.addPrecision(builder, type.precision());
typeOffset = org.apache.arrow.flatbuf.FloatingPoint.endFloatingPoint(builder);
} else if (typeType === Type.Utf8) {
static encoder(size: number = 1024): FlatBufferEncoder {
return new FlatBufferEncoder(new flatbuffers.Builder(size), [])
}
static selectChildren(state: FlatBufferEncoder): FlatBufferEncoder {