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
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
const parsimmon = require("parsimmon");
|
||||
import parsimmon from "parsimmon";
|
||||
|
||||
// Turn escaped characters into real ones (e.g. "\\n" becomes "\n").
|
||||
function interpretEscapes(str) {
|
||||
@@ -22,7 +22,7 @@ function interpretEscapes(str) {
|
||||
});
|
||||
}
|
||||
|
||||
function map(exp, callback) {
|
||||
export function map(exp, callback) {
|
||||
if (!Array.isArray(exp)) return callback(exp);
|
||||
|
||||
let clone;
|
||||
@@ -271,12 +271,12 @@ const lang = parsimmon.createLanguage({
|
||||
}
|
||||
});
|
||||
|
||||
function parse(str) {
|
||||
export function parse(str) {
|
||||
if (!str) return null;
|
||||
return lang.Expression.tryParse(str);
|
||||
}
|
||||
|
||||
function stringify(exp, level = 0) {
|
||||
export function stringify(exp, level = 0) {
|
||||
if (!Array.isArray(exp)) return JSON.stringify(exp);
|
||||
|
||||
const opLevels = {
|
||||
@@ -360,7 +360,7 @@ function stringify(exp, level = 0) {
|
||||
}
|
||||
}
|
||||
|
||||
function parseLikePattern(pat, esc) {
|
||||
export function parseLikePattern(pat, esc) {
|
||||
const chars = pat.split("");
|
||||
|
||||
for (let i = 0; i < chars.length; ++i) {
|
||||
@@ -377,8 +377,3 @@ function parseLikePattern(pat, esc) {
|
||||
}
|
||||
return chars.filter(c => c);
|
||||
}
|
||||
|
||||
exports.parse = parse;
|
||||
exports.stringify = stringify;
|
||||
exports.map = map;
|
||||
exports.parseLikePattern = parseLikePattern;
|
||||
Reference in new issue
Block a user