thai-typo-check
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -1,4 +0,7 @@ | ||
declare function thaiTypoCheck(inputText: string): boolean; | ||
declare function thaiTypoCheck( | ||
inputText: string, | ||
customWords?: string[] | ||
): boolean; | ||
declare namespace thaiTypoCheck {} | ||
export = thaiTypoCheck; |
@@ -19,3 +19,3 @@ const wordBreak = require("word-break-trie"); | ||
function thaiTypoCheck(inputText) { | ||
function thaiTypoCheck(inputText, customWords) { | ||
// skip if input is empty string, null, or undefined | ||
@@ -28,3 +28,5 @@ if (!inputText) return true; | ||
const dictArray = text.split("\n"); | ||
if (!!customWords) { | ||
dictArray.push(...customWords); | ||
} | ||
const longestWordLength = dictArray[0].length; | ||
@@ -31,0 +33,0 @@ const currentTrie = trie(dictArray); |
{ | ||
"name": "thai-typo-check", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "for check thai typo", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -11,7 +11,8 @@ # thai-typo-check | ||
test("thaiTypoCheck", () => { | ||
const wordBreakableInput = "ฉันอยากกินยำ"; | ||
const wordUnBreakableInput = "ฉันอยากกินผฟใก่ร์"; | ||
expect(thaiTypoCheck(wordBreakableInput)).toBe(true); | ||
expect(thaiTypoCheck(wordUnBreakableInput)).toBe(false); | ||
const goodSentence = "ฉันอยากกินยำ"; | ||
const typoSentence = "ฉันอยากกินผฟใก่ร์"; | ||
expect(thaiTypoCheck(goodSentence)).toBe(true); | ||
expect(thaiTypoCheck(typoSentence)).toBe(false); | ||
}); | ||
``` |
@@ -9,2 +9,6 @@ const thaiTypoCheck = require("."); | ||
it("should support custom words", () => { | ||
expect(thaiTypoCheck("ฉันอยากกินยำพัทยา", ["พัทยา"])).toBe(true); | ||
}); | ||
it("should return false when found typos", () => { | ||
@@ -11,0 +15,0 @@ expect(thaiTypoCheck("ฉนอยากกินยำ")).toBe(false); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
857551
64
18
1