mirror of
https://github.com/Polymer/polymer.git
synced 2026-08-17 16:34:49 -05:00
45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
/**
|
|
* DO NOT EDIT
|
|
*
|
|
* This file was automatically generated by
|
|
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
|
*
|
|
* To modify these typings, edit the source file(s):
|
|
* lib/utils/array-splice.js
|
|
*/
|
|
|
|
|
|
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
|
// tslint:disable:no-any describes the API as best we are able today
|
|
|
|
export {calculateSplices};
|
|
|
|
|
|
/**
|
|
* Returns an array of splice records indicating the minimum edits required
|
|
* to transform the `previous` array into the `current` array.
|
|
*
|
|
* Splice records are ordered by index and contain the following fields:
|
|
* - `index`: index where edit started
|
|
* - `removed`: array of removed items from this index
|
|
* - `addedCount`: number of items added at this index
|
|
*
|
|
* This function is based on the Levenshtein "minimum edit distance"
|
|
* algorithm. Note that updates are treated as removal followed by addition.
|
|
*
|
|
* The worst-case time complexity of this algorithm is `O(l * p)`
|
|
* l: The length of the current array
|
|
* p: The length of the previous array
|
|
*
|
|
* However, the worst-case complexity is reduced by an `O(n)` optimization
|
|
* to detect any shared prefix & suffix between the two arrays and only
|
|
* perform the more expensive minimum edit distance calculation over the
|
|
* non-shared portions of the arrays.
|
|
*
|
|
* @returns Returns an array of splice record objects. Each of these
|
|
* contains: `index` the location where the splice occurred; `removed`
|
|
* the array of removed items from this location; `addedCount` the number
|
|
* of items added at this location.
|
|
*/
|
|
declare function calculateSplices(current: any[], previous: any[]): any[];
|