increment-last
TypeScript icon, indicating that this package has built-in type declarations

1.1.10 • Public • Published

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.

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i increment-last

      Weekly Downloads

      1

      Version

      1.1.10

      License

      MIT

      Unpacked Size

      4.09 kB

      Total Files

      5

      Last publish

      Collaborators

      • natqe3