Coder Social home page Coder Social logo

huynhducduy / is-palindrome Goto Github PK

View Code? Open in Web Editor NEW
5.0 5.0 2.0 416 KB

Zero dependencies, lightweight and fully functional palindrome checker

Home Page: https://huynhducduy.me/is-palindrome/

License: MIT License

JavaScript 100.00%
palind palindrom palindrome palindrome-checker palindrome-date palindrome-number palindrome-string palindrome-validator palindromechecker palindromes

is-palindrome's Introduction

Hi, I'm Duy ๐Ÿ‘‹ @huynhducduy.me

Twitter: huynhducduy Linkedin: huynhducduy GitHub huynhducduy

A software engineer who is passionate about web technologies and open source. Innovative, task-driven, detail-oriented perfectionism with 5+ years of experience in web development. I'm also a self-proclaimed internet surfer ๐Ÿ„โ€. Always learning new things ๐Ÿ˜›

is-palindrome's People

Contributors

dependabot[bot] avatar fossabot avatar huynhducduy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

is-palindrome's Issues

Support multiple trimTrailling options

Is your feature request related to a problem? Please describe.
I want to trim multiple trailing strings of the input, which is now not supported

Describe the solution you'd like
Overload trimTrailing options to accept array of strings, and trim them in sequence.

options = {
    trimTrailing: ['a', 'ab', 'c'],
} 

Example

isPalindrome('aaaaabacccccababa', {trimTrailing: ['a', 'ab', 'c']}); // true
// after trim a: 'abacccccababa'
// after trim ab: 'abacccccaba'
// after trim c: 'abacaba'

Alternatives
This is a little bit advanced, but I may want to have mode support for continually trim when any of the string in the array can be matched.
Imagine that a trimming step can make another trailing string happened.

Example:

isPalindrome('abccccccabc', {trimTrailing: ['abc', 'c']})
// Check for trailing 'abc' in 'abccccccabc' but found no occur
// After trim 'c': abcabc
// The string after trim 'c' introduce a trailing 'abc'

Now with this mode we will have something like:

isPalindrome('abccccccabc', {trimTrailing: ['abc', 'c'], trimTrailingCon: true})
// Check for trailing 'abc' in 'abccccccabc' but not found
// After trim 'c': abcabc
// Again, check for trailing 'abc' in 'abcabc' and found, then trim: 'abc'
// Again, check for trailing 'abc' in 'abcabc' and found nothing
// All of the trailing string are not found, so we can stop the operation
// Output: 'abc'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.