Skip to content

Commit bba464d

Browse files
committed
switching to esm
- dependencies updated - switching from nyc to c8 for coverage testing
1 parent 3e67e69 commit bba464d

21 files changed

+3571
-1076
lines changed

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ install:
1515
- npm --version
1616
# install modules
1717
- sh: npm ci
18-
- sh: npm install -g mocha nyc
18+
- sh: npm install -g mocha c8
1919

2020
before_test:
2121
# Download codeclimate test report
2222
- sh: curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./codeclimate-test-reporter
2323
- sh: chmod +x ./codeclimate-test-reporter
2424

2525
test_script:
26-
- nyc --reporter=lcov mocha --timeout 30000
26+
- c8 --reporter=lcov mocha --timeout 30000
2727

2828
after_test:
2929
# Send test result to codeclimate

index.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
"use strict";
2-
Object.defineProperty(exports, "__esModule", { value: true });
3-
exports.unleet = void 0;
4-
const diacritic = require("diacritic");
5-
const translations_1 = require("./translations/translations");
1+
import diacritic from "diacritic";
2+
import { leetSymbolTranslationKeys, simpleTranslations, complexTranslations } from "./translations/translations.js";
63
const indiciesOf = (sourceString, searchString) => {
74
const indicies = [];
85
for (let index = 0; index < sourceString.length - searchString.length; index += 1) {
@@ -19,7 +16,7 @@ const isLetter = (potentialLetter) => {
1916
return false;
2017
};
2118
const isPotentialLeet = (potentialLeetString) => {
22-
for (const leetSymbol of translations_1.leetSymbolTranslationKeys) {
19+
for (const leetSymbol of leetSymbolTranslationKeys) {
2320
if (isLetter(leetSymbol)) {
2421
continue;
2522
}
@@ -36,7 +33,7 @@ const unleetRecurse = (lowerCaseLeetString, unleetStrings, previousStrings, comp
3633
if (matchingIndicies.length === 0) {
3734
matchingIndicies = [lowerCaseLeetString.indexOf(leetSymbol)];
3835
}
39-
const translations = translations_1.complexTranslations[leetSymbol];
36+
const translations = complexTranslations[leetSymbol];
4037
for (const translation of translations) {
4138
for (const symbolIndex of matchingIndicies) {
4239
const newString = lowerCaseLeetString.substring(0, symbolIndex) +
@@ -55,22 +52,21 @@ const unleetRecurse = (lowerCaseLeetString, unleetStrings, previousStrings, comp
5552
}
5653
return unleetStrings;
5754
};
58-
const unleet = (leetString) => {
55+
export const unleet = (leetString) => {
5956
if (leetString === null || leetString === undefined || leetString === "") {
6057
return [""];
6158
}
6259
let cleanLeetString = (leetString + "").toLowerCase();
6360
cleanLeetString = cleanLeetString.replace(/\./g, " ");
6461
cleanLeetString = cleanLeetString.replace(/ +/g, " ");
6562
cleanLeetString = diacritic.clean(cleanLeetString);
66-
for (const leetSymbol of Object.keys(translations_1.simpleTranslations)) {
63+
for (const leetSymbol of Object.keys(simpleTranslations)) {
6764
while (cleanLeetString.includes(leetSymbol)) {
68-
cleanLeetString = cleanLeetString.replace(leetSymbol, translations_1.simpleTranslations[leetSymbol][0]);
65+
cleanLeetString = cleanLeetString.replace(leetSymbol, simpleTranslations[leetSymbol][0]);
6966
}
7067
}
71-
const complexTranslationKeys = Object.keys(translations_1.complexTranslations).filter(function (leetSymbol) {
68+
const complexTranslationKeys = Object.keys(complexTranslations).filter(function (leetSymbol) {
7269
return cleanLeetString.includes(leetSymbol);
7370
});
7471
return Array.from(unleetRecurse(cleanLeetString.trim(), new Set(), new Set(), complexTranslationKeys));
7572
};
76-
exports.unleet = unleet;

index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import * as diacritic from "diacritic";
1+
import diacritic from "diacritic";
22

3-
import { leetSymbolTranslationKeys, simpleTranslations, complexTranslations } from "./translations/translations";
3+
import { leetSymbolTranslationKeys, simpleTranslations, complexTranslations } from "./translations/translations.js";
44

55

66
const indiciesOf = (sourceString: string, searchString: string) => {

0 commit comments

Comments
 (0)