@pinpin.link/string-format

1.0.0 • Public • Published

string-format

Javascript String format function polyfill

Usage

NPM:

npm install @pinpin.link/string-format

require('string-format');

CDN:

<script src=" https://raw.githubusercontent.com/PinPinLink/string-format/master/index.js"/>

Example:

var test = 'Hello, {0} and {1}';
test.format('Davie', 'Mary'); // return 'Hello, Davie and Mary'

test.format(['Davie', 'Mary']); // return 'Hello, Davie and Mary'

test.format({0: 'Davie', 1: 'Mary'}); // return 'Hello, Davie and Mary'

var test = 'Hello, {gender} {last-name}';
test.format({gender: 'Mr.', 'last-name': 'Solo'}); // return 'Hello, Mr. Solo'

License

This project is licensed under the Apache License 2.0 - see the file for details

Package Sidebar

Install

npm i @pinpin.link/string-format

Weekly Downloads

0

Version

1.0.0

License

Apache-2.0

Unpacked Size

13.6 kB

Total Files

4

Last publish

Collaborators

  • vincent7128