dat-palindrome-doe

1.0.1 • Public • Published

dat-palindrome-doe

determine if given string is a palindrome or not

configure the algorithm with custom options. the default configuration is this (merged with custom configs when provided)

const defaultConfig = {
 
  // first deal with special cases (assessed before validation of input)
  specialIs: value => value === 0 || value === '',
  specialIsNot: value => !value || value === true,
 
  // then validate input
  validateInput: value => typeof value === "string" || typeof value === "number",
 
  // algorithm functions
  filter: char => /^[a-z0-9]+$/i.test(char), // isAlphaNumeric
  compare: (a, b) => !!&& !!&& a.toLowerCase() === b.toLowerCase(), // leftEqualsRightWhenBothLowercase
  
}

usage with default configs

const isPalidrome = require('dat-palindrome-doe')()
console.log(isPalindrome('abcd_DCBA')) // true

usage with custom configs

const isPalidrome = require('dat-palindrome-doe')({
  compare: (a, b) => !!&& !!&& a === b // case-senstitive comparator
})
console.log(isPalindrome('abcd_DCBA')) // false

Readme

Keywords

none

Package Sidebar

Install

npm i dat-palindrome-doe

Weekly Downloads

2

Version

1.0.1

License

MIT

Last publish

Collaborators

  • btoo