Socket
Socket
Sign inDemoInstall

flatbuffers

Package Overview
Dependencies
Maintainers
2
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flatbuffers - npm Package Compare versions

Comparing version 2.0.6 to 2.0.7

js/index.d.ts

13

js/builder.d.ts

@@ -24,2 +24,3 @@ import { ByteBuffer } from "./byte-buffer.js";

private string_maps;
private text_encoder;
/**

@@ -68,3 +69,3 @@ * Create a FlatBufferBuilder.

* Add an `int8` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `int8` to add the the buffer.
* @param value The `int8` to add the buffer.
*/

@@ -74,3 +75,3 @@ addInt8(value: number): void;

* Add an `int16` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `int16` to add the the buffer.
* @param value The `int16` to add the buffer.
*/

@@ -80,3 +81,3 @@ addInt16(value: number): void;

* Add an `int32` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `int32` to add the the buffer.
* @param value The `int32` to add the buffer.
*/

@@ -86,3 +87,3 @@ addInt32(value: number): void;

* Add an `int64` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `int64` to add the the buffer.
* @param value The `int64` to add the buffer.
*/

@@ -92,3 +93,3 @@ addInt64(value: bigint): void;

* Add a `float32` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `float32` to add the the buffer.
* @param value The `float32` to add the buffer.
*/

@@ -98,3 +99,3 @@ addFloat32(value: number): void;

* Add a `float64` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `float64` to add the the buffer.
* @param value The `float64` to add the buffer.
*/

@@ -101,0 +102,0 @@ addFloat64(value: number): void;

@@ -28,2 +28,3 @@ "use strict";

this.string_maps = null;
this.text_encoder = new TextEncoder();
var initial_size;

@@ -131,3 +132,3 @@ if (!opt_initial_size) {

* Add an `int8` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `int8` to add the the buffer.
* @param value The `int8` to add the buffer.
*/

@@ -140,3 +141,3 @@ Builder.prototype.addInt8 = function (value) {

* Add an `int16` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `int16` to add the the buffer.
* @param value The `int16` to add the buffer.
*/

@@ -149,3 +150,3 @@ Builder.prototype.addInt16 = function (value) {

* Add an `int32` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `int32` to add the the buffer.
* @param value The `int32` to add the buffer.
*/

@@ -158,3 +159,3 @@ Builder.prototype.addInt32 = function (value) {

* Add an `int64` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `int64` to add the the buffer.
* @param value The `int64` to add the buffer.
*/

@@ -167,3 +168,3 @@ Builder.prototype.addInt64 = function (value) {

* Add a `float32` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `float32` to add the the buffer.
* @param value The `float32` to add the buffer.
*/

@@ -176,3 +177,3 @@ Builder.prototype.addFloat32 = function (value) {

* Add a `float64` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `float64` to add the the buffer.
* @param value The `float64` to add the buffer.
*/

@@ -479,35 +480,3 @@ Builder.prototype.addFloat64 = function (value) {

else {
utf8 = [];
var i = 0;
while (i < s.length) {
var codePoint = void 0;
// Decode UTF-16
var a = s.charCodeAt(i++);
if (a < 0xD800 || a >= 0xDC00) {
codePoint = a;
}
else {
var b = s.charCodeAt(i++);
codePoint = (a << 10) + b + (0x10000 - (0xD800 << 10) - 0xDC00);
}
// Encode UTF-8
if (codePoint < 0x80) {
utf8.push(codePoint);
}
else {
if (codePoint < 0x800) {
utf8.push(((codePoint >> 6) & 0x1F) | 0xC0);
}
else {
if (codePoint < 0x10000) {
utf8.push(((codePoint >> 12) & 0x0F) | 0xE0);
}
else {
utf8.push(((codePoint >> 18) & 0x07) | 0xF0, ((codePoint >> 12) & 0x3F) | 0x80);
}
utf8.push(((codePoint >> 6) & 0x3F) | 0x80);
}
utf8.push((codePoint & 0x3F) | 0x80);
}
}
utf8 = this.text_encoder.encode(s);
}

@@ -558,3 +527,3 @@ this.addInt8(0);

startFunc(this, list.length);
this.createObjectOffsetList(list);
this.createObjectOffsetList(list.slice().reverse());
return this.endVector();

@@ -561,0 +530,0 @@ };

@@ -6,2 +6,3 @@ import { Offset, Table } from "./types.js";

private position_;
private text_decoder_;
/**

@@ -71,6 +72,5 @@ * Create a new ByteBuffer with a given array of bytes (`Uint8Array`)

*
* To avoid the conversion to UTF-16, pass Encoding.UTF8_BYTES as
* the "optionalEncoding" argument. This is useful for avoiding conversion to
* and from UTF-16 when the data will just be packaged back up in another
* FlatBuffer later on.
* To avoid the conversion to string, pass Encoding.UTF8_BYTES as the
* "optionalEncoding" argument. This is useful for avoiding conversion when
* the data will just be packaged back up in another FlatBuffer later on.
*

@@ -77,0 +77,0 @@ * @param offset

@@ -14,2 +14,3 @@ "use strict";

this.position_ = 0;
this.text_decoder_ = new TextDecoder();
}

@@ -161,6 +162,5 @@ /**

*
* To avoid the conversion to UTF-16, pass Encoding.UTF8_BYTES as
* the "optionalEncoding" argument. This is useful for avoiding conversion to
* and from UTF-16 when the data will just be packaged back up in another
* FlatBuffer later on.
* To avoid the conversion to string, pass Encoding.UTF8_BYTES as the
* "optionalEncoding" argument. This is useful for avoiding conversion when
* the data will just be packaged back up in another FlatBuffer later on.
*

@@ -173,50 +173,8 @@ * @param offset

var length = this.readInt32(offset);
var result = '';
var i = 0;
offset += constants_js_1.SIZEOF_INT;
if (opt_encoding === encoding_js_1.Encoding.UTF8_BYTES) {
return this.bytes_.subarray(offset, offset + length);
}
while (i < length) {
var codePoint = void 0;
// Decode UTF-8
var a = this.readUint8(offset + i++);
if (a < 0xC0) {
codePoint = a;
}
else {
var b = this.readUint8(offset + i++);
if (a < 0xE0) {
codePoint =
((a & 0x1F) << 6) |
(b & 0x3F);
}
else {
var c = this.readUint8(offset + i++);
if (a < 0xF0) {
codePoint =
((a & 0x0F) << 12) |
((b & 0x3F) << 6) |
(c & 0x3F);
}
else {
var d = this.readUint8(offset + i++);
codePoint =
((a & 0x07) << 18) |
((b & 0x3F) << 12) |
((c & 0x3F) << 6) |
(d & 0x3F);
}
}
}
// Encode UTF-16
if (codePoint < 0x10000) {
result += String.fromCharCode(codePoint);
}
else {
codePoint -= 0x10000;
result += String.fromCharCode((codePoint >> 10) + 0xD800, (codePoint & ((1 << 10) - 1)) + 0xDC00);
}
}
return result;
var utf8bytes = this.bytes_.subarray(offset, offset + length);
if (opt_encoding === encoding_js_1.Encoding.UTF8_BYTES)
return utf8bytes;
else
return this.text_decoder_.decode(utf8bytes);
};

@@ -223,0 +181,0 @@ /**

@@ -76,4 +76,4 @@ "use strict";

var bitWidth = (0, bit_width_util_js_1.fromByteWidth)(byteWidth);
var indirectOffset = keysVectorOffset - readUInt(dataView, keysVectorOffset, bitWidth);
var _byteWidth = readUInt(dataView, keysVectorOffset + byteWidth, bitWidth);
var indirectOffset = keysVectorOffset - Number(readUInt(dataView, keysVectorOffset, bitWidth));
var _byteWidth = Number(readUInt(dataView, keysVectorOffset + byteWidth, bitWidth));
var low = 0;

@@ -98,3 +98,3 @@ var high = length - 1;

var keyOffset = offset + index * width;
var keyIndirectOffset = keyOffset - readUInt(dataView, keyOffset, (0, bit_width_util_js_1.fromByteWidth)(width));
var keyIndirectOffset = keyOffset - Number(readUInt(dataView, keyOffset, (0, bit_width_util_js_1.fromByteWidth)(width)));
for (var i = 0; i < input.length; i++) {

@@ -112,6 +112,6 @@ var dif = input[i] - dataView.getUint8(keyIndirectOffset + i);

var bitWidth = (0, bit_width_util_js_1.fromByteWidth)(byteWidth);
var indirectOffset = keysVectorOffset - readUInt(dataView, keysVectorOffset, bitWidth);
var _byteWidth = readUInt(dataView, keysVectorOffset + byteWidth, bitWidth);
var indirectOffset = keysVectorOffset - Number(readUInt(dataView, keysVectorOffset, bitWidth));
var _byteWidth = Number(readUInt(dataView, keysVectorOffset + byteWidth, bitWidth));
var keyOffset = indirectOffset + index * _byteWidth;
var keyIndirectOffset = keyOffset - readUInt(dataView, keyOffset, (0, bit_width_util_js_1.fromByteWidth)(_byteWidth));
var keyIndirectOffset = keyOffset - Number(readUInt(dataView, keyOffset, (0, bit_width_util_js_1.fromByteWidth)(_byteWidth)));
var length = 0;

@@ -118,0 +118,0 @@ while (dataView.getUint8(keyIndirectOffset + length) !== 0) {

@@ -158,3 +158,3 @@ "use strict";

}
return this._length;
return Number(this._length);
};

@@ -161,0 +161,0 @@ Reference.prototype.toObject = function () {

@@ -24,2 +24,3 @@ import { ByteBuffer } from "./byte-buffer.js";

private string_maps;
private text_encoder;
/**

@@ -68,3 +69,3 @@ * Create a FlatBufferBuilder.

* Add an `int8` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `int8` to add the the buffer.
* @param value The `int8` to add the buffer.
*/

@@ -74,3 +75,3 @@ addInt8(value: number): void;

* Add an `int16` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `int16` to add the the buffer.
* @param value The `int16` to add the buffer.
*/

@@ -80,3 +81,3 @@ addInt16(value: number): void;

* Add an `int32` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `int32` to add the the buffer.
* @param value The `int32` to add the buffer.
*/

@@ -86,3 +87,3 @@ addInt32(value: number): void;

* Add an `int64` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `int64` to add the the buffer.
* @param value The `int64` to add the buffer.
*/

@@ -92,3 +93,3 @@ addInt64(value: bigint): void;

* Add a `float32` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `float32` to add the the buffer.
* @param value The `float32` to add the buffer.
*/

@@ -98,3 +99,3 @@ addFloat32(value: number): void;

* Add a `float64` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `float64` to add the the buffer.
* @param value The `float64` to add the buffer.
*/

@@ -101,0 +102,0 @@ addFloat64(value: number): void;

@@ -25,2 +25,3 @@ import { ByteBuffer } from "./byte-buffer.js";

this.string_maps = null;
this.text_encoder = new TextEncoder();
let initial_size;

@@ -128,3 +129,3 @@ if (!opt_initial_size) {

* Add an `int8` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `int8` to add the the buffer.
* @param value The `int8` to add the buffer.
*/

@@ -137,3 +138,3 @@ addInt8(value) {

* Add an `int16` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `int16` to add the the buffer.
* @param value The `int16` to add the buffer.
*/

@@ -146,3 +147,3 @@ addInt16(value) {

* Add an `int32` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `int32` to add the the buffer.
* @param value The `int32` to add the buffer.
*/

@@ -155,3 +156,3 @@ addInt32(value) {

* Add an `int64` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `int64` to add the the buffer.
* @param value The `int64` to add the buffer.
*/

@@ -164,3 +165,3 @@ addInt64(value) {

* Add a `float32` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `float32` to add the the buffer.
* @param value The `float32` to add the buffer.
*/

@@ -173,3 +174,3 @@ addFloat32(value) {

* Add a `float64` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `float64` to add the the buffer.
* @param value The `float64` to add the buffer.
*/

@@ -476,35 +477,3 @@ addFloat64(value) {

else {
utf8 = [];
let i = 0;
while (i < s.length) {
let codePoint;
// Decode UTF-16
const a = s.charCodeAt(i++);
if (a < 0xD800 || a >= 0xDC00) {
codePoint = a;
}
else {
const b = s.charCodeAt(i++);
codePoint = (a << 10) + b + (0x10000 - (0xD800 << 10) - 0xDC00);
}
// Encode UTF-8
if (codePoint < 0x80) {
utf8.push(codePoint);
}
else {
if (codePoint < 0x800) {
utf8.push(((codePoint >> 6) & 0x1F) | 0xC0);
}
else {
if (codePoint < 0x10000) {
utf8.push(((codePoint >> 12) & 0x0F) | 0xE0);
}
else {
utf8.push(((codePoint >> 18) & 0x07) | 0xF0, ((codePoint >> 12) & 0x3F) | 0x80);
}
utf8.push(((codePoint >> 6) & 0x3F) | 0x80);
}
utf8.push((codePoint & 0x3F) | 0x80);
}
}
utf8 = this.text_encoder.encode(s);
}

@@ -555,5 +524,5 @@ this.addInt8(0);

startFunc(this, list.length);
this.createObjectOffsetList(list);
this.createObjectOffsetList(list.slice().reverse());
return this.endVector();
}
}

@@ -6,2 +6,3 @@ import { Offset, Table } from "./types.js";

private position_;
private text_decoder_;
/**

@@ -71,6 +72,5 @@ * Create a new ByteBuffer with a given array of bytes (`Uint8Array`)

*
* To avoid the conversion to UTF-16, pass Encoding.UTF8_BYTES as
* the "optionalEncoding" argument. This is useful for avoiding conversion to
* and from UTF-16 when the data will just be packaged back up in another
* FlatBuffer later on.
* To avoid the conversion to string, pass Encoding.UTF8_BYTES as the
* "optionalEncoding" argument. This is useful for avoiding conversion when
* the data will just be packaged back up in another FlatBuffer later on.
*

@@ -77,0 +77,0 @@ * @param offset

@@ -11,2 +11,3 @@ import { FILE_IDENTIFIER_LENGTH, SIZEOF_INT } from "./constants.js";

this.position_ = 0;
this.text_decoder_ = new TextDecoder();
}

@@ -158,6 +159,5 @@ /**

*
* To avoid the conversion to UTF-16, pass Encoding.UTF8_BYTES as
* the "optionalEncoding" argument. This is useful for avoiding conversion to
* and from UTF-16 when the data will just be packaged back up in another
* FlatBuffer later on.
* To avoid the conversion to string, pass Encoding.UTF8_BYTES as the
* "optionalEncoding" argument. This is useful for avoiding conversion when
* the data will just be packaged back up in another FlatBuffer later on.
*

@@ -170,50 +170,8 @@ * @param offset

const length = this.readInt32(offset);
let result = '';
let i = 0;
offset += SIZEOF_INT;
if (opt_encoding === Encoding.UTF8_BYTES) {
return this.bytes_.subarray(offset, offset + length);
}
while (i < length) {
let codePoint;
// Decode UTF-8
const a = this.readUint8(offset + i++);
if (a < 0xC0) {
codePoint = a;
}
else {
const b = this.readUint8(offset + i++);
if (a < 0xE0) {
codePoint =
((a & 0x1F) << 6) |
(b & 0x3F);
}
else {
const c = this.readUint8(offset + i++);
if (a < 0xF0) {
codePoint =
((a & 0x0F) << 12) |
((b & 0x3F) << 6) |
(c & 0x3F);
}
else {
const d = this.readUint8(offset + i++);
codePoint =
((a & 0x07) << 18) |
((b & 0x3F) << 12) |
((c & 0x3F) << 6) |
(d & 0x3F);
}
}
}
// Encode UTF-16
if (codePoint < 0x10000) {
result += String.fromCharCode(codePoint);
}
else {
codePoint -= 0x10000;
result += String.fromCharCode((codePoint >> 10) + 0xD800, (codePoint & ((1 << 10) - 1)) + 0xDC00);
}
}
return result;
const utf8bytes = this.bytes_.subarray(offset, offset + length);
if (opt_encoding === Encoding.UTF8_BYTES)
return utf8bytes;
else
return this.text_decoder_.decode(utf8bytes);
}

@@ -220,0 +178,0 @@ /**

@@ -68,4 +68,4 @@ import { BitWidth } from './bit-width.js';

const bitWidth = fromByteWidth(byteWidth);
const indirectOffset = keysVectorOffset - readUInt(dataView, keysVectorOffset, bitWidth);
const _byteWidth = readUInt(dataView, keysVectorOffset + byteWidth, bitWidth);
const indirectOffset = keysVectorOffset - Number(readUInt(dataView, keysVectorOffset, bitWidth));
const _byteWidth = Number(readUInt(dataView, keysVectorOffset + byteWidth, bitWidth));
let low = 0;

@@ -89,3 +89,3 @@ let high = length - 1;

const keyOffset = offset + index * width;
const keyIndirectOffset = keyOffset - readUInt(dataView, keyOffset, fromByteWidth(width));
const keyIndirectOffset = keyOffset - Number(readUInt(dataView, keyOffset, fromByteWidth(width)));
for (let i = 0; i < input.length; i++) {

@@ -102,6 +102,6 @@ const dif = input[i] - dataView.getUint8(keyIndirectOffset + i);

const bitWidth = fromByteWidth(byteWidth);
const indirectOffset = keysVectorOffset - readUInt(dataView, keysVectorOffset, bitWidth);
const _byteWidth = readUInt(dataView, keysVectorOffset + byteWidth, bitWidth);
const indirectOffset = keysVectorOffset - Number(readUInt(dataView, keysVectorOffset, bitWidth));
const _byteWidth = Number(readUInt(dataView, keysVectorOffset + byteWidth, bitWidth));
const keyOffset = indirectOffset + index * _byteWidth;
const keyIndirectOffset = keyOffset - readUInt(dataView, keyOffset, fromByteWidth(_byteWidth));
const keyIndirectOffset = keyOffset - Number(readUInt(dataView, keyOffset, fromByteWidth(_byteWidth)));
let length = 0;

@@ -108,0 +108,0 @@ while (dataView.getUint8(keyIndirectOffset + length) !== 0) {

@@ -154,3 +154,3 @@ import { fromByteWidth } from './bit-width-util.js';

}
return this._length;
return Number(this._length);
}

@@ -157,0 +157,0 @@ toObject() {

{
"name": "flatbuffers",
"version": "2.0.6",
"version": "2.0.7",
"description": "Memory Efficient Serialization Library",

@@ -12,4 +12,4 @@ "files": [

],
"main": "js/flatbuffers.js",
"module": "mjs/flatbuffers.js",
"main": "js/index.js",
"module": "mjs/index.js",
"directories": {

@@ -20,3 +20,3 @@ "doc": "docs",

"scripts": {
"test": "npm run compile && cd tests && ./TypeScriptTest.sh",
"test": "npm run compile && cd tests && python3 ./TypeScriptTest.py",
"compile": "tsc && tsc -p tsconfig.mjs.json",

@@ -40,7 +40,9 @@ "prepublishOnly": "npm install --only=dev && npm run compile"

"devDependencies": {
"@bazel/typescript": "^5.2.0",
"@types/node": "17.0.21",
"@typescript-eslint/eslint-plugin": "^4.12.0",
"@typescript-eslint/parser": "^4.12.0",
"eslint": "^7.17.0",
"typescript": "^4.1.3"
"typescript": "^4.5.5"
}
}

@@ -5,2 +5,4 @@ ![logo](http://google.github.io/flatbuffers/fpl_logo_small.png) FlatBuffers

![Build status](https://github.com/google/flatbuffers/actions/workflows/build.yml/badge.svg?branch=master)
[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/flatbuffers.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:flatbuffers)
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/google/flatbuffers/badge)](https://api.securityscorecards.dev/projects/github.com/google/flatbuffers)
[![Join the chat at https://gitter.im/google/flatbuffers](https://badges.gitter.im/google/flatbuffers.svg)](https://gitter.im/google/flatbuffers?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

@@ -37,2 +39,3 @@ [![Discord Chat](https://img.shields.io/discord/656202785926152206.svg)](https:///discord.gg/6qgKs3R)

* Rust
* Swift
* TypeScript

@@ -39,0 +42,0 @@

@@ -27,2 +27,3 @@ import { ByteBuffer } from "./byte-buffer.js"

private string_maps: Map<string | Uint8Array, number> | null = null;
private text_encoder = new TextEncoder();

@@ -153,3 +154,3 @@ /**

* Add an `int8` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `int8` to add the the buffer.
* @param value The `int8` to add the buffer.
*/

@@ -163,3 +164,3 @@ addInt8(value: number): void {

* Add an `int16` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `int16` to add the the buffer.
* @param value The `int16` to add the buffer.
*/

@@ -173,3 +174,3 @@ addInt16(value: number): void {

* Add an `int32` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `int32` to add the the buffer.
* @param value The `int32` to add the buffer.
*/

@@ -183,3 +184,3 @@ addInt32(value: number): void {

* Add an `int64` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `int64` to add the the buffer.
* @param value The `int64` to add the buffer.
*/

@@ -193,3 +194,3 @@ addInt64(value: bigint): void {

* Add a `float32` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `float32` to add the the buffer.
* @param value The `float32` to add the buffer.
*/

@@ -203,3 +204,3 @@ addFloat32(value: number): void {

* Add a `float64` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `float64` to add the the buffer.
* @param value The `float64` to add the buffer.
*/

@@ -541,36 +542,3 @@ addFloat64(value: number): void {

} else {
utf8 = [];
let i = 0;
while (i < s.length) {
let codePoint;
// Decode UTF-16
const a = s.charCodeAt(i++);
if (a < 0xD800 || a >= 0xDC00) {
codePoint = a;
} else {
const b = s.charCodeAt(i++);
codePoint = (a << 10) + b + (0x10000 - (0xD800 << 10) - 0xDC00);
}
// Encode UTF-8
if (codePoint < 0x80) {
utf8.push(codePoint);
} else {
if (codePoint < 0x800) {
utf8.push(((codePoint >> 6) & 0x1F) | 0xC0);
} else {
if (codePoint < 0x10000) {
utf8.push(((codePoint >> 12) & 0x0F) | 0xE0);
} else {
utf8.push(
((codePoint >> 18) & 0x07) | 0xF0,
((codePoint >> 12) & 0x3F) | 0x80);
}
utf8.push(((codePoint >> 6) & 0x3F) | 0x80);
}
utf8.push((codePoint & 0x3F) | 0x80);
}
}
utf8 = this.text_encoder.encode(s);
}

@@ -628,5 +596,5 @@

startFunc(this, list.length);
this.createObjectOffsetList(list);
this.createObjectOffsetList(list.slice().reverse());
return this.endVector();
}
}

@@ -8,2 +8,3 @@ import { FILE_IDENTIFIER_LENGTH, SIZEOF_INT } from "./constants.js";

private position_ = 0;
private text_decoder_ = new TextDecoder();

@@ -191,6 +192,5 @@ /**

*
* To avoid the conversion to UTF-16, pass Encoding.UTF8_BYTES as
* the "optionalEncoding" argument. This is useful for avoiding conversion to
* and from UTF-16 when the data will just be packaged back up in another
* FlatBuffer later on.
* To avoid the conversion to string, pass Encoding.UTF8_BYTES as the
* "optionalEncoding" argument. This is useful for avoiding conversion when
* the data will just be packaged back up in another FlatBuffer later on.
*

@@ -202,56 +202,9 @@ * @param offset

offset += this.readInt32(offset);
const length = this.readInt32(offset);
let result = '';
let i = 0;
offset += SIZEOF_INT;
if (opt_encoding === Encoding.UTF8_BYTES) {
return this.bytes_.subarray(offset, offset + length);
}
while (i < length) {
let codePoint;
// Decode UTF-8
const a = this.readUint8(offset + i++);
if (a < 0xC0) {
codePoint = a;
} else {
const b = this.readUint8(offset + i++);
if (a < 0xE0) {
codePoint =
((a & 0x1F) << 6) |
(b & 0x3F);
} else {
const c = this.readUint8(offset + i++);
if (a < 0xF0) {
codePoint =
((a & 0x0F) << 12) |
((b & 0x3F) << 6) |
(c & 0x3F);
} else {
const d = this.readUint8(offset + i++);
codePoint =
((a & 0x07) << 18) |
((b & 0x3F) << 12) |
((c & 0x3F) << 6) |
(d & 0x3F);
}
}
}
// Encode UTF-16
if (codePoint < 0x10000) {
result += String.fromCharCode(codePoint);
} else {
codePoint -= 0x10000;
result += String.fromCharCode(
(codePoint >> 10) + 0xD800,
(codePoint & ((1 << 10) - 1)) + 0xDC00);
}
}
return result;
const utf8bytes = this.bytes_.subarray(offset, offset + length);
if (opt_encoding === Encoding.UTF8_BYTES)
return utf8bytes;
else
return this.text_decoder_.decode(utf8bytes);
}

@@ -258,0 +211,0 @@

@@ -68,4 +68,4 @@ import { BitWidth } from './bit-width.js'

const bitWidth = fromByteWidth(byteWidth);
const indirectOffset = keysVectorOffset - (readUInt(dataView, keysVectorOffset, bitWidth) as number);
const _byteWidth = readUInt(dataView, keysVectorOffset + byteWidth, bitWidth) as number;
const indirectOffset = keysVectorOffset - Number(readUInt(dataView, keysVectorOffset, bitWidth));
const _byteWidth = Number(readUInt(dataView, keysVectorOffset + byteWidth, bitWidth));
let low = 0;

@@ -88,3 +88,3 @@ let high = length - 1;

const keyOffset = offset + index * width;
const keyIndirectOffset = keyOffset - (readUInt(dataView, keyOffset, fromByteWidth(width)) as number);
const keyIndirectOffset = keyOffset - Number(readUInt(dataView, keyOffset, fromByteWidth(width)));
for (let i = 0; i < input.length; i++) {

@@ -102,6 +102,6 @@ const dif = input[i] - dataView.getUint8(keyIndirectOffset + i);

const bitWidth = fromByteWidth(byteWidth);
const indirectOffset = keysVectorOffset - (readUInt(dataView, keysVectorOffset, bitWidth) as number);
const _byteWidth = readUInt(dataView, keysVectorOffset + byteWidth, bitWidth) as number;
const indirectOffset = keysVectorOffset - Number(readUInt(dataView, keysVectorOffset, bitWidth));
const _byteWidth = Number(readUInt(dataView, keysVectorOffset + byteWidth, bitWidth));
const keyOffset = indirectOffset + index * _byteWidth;
const keyIndirectOffset = keyOffset - (readUInt(dataView, keyOffset, fromByteWidth(_byteWidth)) as number);
const keyIndirectOffset = keyOffset - Number(readUInt(dataView, keyOffset, fromByteWidth(_byteWidth)));
let length = 0;

@@ -108,0 +108,0 @@ while (dataView.getUint8(keyIndirectOffset + length) !== 0) {

@@ -160,3 +160,3 @@ import { fromByteWidth } from './bit-width-util.js'

}
return this._length;
return Number(this._length);
}

@@ -163,0 +163,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc