@corefunc/corefunc
Advanced tools
Comparing version 0.0.20 to 0.0.21
@@ -61,3 +61,3 @@ { | ||
}, | ||
"version": "0.0.20" | ||
"version": "0.0.21" | ||
} |
@@ -1,25 +0,29 @@ | ||
import fnLowerCase from "lodash-es/lowerCase"; | ||
import fnToString from "lodash-es/toString"; | ||
import castToString from "../cast/to/string"; | ||
import stringClearReferences from "./clearReferences"; | ||
/** | ||
* Compare two strings | ||
* @param {string} stringFirst | ||
* @param {string} stringSecond | ||
* @param {string} first | ||
* @param {string} second | ||
* @param {boolean} isStrict | ||
* @returns {boolean} | ||
*/ | ||
function compare(stringFirst, stringSecond, isStrict = false) { | ||
let stringOne = fnToString(stringFirst); | ||
let stringTwo = fnToString(stringSecond); | ||
export default function stringCompare(first: string, second: string, isStrict: boolean = false): boolean { | ||
let stringOne = castToString(first).normalize(); | ||
let stringTwo = castToString(second).normalize(); | ||
if (stringOne.length !== stringTwo.length) { | ||
stringClearReferences(stringOne); | ||
stringClearReferences(stringTwo); | ||
return false; | ||
} | ||
if (isStrict) { | ||
return stringOne.localeCompare(stringTwo) === 0; | ||
const isSame = stringOne.localeCompare(stringTwo) === 0; | ||
stringClearReferences(stringOne); | ||
stringClearReferences(stringTwo); | ||
return isSame; | ||
} | ||
stringOne = fnLowerCase(stringOne); | ||
stringTwo = fnLowerCase(stringTwo); | ||
return stringOne === stringTwo; | ||
const isSame = stringOne.toLowerCase().localeCompare(stringTwo.toLowerCase()) === 0; | ||
stringClearReferences(stringOne); | ||
stringClearReferences(stringTwo); | ||
return isSame; | ||
} | ||
export default compare; |
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
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
108288
288
3694