plexis-js / plexis

Lo-fi, powerful, community-driven string manipulation library.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: `startsWith`

vorillaz opened this issue · comments

Checks whether the input text starts with the given pattern.

  @param {String} text
  @param {String|Regex} pattern
  @param {Number} startingPosition, optional

Example usage

import startsWith from '@plexis/starts-with';

startsWith('This is me', 'This is');
// => true

startsWith('This is me', 'his is', 1);
// => true

startsWith('This is me', 'is is', 2);
// => true

startsWith('This is me', 'This is', 1);
// => false
startsWith('This is me', 'This is', 0);
// => false

Wouldn't this be true? Starting from the index of 0 would make it functionally identical to the first example.

@brandon-m-skinner Shoo, you are right. The issue has been updated.