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:
1 parent
824639976f
commit
1e41c72d60
62 files changed
+718
-898
No files matched your search
+7
-13
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const common = require("./common");
|
||||
import * as common from "./common";
|
||||
|
||||
function stringToRegexp(input, flags) {
|
||||
if (input.indexOf("*") === -1) return false;
|
||||
@@ -53,7 +53,7 @@ function normalize(input) {
|
||||
return input;
|
||||
}
|
||||
|
||||
function expandValue(value) {
|
||||
export function expandValue(value) {
|
||||
if (common.typeOf(value) === common.ARRAY_TYPE) {
|
||||
let a = [];
|
||||
for (const j of value) a = a.conact(expandValue(j));
|
||||
@@ -104,7 +104,7 @@ function permute(param, val) {
|
||||
return conditions;
|
||||
}
|
||||
|
||||
function expand(query) {
|
||||
export function expand(query) {
|
||||
const newQuery = {};
|
||||
for (const [k, v] of Object.entries(query)) {
|
||||
if (k[0] === "$") {
|
||||
@@ -157,7 +157,7 @@ function testExpressions(params, expressions, lop) {
|
||||
}
|
||||
}
|
||||
|
||||
function test(params, query) {
|
||||
export function test(params, query) {
|
||||
let res;
|
||||
for (const [k, v] of Object.entries(query)) {
|
||||
if (k.charAt(0) === "$") {
|
||||
@@ -233,7 +233,7 @@ function matchType(src, dst) {
|
||||
return dst;
|
||||
}
|
||||
|
||||
function testFilter(obj, filter) {
|
||||
export function testFilter(obj, filter) {
|
||||
for (const [k, v] of Object.entries(filter)) {
|
||||
const [param, op] = k.split(/([^a-zA-Z0-9\-_.].*)/, 2);
|
||||
const val = matchType(obj[param], v);
|
||||
@@ -264,7 +264,7 @@ function testFilter(obj, filter) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function convertMongoQueryToFilters(query, filters) {
|
||||
export function convertMongoQueryToFilters(query, filters) {
|
||||
filters = filters || {};
|
||||
for (let [k, v] of Object.entries(query)) {
|
||||
if (k[0] === "$") {
|
||||
@@ -346,7 +346,7 @@ function convertMongoQueryToFilters(query, filters) {
|
||||
return filters;
|
||||
}
|
||||
|
||||
function sanitizeQueryTypes(query, types) {
|
||||
export function sanitizeQueryTypes(query, types) {
|
||||
for (const [k, v] of Object.entries(query)) {
|
||||
if (k[0] === "$") {
|
||||
// Logical operator
|
||||
@@ -383,9 +383,3 @@ function sanitizeQueryTypes(query, types) {
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
exports.expand = expand;
|
||||
exports.test = test;
|
||||
exports.sanitizeQueryTypes = sanitizeQueryTypes;
|
||||
exports.convertMongoQueryToFilters = convertMongoQueryToFilters;
|
||||
exports.testFilter = testFilter;
|
||||
Reference in new issue
Block a user