aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorcvega <[email protected]>2016-10-01 14:31:51 -0700
committercvega <[email protected]>2016-10-01 14:31:51 -0700
commitfc9d5351cd34d741538a364a31d22ae0c0f8101e (patch)
tree839ae9dd40324810ca15f94bd14829e427cba756 /lib
parent2ad5b70d4134e4b68a64d32cc3c9a9322ef6af9a (diff)
downloadfaker-fc9d5351cd34d741538a364a31d22ae0c0f8101e.tar.xz
faker-fc9d5351cd34d741538a364a31d22ae0c0f8101e.zip
[api] Added `internet.ipv6` method
* Returns a random 8 octet ipv6 address
Diffstat (limited to 'lib')
-rw-r--r--lib/internet.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/internet.js b/lib/internet.js
index 2d7ff530..4b0bfd8a 100644
--- a/lib/internet.js
+++ b/lib/internet.js
@@ -215,6 +215,32 @@ var Internet = function (faker) {
};
/**
+ * ipv6
+ *
+ * @method faker.internet.ipv6
+ */
+ self.ipv6 = function () {
+ var randHash = function () {
+ var result = "";
+ for (var i = 0; i < 4; i++) {
+ result += (faker.random.arrayElement(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"]));
+ }
+ return result
+ };
+
+ var result = [];
+ for (var i = 0; i < 8; i++) {
+ result[i] = randHash();
+ }
+ return result.join(":");
+ };
+
+ self.ipv6.schema = {
+ "description": "Generates a random IPv6 address.",
+ "sampleResults": ["2001:0db8:6276:b1a7:5213:22f1:25df:c8a0"]
+ };
+
+ /**
* userAgent
*
* @method faker.internet.userAgent