(
graphs: any,
paths: any,
callback: ICallback
)
| 105 | * to create a sortable priority hash. |
| 106 | */ |
| 107 | export function getPriority( |
| 108 | graphs: any, |
| 109 | paths: any, |
| 110 | callback: ICallback |
| 111 | ): string { |
| 112 | let callbacks: ICallback[] = [callback]; |
| 113 | const touchedOutputs: {[key: string]: boolean} = {}; |
| 114 | const touchedCbIds: {[key: string]: boolean} = {}; |
| 115 | const priority: number[] = []; |
| 116 | |
| 117 | while (callbacks.length) { |
| 118 | callbacks = filter(c => { |
| 119 | const touched = touchedCbIds[c.resolvedId]; |
| 120 | touchedCbIds[c.resolvedId] = true; |
| 121 | return touched; |
| 122 | }, callbacks); |
| 123 | |
| 124 | const outputs = filter( |
| 125 | o => !touchedOutputs[combineIdAndProp(o)], |
| 126 | flatten(map(cb => flatten(cb.getOutputs(paths)), callbacks)) |
| 127 | ); |
| 128 | |
| 129 | outputs.forEach(o => (touchedOutputs[combineIdAndProp(o)] = true)); |
| 130 | |
| 131 | callbacks = flatten( |
| 132 | map( |
| 133 | ({id, property}: any) => |
| 134 | getCallbacksByInput( |
| 135 | graphs, |
| 136 | paths, |
| 137 | id, |
| 138 | property, |
| 139 | INDIRECT, |
| 140 | false |
| 141 | ), |
| 142 | outputs |
| 143 | ) |
| 144 | ); |
| 145 | |
| 146 | if (callbacks.length) { |
| 147 | priority.push(callbacks.length); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | priority.unshift(priority.length); |
| 152 | |
| 153 | return map(i => Math.min(i, 35).toString(36), priority).join(''); |
| 154 | } |
| 155 | |
| 156 | export function getAllSubsequentOutputsForCallback( |
| 157 | graphs: any, |
no test coverage detected
searching dependent graphs…