DiffString:
Filter:
Steno/Classes (extension) | Little Languages

DiffString
ExtensionExtension

A parser for differences in strings

Description

A wrapper for the unix diff command line program.

NOTE: Sometimes, the commandline program fails for unknown reasons. DiffString throws an error before it calls any function then.

Class Methods

.new

Arguments:

insertFunc

Specify what to do when a new element is inserted in the result. As arguments are passed: newToken, index, oldToken.

removeFunc

Specify what to do when an element is removed. As arguments are passed: oldToken, index.

swapFunc

Specify what to do when an element is replaced by a new one. As arguments are passed: newToken, index, oldToken.

keepFunc

Specify what to do when an element is kept as it was. As arguments are passed: oldToken, index.

beginFunc

Specify what to do before the string is compared. As arguments are passed: oldToken, index.

returnFunc

Specify what to return from diff.value As arguments are passed the result of the functions for each line as an array.

testFunc

A global test functions that is called before calling any of the above (apart from beginFunc and returnFunc). As arguments are passed: index, operator, oldToken, newToken.

Instance Methods

.parse

Compare two arrays of tokens. A token can be a String or anything that can be converted to a string consistently (e.g. Char, Symbol, Integer, but also an Array of these).

Arguments:

newTokens, oldTokens

Examples