* Trims the . and .. from an array of path segments. * It will keep a leading path segment if a .. will become * the first path segment, to help with module name lookups, * which act like paths, but can be remapped. But the end result, * all paths that use this fu
(ary)
| 234 | * @param {Array} ary the array of path segments. |
| 235 | */ |
| 236 | function trimDots(ary) { |
| 237 | var i, part; |
| 238 | for (i = 0; i < ary.length; i++) { |
| 239 | part = ary[i]; |
| 240 | if (part === '.') { |
| 241 | ary.splice(i, 1); |
| 242 | i -= 1; |
| 243 | } else if (part === '..') { |
| 244 | // If at the start, or previous value is still .., |
| 245 | // keep them so that when converted to a path it may |
| 246 | // still work when converted to a path, even though |
| 247 | // as an ID it is less than ideal. In larger point |
| 248 | // releases, may be better to just kick out an error. |
| 249 | if (i === 0 || (i === 1 && ary[2] === '..') || ary[i - 1] === '..') { |
| 250 | continue; |
| 251 | } else if (i > 0) { |
| 252 | ary.splice(i - 1, 2); |
| 253 | i -= 2; |
| 254 | } |
| 255 | } |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | /** |
| 260 | * Given a relative module name, like ./something, normalize it to |
no outgoing calls
no test coverage detected
searching dependent graphs…