Skip to content

Commit

Permalink
fix(localize): remove circural dependncies in files
Browse files Browse the repository at this point in the history
  • Loading branch information
smalluban committed May 4, 2022
1 parent 08d3412 commit 3d7353a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/localize.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { compileTemplate, getPlaceholder } from "./template/core.js";
import { compileTemplate } from "./template/core.js";
import { getPlaceholder } from "./template/utils.js";

import global from "./global.js";
import { probablyDevMode } from "./utils.js";
Expand Down
6 changes: 1 addition & 5 deletions src/template/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@ import global from "../global.js";
import { stringifyElement, probablyDevMode } from "../utils.js";
import { get as getMessage } from "../localize.js";

import { dataMap, removeTemplate } from "./utils.js";
import { dataMap, removeTemplate, getPlaceholder } from "./utils.js";

import resolveValue from "./resolvers/value.js";
import resolveProperty from "./resolvers/property.js";

const TIMESTAMP = Date.now();

export const getPlaceholder = (id = 0) => `H-${TIMESTAMP}-${id}`;

const PLACEHOLDER_REGEXP_TEXT = getPlaceholder("(\\d+)");
const PLACEHOLDER_REGEXP_EQUAL = new RegExp(`^${PLACEHOLDER_REGEXP_TEXT}$`);
const PLACEHOLDER_REGEXP_ALL = new RegExp(PLACEHOLDER_REGEXP_TEXT, "g");
Expand Down
3 changes: 2 additions & 1 deletion src/template/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { compileTemplate, getPlaceholder } from "./core.js";
import { compileTemplate } from "./core.js";
import { getPlaceholder } from "./utils.js";
import * as helpers from "./helpers.js";

const PLACEHOLDER = getPlaceholder();
Expand Down
3 changes: 3 additions & 0 deletions src/template/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ export function removeTemplate(target) {
}
}
}

const TIMESTAMP = Date.now();
export const getPlaceholder = (id = 0) => `H-${TIMESTAMP}-${id}`;

0 comments on commit 3d7353a

Please sign in to comment.