- 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
61 lines
1.9 KiB
JavaScript
61 lines
1.9 KiB
JavaScript
var fs = require('fs'),
|
|
EventEmitter = require('events').EventEmitter,
|
|
util = require('util');
|
|
|
|
var readLine = module.exports = function(file, opts) {
|
|
if (!(this instanceof readLine)) return new readLine(file, opts);
|
|
|
|
EventEmitter.call(this);
|
|
opts = opts || {};
|
|
opts.maxLineLength = opts.maxLineLength || 4096; // 4K
|
|
opts.retainBuffer = !!opts.retainBuffer; //do not convert to String prior to invoking emit 'line' event
|
|
var self = this,
|
|
lineBuffer = new Buffer(opts.maxLineLength),
|
|
lineLength = 0,
|
|
lineCount = 0,
|
|
byteCount = 0,
|
|
emit = function(lineCount, byteCount) {
|
|
try {
|
|
var line = lineBuffer.slice(0, lineLength);
|
|
self.emit('line', opts.retainBuffer? line : line.toString(), lineCount, byteCount);
|
|
} catch (err) {
|
|
self.emit('error', err);
|
|
} finally {
|
|
lineLength = 0; // Empty buffer.
|
|
}
|
|
};
|
|
this.input = ('string' === typeof file) ? fs.createReadStream(file, opts) : file;
|
|
this.input.on('open', function(fd) {
|
|
self.emit('open', fd);
|
|
})
|
|
.on('data', function(data) {
|
|
for (var i = 0; i < data.length; i++) {
|
|
if (data[i] == 10 || data[i] == 13) { // Newline char was found.
|
|
if (data[i] == 10) {
|
|
lineCount++;
|
|
emit(lineCount, byteCount);
|
|
}
|
|
} else {
|
|
lineBuffer[lineLength] = data[i]; // Buffer new line data.
|
|
lineLength++;
|
|
}
|
|
byteCount++;
|
|
}
|
|
})
|
|
.on('error', function(err) {
|
|
self.emit('error', err);
|
|
})
|
|
.on('end', function() {
|
|
// Emit last line if anything left over since EOF won't trigger it.
|
|
if (lineLength) {
|
|
lineCount++;
|
|
emit(lineCount, byteCount);
|
|
}
|
|
self.emit('end');
|
|
})
|
|
.on('close', function() {
|
|
self.emit('close');
|
|
});
|
|
};
|
|
util.inherits(readLine, EventEmitter);
|