@mapbox/frontend-util-maybe-add-period

A Mapbox frontend utility

Usage no npm install needed!

<script type="module">
  import mapboxFrontendUtilMaybeAddPeriod from 'https://cdn.skypack.dev/@mapbox/frontend-util-maybe-add-period';
</script>

README

@mapbox/frontend-util-maybe-add-period

Add a period to the end of a string if that string does not already end with sentence-ending punctuation.

Installation

npm install @mapbox/frontend-util-maybe-add-period

Usage

import maybeAddPeriod from '@mapbox/frontend-util-maybe-add-period';

maybeAddPeriod('Call the dentist'); // Call the dentist.
maybeAddPeriod('Call the dentist.'); // Call the dentist.
maybeAddPeriod('Call the dentist!'); // Call the dentist!
maybeAddPeriod('Call the dentist?'); // Call the dentist?