1
0
Fork 0
mirror of synced 2024-07-04 05:50:57 +12:00

Processors to esm

This commit is contained in:
Adria Navarro 2024-02-21 19:29:03 +01:00
parent e0873b359c
commit cdf251f9cc
3 changed files with 12 additions and 16 deletions

View file

@ -1,6 +1,6 @@
const { FIND_HBS_REGEX } = require("../utilities")
const preprocessor = require("./preprocessor")
const postprocessor = require("./postprocessor")
import { FIND_HBS_REGEX } from "../utilities"
import * as preprocessor from "./preprocessor"
import * as postprocessor from "./postprocessor"
function process(output, processors, opts) {
for (let processor of processors) {
@ -21,7 +21,7 @@ function process(output, processors, opts) {
return output
}
module.exports.preprocess = (string, opts) => {
export function preprocess(string, opts) {
let processors = preprocessor.processors
if (opts.noFinalise) {
processors = processors.filter(
@ -30,7 +30,7 @@ module.exports.preprocess = (string, opts) => {
}
return process(string, processors, opts)
}
module.exports.postprocess = string => {
export function postprocess(string) {
let processors = postprocessor.processors
return process(string, processors)
}

View file

@ -1,6 +1,6 @@
const { LITERAL_MARKER } = require("../helpers/constants")
import { LITERAL_MARKER } from "../helpers/constants"
const PostProcessorNames = {
export const PostProcessorNames = {
CONVERT_LITERALS: "convert-literals",
}
@ -16,9 +16,7 @@ class Postprocessor {
}
}
module.exports.PostProcessorNames = PostProcessorNames
module.exports.processors = [
export const processors = [
new Postprocessor(PostProcessorNames.CONVERT_LITERALS, statement => {
if (typeof statement !== "string" || !statement.includes(LITERAL_MARKER)) {
return statement

View file

@ -1,9 +1,9 @@
const { HelperNames } = require("../helpers")
const { swapStrings, isAlphaNumeric } = require("../utilities")
import { HelperNames } from "../helpers"
import { swapStrings, isAlphaNumeric } from "../utilities"
const FUNCTION_CASES = ["#", "else", "/"]
const PreprocessorNames = {
export const PreprocessorNames = {
SWAP_TO_DOT: "swap-to-dot-notation",
FIX_FUNCTIONS: "fix-functions",
FINALISE: "finalise",
@ -23,7 +23,7 @@ class Preprocessor {
}
}
module.exports.processors = [
export const processors = [
new Preprocessor(PreprocessorNames.SWAP_TO_DOT, statement => {
let startBraceIdx = statement.indexOf("[")
let lastIdx = 0
@ -74,5 +74,3 @@ module.exports.processors = [
return `{{ all ${insideStatement} }}`
}),
]
module.exports.PreprocessorNames = PreprocessorNames