string-prepend
Version:
The unicorn String.prototype.prepend as a curried function.
43 lines (24 loc) • 1.48 kB
Markdown
# string-prepend
[](https://codeclimate.com/github/wilmoore/string-prepend.js) [](https://travis-ci.org/wilmoore/string-prepend.js) [](https://www.npmjs.org/package/string-prepend) [](https://www.npmjs.org/package/string-prepend) [](license)
> The unicorn String.prototype.prepend as a curried function.
$ npm install string-prepend --save
## API Examples & Inspiration
###### Require
var prepend = require('./');
###### Equivalent to str1 + str2
prepend("http://", "example.com");
//=> http://example.com
###### URL building
var paramName = prepend('http://');
var interests = ["example.com", "google.com", "yahoo.com"];
interests.map(paramName);
//=> [ 'http://example.com', 'http://google.com', 'http://yahoo.com' ]
###### Query params building
var paramName = prepend('interest[]=');
var interests = ["finance", "fitness", "health"];
var params = interests.map(paramName);
//=> [ 'interest[]=finance', 'interest[]=fitness', 'interest[]=health']
params.join('&');
//=> interest[]=finance&interest[]=fitness&interest[]=health
## License
[MIT](license)