JCloudYu/beson · deserialize.esm.js
javascript logo
function __deserializeObjectStreaming(buffer, start, options) {
	let end = start;
	let dataView = new DataView(buffer);
	let endData = new Uint16Array(TYPE_HEADER.OBJECT_END);
	let data = {};
	while (start < buffer.byteLength) {
		let tmpType = dataView.getUint16(start, true);
		if (tmpType === endData[0]) {
			end += 2;
			break;
		}

		let subType, subKey, subData;
		({ anchor: start, value: subType } = __deserializeType(buffer, start, options));
		({ anchor: start, value: subKey } = __deserializeShortString(buffer, start, options));
		({ anchor: start, value: subData } = __deserializeData(subType, buffer, start, options));
		data[subKey] = subData;
		end = start;
	}
	return { anchor: end, value: data };
}
Similar code snippets
1.
JCloudYu/beson · deserialize.esm.js
Match rating: 89.49% · See similar code snippets
javascript logo
function __deserializeArrayStreaming(buffer, start, options) {
	let end = start;
	let dataView = new DataView(buffer);
	let endData = new Uint16Array(TYPE_HEADER.ARRAY_END);
	let data = [];
	while (start < buffer.byteLength) {
		let tmpType = dataView.getUint16(start, true);
		if (tmpType === endData[0]) {
			end += 2;
			break;
		}
		
		let subType, subData;
		({ anchor: start, value: subType } = __deserializeType(buffer, start, options));
		({ anchor: start, value: subData } = __deserializeData(subType, buffer, start, options));
		data.push(subData);
		end = start;
	}
	return { anchor: end, value: data };
}
2.
JCloudYu/beson · deserialize.esm.js
Match rating: 86.88% · See similar code snippets
javascript logo
function __deserializeObject(buffer, start, options) {
	let dataView = new DataView(buffer);
	let length = dataView.getUint32(start, true);
	start += 4;
	let end = start + length;
	let data = {};
	while (start < end) {
		let subType, subKey, subData;
		({ anchor: start, value: subType } = __deserializeType(buffer, start, options));
		({ anchor: start, value: subKey } = __deserializeShortString(buffer, start, options));
		({ anchor: start, value: subData } = __deserializeData(subType, buffer, start, options));
		data[subKey] = subData;
	}
	return { anchor: end, value: data };
}
3.
JCloudYu/beson · deserialize.esm.js
Match rating: 84.63% · See similar code snippets
javascript logo
function __deserializeArray(buffer, start, options) {
	let dataView = new DataView(buffer);
	let length = dataView.getUint32(start, true);
	start += 4;
	let end = start + length;
	let data = [];
	while (start < end) {
		let subType, subData;
		({ anchor: start, value: subType } = __deserializeType(buffer, start, options));
		({ anchor: start, value: subData } = __deserializeData(subType, buffer, start, options));
		data.push(subData);
	}
	return { anchor: end, value: data };
}
4.
JCloudYu/beson · deserialize.esm.js
Match rating: 73.17% · See similar code snippets
javascript logo
function __deserializeContent(buffer, start, options) {
	let type, data;
	({ anchor: start, value: type } = __deserializeType(buffer, start, options));
	({ anchor: start, value: data } = __deserializeData(type, buffer, start, options));
	return { anchor: start, value: data };
}
5.
JCloudYu/beson · deserialize.esm.js
Match rating: 67.55% · See similar code snippets
javascript logo
function __deserializeDate(buffer, start, options) {
	let end = start + 8;
	let dataView = new DataView(buffer);
	let data = new Date(dataView.getFloat64(start, true));
	return { anchor: end, value: data };
}
6.
JCloudYu/beson · deserialize.esm.js
Match rating: 67.32% · See similar code snippets
javascript logo
function __deserializeData(type, buffer, start, options) {
	let result = {anchor:start, value:undefined};
	if (type === DATA_TYPE.NULL) {
		result = __deserializeNull(start, options);
	}
	else if (type === DATA_TYPE.FALSE || type === DATA_TYPE.TRUE) {
		result = __deserializeBoolean(type, start, options);
	}
	else if (type === DATA_TYPE.INT8) {
		result = __deserializeInt8(buffer, start, options);
	}
	else if (type === DATA_TYPE.INT16) {
		result = __deserializeInt16(buffer, start, options);
	}
	else if (type === DATA_TYPE.INT32) {
		result = __deserializeInt32(buffer, start, options);
	}
	else if (type === DATA_TYPE.INT64) {
		result = __deserializeInt64(buffer, start, options);
	}
	else if (type === DATA_TYPE.INT128) {
		result = __deserializeInt128(buffer, start, options);
	}
	else if (type === DATA_TYPE.INT256) {
		result = __deserializeInt256(buffer, start, options);
	}
	else if (type === DATA_TYPE.INT512) {
		result = __deserializeInt512(buffer, start, options);
	}
	else if (type === DATA_TYPE.INTVAR) {
		result = __deserializeIntVar(buffer, start, options);
	}
	else if (type === DATA_TYPE.UINT8) {
		result = __deserializeUInt8(buffer, start, options);
	}
	else if (type === DATA_TYPE.UINT16) {
		result = __deserializeUInt16(buffer, start, options);
	}
	else if (type === DATA_TYPE.UINT32) {
		result = __deserializeUInt32(buffer, start, options);
	}
	else if (type === DATA_TYPE.UINT64) {
		result = __deserializeUInt64(buffer, start, options);
	}
	else if (type === DATA_TYPE.UINT128) {
		result = __deserializeUInt128(buffer, start, options);
	}
	else if (type === DATA_TYPE.UINT256) {
		result = __deserializeUInt256(buffer, start, options);
	}
	else if (type === DATA_TYPE.UINT512) {
		result = __deserializeUInt512(buffer, start, options);
	}
	else if (type === DATA_TYPE.UINTVAR) {
		result = __deserializeUIntVar(buffer, start, options);
	}
	else if (type === DATA_TYPE.FLOAT32) {
		result = __deserializeFloat32(buffer, start, options);
	}
	else if (type === DATA_TYPE.FLOAT64) {
		result = __deserializeFloat64(buffer, start, options);
	}
	else if (type === DATA_TYPE.STRING) {
		result = __deserializeString(buffer, start, options);
	}
	else if (type === DATA_TYPE.ARRAY) {
		result = __deserializeArray(buffer, start, options);
	}
	else if (type === DATA_TYPE.ARRAY_START) {
		result = __deserializeArrayStreaming(buffer, start, options);
	}
	else if (type === DATA_TYPE.OBJECT) {
		result = __deserializeObject(buffer, start, options);
	}
	else if (type === DATA_TYPE.OBJECT_START) {
		result = __deserializeObjectStreaming(buffer, start, options);
	}
	else if (type === DATA_TYPE.DATE) {
		result = __deserializeDate(buffer, start, options);
	}
	else if (type === DATA_TYPE.OBJECTID) {
		result = __deserializeObjectId(buffer, start, options);
	}
	else if (type === DATA_TYPE.BINARY) {
		result = __deserializeArrayBuffer(buffer, start, options);
		result.value = Binary.FromArrayBuffer(result.value);
	}
	else if (type === DATA_TYPE.ARRAY_BUFFER) {
		result = __deserializeArrayBuffer(buffer, start, options);
	}
	else if (type === DATA_TYPE.DATA_VIEW) {
		result = __deserializeArrayBuffer(buffer, start, options);
		result.value = new DataView(result.value);
	}
	else if (type === DATA_TYPE.UINT8_ARRAY) {
		result = __deserializeArrayBuffer(buffer, start, options);
		result.value = new Uint8Array(result.value);
	}
	else if (type === DATA_TYPE.INT8_ARRAY) {
		result = __deserializeArrayBuffer(buffer, start, options);
		result.value = new Int8Array(result.value);
	}
	else if (type === DATA_TYPE.UINT16_ARRAY) {
		result = __deserializeArrayBuffer(buffer, start, options);
		result.value = new Uint16Array(result.value);
	}
	else if (type === DATA_TYPE.INT16_ARRAY) {
		result = __deserializeArrayBuffer(buffer, start, options);
		result.value = new Int16Array(result.value);
	}
	else if (type === DATA_TYPE.UINT32_ARRAY) {
		result = __deserializeArrayBuffer(buffer, start, options);
		result.value = new Uint32Array(result.value);
	}
	else if (type === DATA_TYPE.INT32_ARRAY) {
		result = __deserializeArrayBuffer(buffer, start, options);
		result.value = new Int32Array(result.value);
	}
	else if (type === DATA_TYPE.FLOAT32_ARRAY) {
		result = __deserializeArrayBuffer(buffer, start, options);
		result.value = new Float32Array(result.value);
	}
	else if (type === DATA_TYPE.FLOAT64_ARRAY) {
		result = __deserializeArrayBuffer(buffer, start, options);
		result.value = new Float64Array(result.value);
	}
	else if (type === DATA_TYPE.SPECIAL_BUFFER) {
		result = __deserializeArrayBuffer(buffer, start, options);
		result.value = HAS_NODE_BUFFER ? Buffer.from(result.value) : new Uint8Array(result.value);
	}
	
	return result;
}
7.
JCloudYu/beson · deserialize.esm.js
Match rating: 66.08% · See similar code snippets
javascript logo
function __deserializeInt8(buffer, start, options) {
	let end = start + 1;
	let dataView = new DataView(buffer);
	let data = dataView.getInt8(start);
	return { anchor: end, value:options.use_native_types ? data : Int8.from(data) };
}
8.
JCloudYu/beson · deserialize.esm.js
Match rating: 65.92% · See similar code snippets
javascript logo
function __deserializeBoolean(type, start, options) {
	let end = start;
	let data = type === DATA_TYPE.TRUE;
	return { anchor: end, value: data };
}
9.
JCloudYu/beson · deserialize.esm.js
Match rating: 65.62% · See similar code snippets
javascript logo
function __deserializeObjectId(buffer, start, options) {
	let step = 1;
	let length = 12;
	let end = start + length;
	let dataView = new DataView(buffer);
	let dataArray = [];
	for (let i = start; i < end; i += step) {
		dataArray.push(dataView.getUint8(i));
	}
	let data = new ObjectId(Uint8Array.from(dataArray).buffer);
	return { anchor: end, value: data };
}
10.
JCloudYu/beson · deserialize.esm.js
Match rating: 64.79% · See similar code snippets
javascript logo
function __deserializeFloat32(buffer, start, options) {
	let end = start + 4;
	let dataView = new DataView(buffer);
	let data = dataView.getFloat32(start, true);
	return { anchor: end, value: data };
}