| 145 | ///--- Helpers |
| 146 | |
| 147 | function cloneJob(job) { |
| 148 | if (typeof (job) === 'string') { |
| 149 | return ({phases: [{exec: job}]}); |
| 150 | } else if (Array.isArray(job)) { |
| 151 | return ({ |
| 152 | phases: job.map(function (j) { |
| 153 | if (typeof (j) === 'object') { |
| 154 | return (j); |
| 155 | } else if (typeof (j) === 'string') { |
| 156 | return ({ |
| 157 | exec: j |
| 158 | }); |
| 159 | } else { |
| 160 | throw new TypeError(util.inspect(j) + |
| 161 | ' invalid'); |
| 162 | } |
| 163 | }) |
| 164 | }); |
| 165 | } else if (typeof (job) === 'object') { |
| 166 | return (clone(job)); |
| 167 | } else { |
| 168 | throw new TypeError('job (object) required'); |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | /** |
| 173 | * HTTP Header names are case insensitive, so we ensure |