aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Mandula <[email protected]>2016-06-13 22:21:47 +0200
committerJakub Mandula <[email protected]>2016-06-13 22:21:47 +0200
commitd6c20353360ef1eefb56128eeb50ece4f5845372 (patch)
tree165e9d78781bed646a8d59ccf1930d5d75a9775a
parentd355d412a9c91ab13343737f30036a4194da2623 (diff)
downloadfaker-d6c20353360ef1eefb56128eeb50ece4f5845372.tar.xz
faker-d6c20353360ef1eefb56128eeb50ece4f5845372.zip
add String.prototype.repeat in older versions of node - see PR #382
-rw-r--r--lib/helpers.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/helpers.js b/lib/helpers.js
index 832732f5..c7957e08 100644
--- a/lib/helpers.js
+++ b/lib/helpers.js
@@ -1,3 +1,18 @@
+/** Define the String.prototype.repeat if it is not implemented.... See PR #382
+*/
+if(typeof String.prototype.repeat === "undefined") {
+ String.prototype.repeat = function(num) {
+ if(typeof num ==="undefined") {
+ num = 0;
+ }
+ var text = "";
+ for(var i = 0; i < num; i++){
+ text += this.toString();
+ }
+ return text;
+ };
+}
+
/**
*
* @namespace faker.helpers