0.0.9 • Published 1 year ago

@toluwap/complete-string v0.0.9

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Complete String

The completeString function is a JavaScript function that ensures a given string ends with a desired ending. If the string already ends with the desired ending, the function returns the original string. Otherwise, the function adds the missing characters to the end of the string.

import { completeString } from "@toluwap/complete-string"

const result = completeString(inputString, desiredEnding);

The completeString function takes two arguments:

inputString (string): The input string to be checked. desiredEnding (string): The desired ending that the input string should have. The function returns the original string with the desired ending appended, if necessary.

console.log(completeString("https://url.com", "/api/v4")); // output: https://url.com/api/v4

console.log(completeString("https://url.com/api", "/api/v4")); // output: https://url.com/api/v4

console.log(completeString("https://url.com/api/v4", "/api/v4")); // output: https://url.com/api/v4

test

$ npm test
0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago