Convert backend code to ES modules

Bundling code now with Rollup for its flat bundling and tree shaking
support. Front end code still goes through Webpack for browser support.
This commit is contained in:
Zaid Abdulla committed 2019-02-04 23:47:54 -08:00
1 parent 824639976f
commit 1e41c72d60
62 files changed
+718 -898

No files matched your search

+15 -17
View File
@@ -32,7 +32,7 @@ function parseBool(v) {
else return null;
}
function sanitizeParameterValue(parameterValue) {
export function sanitizeParameterValue(parameterValue) {
if (parameterValue[0] != null) {
switch (parameterValue[1]) {
case "xsd:boolean":
@@ -83,8 +83,8 @@ function sanitizeParameterValue(parameterValue) {
return parameterValue;
}
function getAliasDeclarations(path, timestamp) {
var decs = [];
export function getAliasDeclarations(path, timestamp) {
const decs = [];
function recursive(p, prefix) {
const pattern = prefix.concat(p);
@@ -113,7 +113,7 @@ function getAliasDeclarations(path, timestamp) {
return decs;
}
function unpack(deviceData, path, revision) {
export function unpack(deviceData, path, revision) {
let allMatches = [];
if (!path.alias) {
for (const p of deviceData.paths.find(path, false, true))
@@ -194,7 +194,13 @@ function unpack(deviceData, path, revision) {
return allMatches;
}
function clear(deviceData, path, timestamp, attributes, changeFlags = 0) {
export function clear(
deviceData,
path,
timestamp,
attributes,
changeFlags = 0
) {
const changeTrackers = {};
timestamp = timestamp || 0;
@@ -254,7 +260,7 @@ function clear(deviceData, path, timestamp, attributes, changeFlags = 0) {
}
function compareEquality(a, b) {
var t = typeof a;
const t = typeof a;
if (
a === null ||
a === undefined ||
@@ -268,7 +274,7 @@ function compareEquality(a, b) {
return JSON.stringify(a) === JSON.stringify(b);
}
function set(deviceData, path, timestamp, attributes, toClear) {
export function set(deviceData, path, timestamp, attributes, toClear) {
path = deviceData.paths.add(path);
const currentTimestamp = deviceData.timestamps.get(path);
@@ -366,7 +372,7 @@ function set(deviceData, path, timestamp, attributes, toClear) {
return toClear;
}
function track(deviceData, path, marker, attributes) {
export function track(deviceData, path, marker, attributes) {
path = deviceData.paths.add(path);
let f = 1;
@@ -382,7 +388,7 @@ function track(deviceData, path, marker, attributes) {
cur[marker] |= f;
}
function clearTrackers(deviceData, tracker) {
export function clearTrackers(deviceData, tracker) {
if (Array.isArray(tracker)) {
for (const v of deviceData.trackers.values())
for (const t of tracker) delete v[t];
@@ -392,11 +398,3 @@ function clearTrackers(deviceData, tracker) {
deviceData.changes.delete(tracker);
}
}
exports.sanitizeParameterValue = sanitizeParameterValue;
exports.getAliasDeclarations = getAliasDeclarations;
exports.unpack = unpack;
exports.set = set;
exports.clear = clear;
exports.track = track;
exports.clearTrackers = clearTrackers;