0.0.8 • Published 4 years ago

@pelevesque/is-palindrome v0.0.8

Weekly downloads
8
License
MIT
Repository
github
Last release
4 years ago

Build Status Coverage Status JavaScript Style Guide

is-palindrome

Checks if a string is a palindrome with a grouping feature not seen in other palindrome checkers.

Node Repository

https://www.npmjs.com/package/@pelevesque/is-palindrome

Installation

npm install @pelevesque/is-palindrome

Tests

CommandDescription
npm test or npm run testAll Tests Below
npm run coverStandard Style
npm run standardCoverage
npm run unitUnit Tests

Usage

Parameters

str                    (required)
groupBy                (optional) default = 1
pivotMustBePalindromic (optional) default = false

Examples

const isPalindrome = require('@pelevesque/is-palindrome')
// works with traditional palindromes
isPalindrome('')      // false
isPalindrome('12345') // false
isPalindrome('a')     // true
isPalindrome('1221')  // true
isPalindrome('12321') // true
// a groupBy parameter can be used to group elements
const groupBy = 2
isPalindrome('abba',  groupBy) // false
isPalindrome('abab',  groupBy) // true
isPalindrome('abcba', groupBy) // true

// pivots do not have to be palindromic by default
// they exist when a center point is smaller than groupBy * 2
const groupBy = 4
isPalindrome('abcd!@#$123!@#$abcd',   groupBy) // true
isPalindrome('abcd!@#$1234!@#$abcd',  groupBy) // true
isPalindrome('abcd!@#$12345!@#$abcd', groupBy) // true
isPalindrome('abcd!@#$12321!@#$abcd', groupBy) // true
// the pivotMustBePalindromic flag can be used to force palindromic pivots
const groupBy = 4
const pivotMustBePalindromic = true
isPalindrome('abcd!@#$12345!@#$abcd', groupBy, pivotMustBePalindromic) // false
isPalindrome('abcd!@#$12321!@#$abcd', groupBy, pivotMustBePalindromic) // true
0.0.8

4 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago