aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMarak <[email protected]>2014-09-21 08:41:06 +0200
committerMarak <[email protected]>2014-09-21 10:28:41 +0200
commit851b286d041c137bada54c8882cf3e024c43bb2d (patch)
tree2f374316c800826f0c99cfc9de40d8ff071a8de6 /lib
parent970be2ef22f1b5895f3880c5f54251b93fdf368a (diff)
downloadfaker-851b286d041c137bada54c8882cf3e024c43bb2d.tar.xz
faker-851b286d041c137bada54c8882cf3e024c43bb2d.zip
[api] Removed tree module. This code should be in a separate project.
Diffstat (limited to 'lib')
-rw-r--r--lib/tree.js73
1 files changed, 0 insertions, 73 deletions
diff --git a/lib/tree.js b/lib/tree.js
deleted file mode 100644
index 204d10f4..00000000
--- a/lib/tree.js
+++ /dev/null
@@ -1,73 +0,0 @@
-var faker = require('../index');
-
-var tree = {
-
- clone: function clone(obj) {
- if (obj == null || typeof(obj) != 'object')
- return obj;
-
- var temp = obj.constructor(); // changed
-
- for (var key in obj) {
- temp[key] = this.clone(obj[key]);
- }
- return temp;
- },
-
- createTree: function (depth, width, obj) {
- depth = depth || 0;
- width = width || 0;
- obj = obj || {};
-
- if (!obj) {
- throw {
- name: "ObjectError",
- message: "there needs to be an object passed in"
- };
- }
-
-
- if (width <= 0) {
- throw {
- name: "TreeParamError",
- message: "width must be greater than zero"
- };
- }
-
- var newObj = this.clone(obj);
-
- for (var prop in newObj) {
- if (newObj.hasOwnProperty(prop)) {
- var value = null;
- if (newObj[prop] !== "__RECURSE__") {
- value = eval(newObj[prop]);
- }
- else {
- if (depth !== 0) {
- value = [];
- var evalWidth = 1;
-
- if (typeof(width) == "function") {
- evalWidth = width();
- }
- else {
- evalWidth = width;
- }
-
- for (var i = 0; i < evalWidth; i++) {
- value.push(this.createTree(depth - 1, width, obj));
- }
-
- }
- }
-
- newObj[prop] = value;
- }
- }
-
- return newObj;
- }
-
-};
-
-module.exports = tree;