mathphreak / compare-ignoring-articles

Compare two strings while ignoring 'A' or 'The' at the beginning

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

compare-ignoring-articles Build Status

Compare two strings while ignoring 'A' or 'The' at the beginning

Install

$ npm install --save compare-ignoring-articles

Usage

const compareIgnoringArticles = require('compare-ignoring-articles');

compareIgnoringArticles('The Title', 'Title');
//=> 0

API

compareIgnoringArticles(str1, str2[, caseSensitive])

str1

Type: string

The first string to use.

str2

Type: string

The second string to use.

caseSensitive

Type: bool Default: true

Whether or not the comparison should be case sensitive.

Return

  • Negative when the str1 occurs before str2
  • Positive when the str1 occurs after str2
  • Returns 0 if they are equivalent

Note that this is the same as String#localeCompare, which this library uses once articles have been stripped.

License

MIT © Matt Horn

About

Compare two strings while ignoring 'A' or 'The' at the beginning

License:MIT License


Languages

Language:JavaScript 100.0%