(predicate, reversed, suffix, earlyOut)
| 83 | * @returns {Search<T>} The compiled binary search function. |
| 84 | */ |
| 85 | const compileBoundsSearch = (predicate, reversed, suffix, earlyOut) => { |
| 86 | const arg1 = compileSearch("A", `x${predicate}y`, reversed, ["y"], earlyOut); |
| 87 | |
| 88 | const arg2 = compileSearch( |
| 89 | "P", |
| 90 | `c(x,y)${predicate}0`, |
| 91 | reversed, |
| 92 | ["y", "c"], |
| 93 | earlyOut |
| 94 | ); |
| 95 | |
| 96 | const fnHeader = "function dispatchBinarySearch"; |
| 97 | |
| 98 | const fnBody = |
| 99 | // eslint-disable-next-line no-multi-str |
| 100 | "(a,y,c,l,h){\ |
| 101 | if(typeof(c)==='function'){\ |
| 102 | return P(a,(l===void 0)?0:l|0,(h===void 0)?a.length-1:h|0,y,c)\ |
| 103 | }else{\ |
| 104 | return A(a,(c===void 0)?0:c|0,(l===void 0)?a.length-1:l|0,y)\ |
| 105 | }}\ |
| 106 | return dispatchBinarySearch"; |
| 107 | |
| 108 | const fnArgList = [arg1, arg2, fnHeader, suffix, fnBody, suffix]; |
| 109 | const fnSource = fnArgList.join(""); |
| 110 | // eslint-disable-next-line no-new-func |
| 111 | const result = new Function(fnSource); |
| 112 | return result(); |
| 113 | }; |
| 114 | |
| 115 | const fns = { |
| 116 | ge: compileBoundsSearch(">=", false, "GE"), |
no test coverage detected