https://github.com/rodribus/better-strings
npm module with string tweaks
https://github.com/rodribus/better-strings
Last synced: 11 months ago
JSON representation
npm module with string tweaks
- Host: GitHub
- URL: https://github.com/rodribus/better-strings
- Owner: RodriBus
- License: mit
- Created: 2016-02-08T19:32:11.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-02-11T20:21:36.000Z (over 10 years ago)
- Last Synced: 2025-03-24T08:55:35.751Z (over 1 year ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# better-strings
This module provides `String.format` C#-like function extending `String` object.
##Install
To install the module
```sh
$ npm install better-strings
```
##How to use
There are two ways of using this module.
###Using as string-object method
**String.format($0 [, $1, ..., $N])**
__Only__ takes *strings* and *numbers* as arguments.
```javascript
//Requiring the module enables the tweak
require('better-strings');
var result = 'Hello {0}!'.format('world');
console.log(result);
//produces 'Hello world!' output
```
###Using as module method
**betterString.format(baseString, $0 [, $1, ..., $N])**
__Only__ takes *strings* as firts argument, *strings* and *numbers* for the rest of them.
```javascript
//Requiring the module enables the string method anyway
var betterString = require('better-strings');
var result = betterString.format('Hello {0}!', 'world');
console.log(result);
//produces 'Hello world!' output
```
##Test
If you want to run the test, get the repository and run
```sh
$ npm install
$ npm test
```
##Why yet another 'string module'?
I have created this module as an exercise to learn about javascript, node, npm, gulp, unit test, and other dev-things involved in current development proccesses.