Skip to content

msfragala/upprepa

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

upprepa

It means 'to repeat' in Swedish; it's not a very creative name, I know.

Usage

Repeat a string to your heart's content!

var upprepa = require('upprepa');
upprepa("naked babies", 5);
//=> naked babies naked babies naked babies naked babies naked babies

(wtf?)

Repeat a string, and pass in a delimiter to appear between each repetition!

var upprepa = require('upprepa');
upprepa("Hello", 5, "! ");
//=> Hello! Hello! Hello! Hello! Hello

Repeat a string, and pass a delimiters object to delimit how you want, when you want.

var upprepa = require('upprepa');
upprepa("dogs", 5, {
  def: ", ", //sets the default delimiter
  pre: "Yeah, ", //goes before the first repetition
  1: ", okay, ",
  4: " — I love ",
  post: ". Seriously!" //goes after the last repetition
});
//=> Yeah, dogs, okay, dogs, dogs, dogs — I love dogs. Seriously!

Oh, and you can also pass an array instead of a string, to perform an Array.prototype.join() with the delimiter control that upprepa offers.

var upprepa = require('upprepa');
var phrase = ["I", "love", "swimming"];
upprepa(phrase, 1, {
  def: ", um... ",
  post: "...?"  
});
//=> I, um... love, um... swimming...?

License

MIT © Mitchell Gates

About

Repeat a string - fast

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%