UNPKG

siesta-lite

Version:

Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers

106 lines (77 loc) 3.38 kB
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>The source code</title> <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" /> <script type="text/javascript" src="../resources/prettify/prettify.js"></script> <style type="text/css"> .highlight { display: block; background-color: #ddd; } </style> <script type="text/javascript"> function highlight() { document.getElementById(location.hash.replace(/#/, "")).className = "highlight"; } </script> </head> <body onload="prettyPrint(); highlight();"> <pre class="prettyprint lang-js">/* Siesta 5.6.1 Copyright(c) 2009-2022 Bryntum AB https://bryntum.com/contact https://bryntum.com/products/siesta/license */ Class(&#39;Ariadne.QueryFinder.Combinator&#39;, { has : { elements : { required : true }, currentCombLen : null, combination : null }, methods : { forAllCombinations : function (func) { var elements = this.elements var elemLength = elements.length var combination = this.combination for (var combLen = combination ? combination.length : 1; combLen &lt;= elemLength; combLen++) { combination = this.forAllCombinationsOfLength(combLen, func, combination) this.combination = combination if (combination) return false } }, forAllCombinationsOfLength : function (combLen, func, combination) { var elements = this.elements var elemLength = elements.length if (combLen &gt; elemLength) return if (!combination) { combination = new Array(combLen) for (var i = 0; i &lt; combLen; i++) { combination[ i ] = { current : i, max : elemLength - combLen + i } } } if (combination.length != combLen) throw new Error(&quot;Wrong combination state&quot;) var shouldStop do { var collected = [] for (var k = 0; k &lt; combLen; k++) { collected.push(elements[ combination[ k ].current ]) } if (func(collected) === false) return combination shouldStop = true for (var i = combLen - 1; i &gt;= 0; i--) { var combAt = combination[ i ] if (combAt.current &lt; combAt.max) { combAt.current++ shouldStop = false for (var j = i + 1; j &lt; combLen; j++) { combination[ j ].current = combination[ j - 1 ].current + 1 } break } } } while (!shouldStop) } } }); </pre> </body> </html>