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 -31
View File
@@ -18,19 +18,19 @@
*/
"use strict";
const UNDEFINED_TYPE = "[object Undefined]";
const NULL_TYPE = "[object Null]";
const BOOLEAN_TYPE = "[object Boolean]";
const NUMBER_TYPE = "[object Number]";
const STRING_TYPE = "[object String]";
const ARRAY_TYPE = "[object Array]";
const OBJECT_TYPE = "[object Object]";
const REGEXP_TYPE = "[object RegExp]";
const DATE_TYPE = "[object Date]";
export const UNDEFINED_TYPE = "[object Undefined]";
export const NULL_TYPE = "[object Null]";
export const BOOLEAN_TYPE = "[object Boolean]";
export const NUMBER_TYPE = "[object Number]";
export const STRING_TYPE = "[object String]";
export const ARRAY_TYPE = "[object Array]";
export const OBJECT_TYPE = "[object Object]";
export const REGEXP_TYPE = "[object RegExp]";
export const DATE_TYPE = "[object Date]";
const typeOf = obj => Object.prototype.toString.call(obj);
export const typeOf = obj => Object.prototype.toString.call(obj);
function generateDeviceId(deviceIdStruct) {
export function generateDeviceId(deviceIdStruct) {
// Escapes everything except alphanumerics and underscore
function esc(str) {
return str.replace(/[^A-Za-z0-9_]/g, chr => {
@@ -54,7 +54,7 @@ function generateDeviceId(deviceIdStruct) {
return esc(deviceIdStruct["OUI"]) + "-" + esc(deviceIdStruct["SerialNumber"]);
}
function parseAlias(pattern, start, res) {
export function parseAlias(pattern, start, res) {
const aliases = [];
let i = start;
while (i < pattern.length && pattern[i] !== "]") {
@@ -126,7 +126,7 @@ function parseAlias(pattern, start, res) {
return i;
}
function parsePath(pattern, start, res) {
export function parsePath(pattern, start, res) {
const path = [];
path.wildcard = 0;
path.alias = 0;
@@ -163,7 +163,7 @@ function parsePath(pattern, start, res) {
return i;
}
function addPathMeta(path) {
export function addPathMeta(path) {
if (path.alias != null && path.wildcard != null) return path;
path.alias = 0;
@@ -183,22 +183,6 @@ function addPathMeta(path) {
}
// Source: http://stackoverflow.com/a/6969486
function escapeRegExp(str) {
export function escapeRegExp(str) {
return str.replace(/[-[\]/{}()*+?.\\^$|]/g, "\\$&");
}
exports.UNDEFINED_TYPE = UNDEFINED_TYPE;
exports.NULL_TYPE = NULL_TYPE;
exports.BOOLEAN_TYPE = BOOLEAN_TYPE;
exports.NUMBER_TYPE = NUMBER_TYPE;
exports.STRING_TYPE = STRING_TYPE;
exports.ARRAY_TYPE = ARRAY_TYPE;
exports.OBJECT_TYPE = OBJECT_TYPE;
exports.DATE_TYPE = DATE_TYPE;
exports.REGEXP_TYPE = REGEXP_TYPE;
exports.typeOf = typeOf;
exports.generateDeviceId = generateDeviceId;
exports.parsePath = parsePath;
exports.addPathMeta = addPathMeta;
exports.escapeRegExp = escapeRegExp;