File "format.ts"

Full path: /home/fsibplc/public_html/sommilito-bank2/splide-4.1.3/src/js/utils/string/format/format.ts
File size: 441 B (441 B bytes)
MIME-type: text/x-java
Charset: utf-8

Download   Open   Edit   Advanced Editor   Back

import { forEach } from '../../array';


/**
 * Formats a string.
 *
 * @param string       - A string to format.
 * @param replacements - A replacement or replacements.
 *
 * @return A formatted string.
 */
export function format( string: string, replacements: string | number | Array<string | number> ): string {
  forEach( replacements, replacement => {
    string = string.replace( '%s', `${ replacement }` );
  } );

  return string;
}