diff options
| author | Jay Liu <[email protected]> | 2013-11-05 17:46:31 -0700 |
|---|---|---|
| committer | Jay Liu <[email protected]> | 2013-11-05 17:46:31 -0700 |
| commit | b17d651e90aaef0416fb632844b46dfcdb6c46f2 (patch) | |
| tree | 507acb065e0bb746bf6f13bd5cd3767a3ea6236b /examples/js | |
| parent | b89d44ba279d5dff3da831e5e3fda3af049b8a21 (diff) | |
| download | faker-b17d651e90aaef0416fb632844b46dfcdb6c46f2.tar.xz faker-b17d651e90aaef0416fb632844b46dfcdb6c46f2.zip | |
Update build with Tree module supporting width function
Diffstat (limited to 'examples/js')
| -rw-r--r-- | examples/js/Faker.js | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/examples/js/Faker.js b/examples/js/Faker.js index 1df2b6a8..24687384 100644 --- a/examples/js/Faker.js +++ b/examples/js/Faker.js @@ -17,7 +17,7 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************** AUTOGENERATED @ 1383696373283 *************** +/*************** AUTOGENERATED @ 1383698745803 *************** WARNING: THIS FILE WAS AUTOGENERATED BY THE FAKER BUILD SCRIPT MODIFYING THIS FILE IS FINE, BUT YOU REALLY SHOULD BE MODIFYING THE LIBRARY DIRECTLY AND REGENERATING THIS FILE USING BUILD.js!!!! @@ -415,6 +415,7 @@ Faker.Tree.createTree = function (depth, width, obj) { }; } + if (width <= 0) { throw { name: "TreeParamError", @@ -436,9 +437,19 @@ Faker.Tree.createTree = function (depth, width, obj) { else { if (depth !== 0) { value = []; - for (var i = 0; i < width; i++) { + 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)); } + } } |
