MCPcopy Index your code
hub / github.com/prettydiff/prettydiff / byType

Function byType

services.ts:3360–3424  ·  view source on GitHub ↗
(type:"directory"|"file"|"link")

Source from the content-addressed store, hash-verified

3358 }
3359 },
3360 byType = function node_apps_readmethod_resolve_stat_resolveItem_callbackDiff_byType(type:"directory"|"file"|"link"):void {
3361 let del:string[] = [],
3362 ins:string[] = [],
3363 aa:number = 0,
3364 dlen:number = del.length,
3365 ilen:number = ins.length;
3366 const formal = function node_apps_readmethod_resolve_stat_resolveItem_callbackDiff_byType_formal(arr:string[]):string {
3367 if (type === "directory") {
3368 if (arr.length === 1) {
3369 return "directory";
3370 }
3371 return "directories";
3372 }
3373 if (type === "file") {
3374 if (arr.length === 1) {
3375 return "file";
3376 }
3377 return "files";
3378 }
3379 if (arr.length === 1) {
3380 return "symbolic link";
3381 }
3382 return "symbolic links";
3383 };
3384 if (type !== "directory") {
3385 if (type === "file") {
3386 options.source = files.source;
3387 options.diff = files.diff;
3388 } else {
3389 options.source = links.source;
3390 options.diff = links.diff;
3391 }
3392 json = JSON.parse(prettydiff.api.diffview(options)[0]).diff;
3393 len = json.length;
3394 }
3395 if (len > 0) {
3396 do {
3397 if (json[aa][0] === "-") {
3398 del.push(json[aa][1]);
3399 } else if (json[aa][0] === "+") {
3400 ins.push(json[aa][1]);
3401 } else if (json[aa][0] === "r") {
3402 del.push(json[aa][1]);
3403 ins.push(json[aa][2]);
3404 }
3405 aa = aa + 1;
3406 } while (aa < len);
3407 }
3408 dlen = del.length;
3409 ilen = ins.length;
3410 output.push(`${dlen} ${formal(del)} ${text.angry}deleted${text.none}.`);
3411 if (dlen > 0) {
3412 del.forEach(function node_apps_readmethod_resolve_stat_resolveItem_callbackDiff_byType_delEach(value:string):void {
3413 output.push(` ${text.angry}*${text.none} ${value}`);
3414 });
3415 }
3416 output.push("");
3417 output.push(`${ilen} ${formal(ins)} ${text.green + text.bold}inserted${text.none}.`);

Callers 1

callback_diffFunction · 0.85

Calls 1

formalFunction · 0.85

Tested by

no test coverage detected