compare-ignoring-articles

1.3.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i compare-ignoring-articles

Weekly Downloads

3

Version

1.3.0

License

MIT

Last publish

Collaborators

  • mathphreak