wikimedia/mediawiki-extensions-Wikibase

View on GitHub
view/lib/wikibase-tainted-ref/src/ReferenceListChangeCounter.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { Reference } from '@/definitions/wikibase-js-datamodel/Reference';
import { ReferenceList } from '@/definitions/wikibase-js-datamodel/ReferenceList';

export default class ReferenceListChangeCounter {

    public countOldReferencesRemovedOrChanged( oldReferenceList: ReferenceList, newReferenceList: ReferenceList ):
    number {
        let diffRefCount = 0;
        oldReferenceList.each( ( _index: number, oldRef: Reference ) => {
            if ( !newReferenceList.hasItem( oldRef ) ) {
                diffRefCount++;
            }
        } );

        return diffRefCount;
    }

}