MCPcopy Index your code
hub / github.com/unconed/TermKit / commonPrefix

Function commonPrefix

Node/shell/reader.js:418–436  ·  view source on GitHub ↗
(types)

Source from the content-addressed store, hash-verified

416 }
417
418 function commonPrefix(types) {
419 // Sort types, inspect first/last strings.
420 types.sort();
421 var first = types[0],
422 last = types[types.length - 1],
423 n = Math.min(first.length, last.length),
424 match = '';
425
426 // Find common prefix.
427 while (n > 0) {
428 last = last.substring(0, n--);
429 if (first.indexOf(last) == 0) {
430 match = last;
431 break;
432 }
433 }
434
435 return match;
436 }
437
438 var type = 'application/octed-stream';
439

Callers 1

reader.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected