string-equal2

case sensitive string compare

Usage no npm install needed!

<script type="module">
  import stringEqual2 from 'https://cdn.skypack.dev/string-equal2';
</script>

README

string-equal

What is it?

'string-equal' It's a simple and very tiny library that allows compare two string with and without case sensitive.

Getting started

Installation

npm i string-equal

Importing

require('string-equal'); //commonJs
or
import('string-equal'); //ESM

Usage

console.log("Hello".equal("Hello")) // output: true
console.log("HELLO".equal("hello")) // output: false
console.log("HELLO".ignoreCaseEqual("hello")) // output: true

Available functions

I extended the String prototype to add a few functions to compare the strings.

String.ignoreCaseEqual(string)

Compare the strings ignoring case. It mean that if we compare "XX" with "xx" it will return TRUE.

console.log("HELLO".ignoreCaseEqual("hello")) // output: true

String.equal(string)

It recibe a string as a param, and it make a simple comparison using ===. It's case sensitive, it mean that if you are comparing "XX" against "xx" i will return FALSE.

console.log("xx".equal("xx")) // output: true
console.log("XX".equal("xx")) // output: false