MCPcopy Create free account
hub / github.com/kpdecker/jsdiff / diff

Method diff

src/diff/base.ts:54–75  ·  view source on GitHub ↗
(
    oldStr: InputValueT,
    newStr: InputValueT,
    // Type below is not accurate/complete - see above for full possibilities - but it compiles
    options: DiffCallbackNonabortable<ValueT> | AllDiffOptions & Partial<CallbackOptionNonabortable<ValueT>> = {}
  )

Source from the content-addressed store, hash-verified

52 options?: AllDiffOptions
53 ): ChangeObject<ValueT>[]
54 diff(
55 oldStr: InputValueT,
56 newStr: InputValueT,
57 // Type below is not accurate/complete - see above for full possibilities - but it compiles
58 options: DiffCallbackNonabortable<ValueT> | AllDiffOptions & Partial<CallbackOptionNonabortable<ValueT>> = {}
59 ): ChangeObject<ValueT>[] | undefined {
60 let callback: DiffCallbackAbortable<ValueT> | DiffCallbackNonabortable<ValueT> | undefined;
61 if (typeof options === 'function') {
62 callback = options;
63 options = {};
64 } else if ('callback' in options) {
65 callback = options.callback;
66 }
67 // Allow subclasses to massage the input prior to running
68 const oldString = this.castInput(oldStr, options);
69 const newString = this.castInput(newStr, options);
70
71 const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
72 const newTokens = this.removeEmpty(this.tokenize(newString, options));
73
74 return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
75 }
76
77 private diffWithOptionsObj(
78 oldTokens: TokenT[],

Callers 10

diffWordsFunction · 0.80
diffWordsWithSpaceFunction · 0.80
diffLinesFunction · 0.80
diffTrimmedLinesFunction · 0.80
diffArraysFunction · 0.80
diffJsonFunction · 0.80
diffSentencesFunction · 0.80
diffCssFunction · 0.80
diffCharsFunction · 0.80

Calls 4

castInputMethod · 0.95
removeEmptyMethod · 0.95
tokenizeMethod · 0.95
diffWithOptionsObjMethod · 0.95

Tested by

no test coverage detected