string-prepend

The unicorn String.prototype.prepend as a curried function.

Usage no npm install needed!

<script type="module">
  import stringPrepend from 'https://cdn.skypack.dev/string-prepend';
</script>

README

string-prepend

Code Climate Build Status NPM version NPM downloads 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