increment-last

v1.1.10
Return string with the number in the end incremented
increment last increment-last last-increment

incrementLast

Return string with the number in the end incremented

Usage: incrementLast(str: string, defaultNum?: number): string

import { incrementLast } from 'increment-last'

incrementLast('name1')
// Output: "name2"
incrementLast('name01')
// Output: "name02"
incrementLast('name') // When the given string does not end with number, the default number is 2
// Output: "name2"
incrementLast('name', 5) // The second argument is the default number to use when the given string does not end with number
// Output: "name5"
incrementLast('name1', 5) // defaultNum has no effect in this case
// Output: "name2"

This module exported from utilizes project.

npm i increment-last

Metadata

  • MIT
  • Whatever
  • Natan Farkash
  • released 5/31/2021

Downloads

Maintainers