code: function dedot(path) { // eslint-disable-line complexity
    const inpath = `${ path }`;
    let outpath = '';
    const len = inpath.length;
  
    // Walk over segment by segment.
    // Accumulate output onto outpath.
  
    // i is the index past last sep considered.
    let i = 0;
    if (len && inpath[0] === sep) {
      outpath = sep;
      i = 1;
    }
    const rootLength = outpath.length;
  
    for (let nextSep; i < len; i = nextSep + 1) {
      nextSep = apply(indexOf, inpath, [ sep, i ]);
      if (nextSep < 0) {
        nextSep = len;
      }
      const segmentLen = nextSep - i;
      switch (segmentLen) {
        case 0:
          continue;
        case 1:
          if (inpath[i] === '.') {
            continue;
          }
          break;
        case 2:
          if (inpath[i] === '.' && inpath[i + 1] === '.') {
            const lastOutSep = apply(lastIndexOf, outpath, [ sep ]);
            outpath = apply(substring, outpath, [ 0, max(rootLength, lastOutSep) ]);
            continue;
          }
          break;
        default:
          break;
      }
      const segment = apply(substring, inpath, [ i, nextSep ]);
      outpath = outpath + (outpath.length > rootLength ? sep : '') + segment;
    }
  
    return outpath;
  }
docs: foo/./bar/..///baz -> foo/baz