UNPKG

@bacnet-js/device

Version:

A TypeScript library for implementing BACnet IP devices in Node.js.

31 lines 1.21 kB
import bacnet, { ApplicationTag } from '@bacnet-js/client'; const { default: BACnetClient } = bacnet; /** * Ensures that a value or array of values is returned as an array * * @param val - A single value or array of values * @returns An array containing the input value(s) * @typeParam T - The type of the values */ export const ensureArray = (val) => { return Array.isArray(val) ? val : [val]; }; /** * Start date of the process. */ export const PROCESS_START_DATE = new Date(); /** * Standard time zone offset local to the computer running this code. */ export const STD_TZ_OFFSET = Math.max(new Date(PROCESS_START_DATE.getFullYear(), 0, 1).getTimezoneOffset(), new Date(PROCESS_START_DATE.getFullYear(), 6, 1).getTimezoneOffset()); /** * Returns whether daylight saving time is in effect for a given date, * relative to the local time zone of the computer running this code. */ export const isDstInEffect = (date) => { return date.getTimezoneOffset() < STD_TZ_OFFSET; }; export const isNumericApplicationTag = (tag) => { return tag === ApplicationTag.REAL || tag === ApplicationTag.SIGNED_INTEGER || tag === ApplicationTag.UNSIGNED_INTEGER; }; //# sourceMappingURL=utils.js.map