* Parse variadic arguments for pipeTo/pipeToSync. * Returns { transforms, writer, options }
(args)
| 127 | * Returns { transforms, writer, options } |
| 128 | */ |
| 129 | function parsePipeToArgs(args) { |
| 130 | if (args.length === 0) { |
| 131 | throw new TypeError('pipeTo requires a writer argument'); |
| 132 | } |
| 133 | var options; |
| 134 | var writerIndex = args.length - 1; |
| 135 | // Check if last arg is options |
| 136 | var last = args[args.length - 1]; |
| 137 | if ((0, utils_js_1.isPullOptions)(last) && !isWriter(last)) { |
| 138 | options = last; |
| 139 | writerIndex = args.length - 2; |
| 140 | } |
| 141 | if (writerIndex < 0) { |
| 142 | throw new TypeError('pipeTo requires a writer argument'); |
| 143 | } |
| 144 | var writer = args[writerIndex]; |
| 145 | if (!isWriter(writer)) { |
| 146 | throw new TypeError('pipeTo requires a writer argument with a write method'); |
| 147 | } |
| 148 | return { |
| 149 | transforms: args.slice(0, writerIndex), |
| 150 | writer: writer, |
| 151 | options: options, |
| 152 | }; |
| 153 | } |
| 154 | // ============================================================================= |
| 155 | // Transform Output Flattening |
| 156 | // ============================================================================= |
no test coverage detected