Skip to content

TiagoDanin/JFormat

Repository files navigation

JFormat

Node Version Downloads Travis

Python function str.format for JavaScript

Installation

Module available through the npm registry. It can be installed using the npm or yarn command line tools.

# NPM
npm install jformat --save
# Or Using Yarn
yarn add jformat

Example

"Forever {Python}".format({Python: "JavaScript"});
// "Forever JavaScript"

"Forever {0}".format(["JavaScript"]);
// "Forever JavaScript"

"Forever {Java}".format({}, true);
// "Forever "

format("Forever {Python}", {Python: "JavaScript"});
// "Forever JavaScript"

format("Forever {0}", ["JavaScript"]);
// "Forever JavaScript"

format("Forever {Java}", {}, true);
// "Forever "

Documentation

format(string, table, HideIfNull)

Options

  • string

Type: string

  • table

Type: array & object

  • HideIfNull

Type: boolean

Tests

To run the test suite, first install the dependencies, then run test:

# NPM
npm test
# Or Using Yarn
yarn test

Dependencies

None

Contributors

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue. List of all contributors.

License

MIT © TiagoDanin