- App.tsx: full navigation (Auth stack + Main tabs with 5 screens) - Auth: LoginScreen, RegisterScreen, ForgotPasswordScreen - HomeScreen: dashboard with IoT metrics, weather widget, alerts, quick actions, sensors - MapScreen: interactive map with layer toggles (6 layers) - MarketplaceScreen: categories (6), products (5), search - ChatScreen: AI chat with quick prompts (4), bot responses - ProfileScreen: user info, stats, menu (9 items), logout - AlertsScreen: alert list with severity, acknowledge - SensorsScreen: sensor list with type filters (6 types), search - ZonesScreen: zone cards with stats - SettingsScreen: language picker (FR/EN/ES/DE), privacy, about - Stores: iotStore (sensors, zones, alerts), notificationStore, uiStore + i18n - Hooks: useSensors, useAlerts, useNotifications, useLocation - Components: Card, Button, LoadingSpinner, ErrorBoundary, Header - Services: iotService, notificationService (with axios API client) - Utils: formatters (temp, AQI, noise, dates), validators (email, password, IBAN) - Theme: colors.ts with full design system (Blue Ocean palette) - Ditto: fixed MongoDB connection, new JWT secrets, official gateway image
68 lines
2.3 KiB
JavaScript
68 lines
2.3 KiB
JavaScript
'use strict';
|
|
|
|
var GetIntrinsic = require('get-intrinsic');
|
|
var callBound = require('call-bound');
|
|
|
|
var $RangeError = require('es-errors/range');
|
|
var $SyntaxError = require('es-errors/syntax');
|
|
var $TypeError = require('es-errors/type');
|
|
var $BigInt = GetIntrinsic('%BigInt%', true);
|
|
|
|
var hasOwnProperty = require('./HasOwnProperty');
|
|
var IsArray = require('./IsArray');
|
|
var IsBigIntElementType = require('./IsBigIntElementType');
|
|
var IsUnsignedElementType = require('./IsUnsignedElementType');
|
|
|
|
var bytesAsFloat32 = require('../helpers/bytesAsFloat32');
|
|
var bytesAsFloat64 = require('../helpers/bytesAsFloat64');
|
|
var bytesAsInteger = require('../helpers/bytesAsInteger');
|
|
var every = require('../helpers/every');
|
|
var isByteValue = require('../helpers/isByteValue');
|
|
|
|
var $reverse = callBound('Array.prototype.reverse');
|
|
var $slice = callBound('Array.prototype.slice');
|
|
|
|
var tableTAO = require('./tables/typed-array-objects');
|
|
|
|
// https://262.ecma-international.org/11.0/#sec-rawbytestonumeric
|
|
|
|
module.exports = function RawBytesToNumeric(type, rawBytes, isLittleEndian) {
|
|
if (typeof type !== 'string' || !hasOwnProperty(tableTAO.size, '$' + type)) {
|
|
throw new $TypeError('Assertion failed: `type` must be a TypedArray element type');
|
|
}
|
|
if (!IsArray(rawBytes) || !every(rawBytes, isByteValue)) {
|
|
throw new $TypeError('Assertion failed: `rawBytes` must be an Array of bytes');
|
|
}
|
|
if (typeof isLittleEndian !== 'boolean') {
|
|
throw new $TypeError('Assertion failed: `isLittleEndian` must be a Boolean');
|
|
}
|
|
|
|
var elementSize = tableTAO.size['$' + type]; // step 1
|
|
|
|
if (rawBytes.length !== elementSize) {
|
|
// this assertion is not in the spec, but it'd be an editorial error if it were ever violated
|
|
throw new $RangeError('Assertion failed: `rawBytes` must have a length of ' + elementSize + ' for type ' + type);
|
|
}
|
|
|
|
var isBigInt = IsBigIntElementType(type);
|
|
if (isBigInt && !$BigInt) {
|
|
throw new $SyntaxError('this environment does not support BigInts');
|
|
}
|
|
|
|
// eslint-disable-next-line no-param-reassign
|
|
rawBytes = $slice(rawBytes, 0, elementSize);
|
|
if (!isLittleEndian) {
|
|
$reverse(rawBytes); // step 2
|
|
}
|
|
|
|
if (type === 'Float32') { // step 3
|
|
return bytesAsFloat32(rawBytes);
|
|
}
|
|
|
|
if (type === 'Float64') { // step 4
|
|
return bytesAsFloat64(rawBytes);
|
|
}
|
|
|
|
return bytesAsInteger(rawBytes, elementSize, IsUnsignedElementType(type), isBigInt);
|
|
};
|