From 044cd84e60e677592f57441ecbc25cd274379dbd Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Tue, 22 Jul 2014 10:23:32 -0700 Subject: [PATCH] Add route.fullGestalt function --- route.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/route.js b/route.js index b30e7d5..895427c 100644 --- a/route.js +++ b/route.js @@ -1254,6 +1254,21 @@ function Routing(exports) { var emptyGestalt = new Gestalt([]); + // Not quite what it says on the tin - the true fullGestalt + // wouldn't be parameterized on the number of levels and + // metalevels, but instead would be full at *all* levels and + // metalevels. Our representation leaks through into the interface + // here :-/ + function fullGestalt(nMetalevels, nLevels) { + var matcher = compilePattern(true, __); + var l = new GestaltLevel(matcher, matcher); + var levels = []; + while (nLevels--) { levels.push(l); } + var metaLevels = []; + while (nMetalevels--) { metaLevels.push(levels); } + return new Gestalt(metaLevels); + } + Gestalt.prototype.isEmpty = function () { for (var i = 0; i < this.metaLevels.length; i++) { var levels = this.metaLevels[i]; @@ -1503,6 +1518,7 @@ function Routing(exports) { exports.Gestalt = Gestalt; exports.simpleGestalt = simpleGestalt; exports.emptyGestalt = emptyGestalt; + exports.fullGestalt = fullGestalt; exports.gestaltUnion = gestaltUnion; exports.deserializeGestalt = deserializeGestalt; }