string-prepend
v0.1.2
Published
The unicorn String.prototype.prepend as a curried function.
Downloads
5
Maintainers
Readme
string-prepend
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