🤖 Merge PR #45029 [@types/backbone] [backbone-1.4] Add iterator methods to Backbone.Collection by @jakubadamw

This commit is contained in:
Jakub Wieczorek 2020-06-12 20:53:42 +02:00 committed by GitHub
parent a9afdd9eb6
commit b9418476d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -287,6 +287,14 @@ function test_collection() {
models = books.slice(1);
models = books.slice(1, 3);
let it1: Iterator<Book>;
it1 = books.values();
it1 = books[Symbol.iterator]();
let it2: Iterator<any>;
it2 = books.keys();
let it3: Iterator<[any, Book]>;
it3 = books.entries();
// underscore methods
bool = books.all((value: Book, index: number, list: Book[]) => true);
bool = books.any((value: Book, index: number, list: Book[]) => true);

View File

@ -376,6 +376,11 @@ declare namespace Backbone {
findWhere(properties: any): TModel;
modelId(attrs: any) : any
values(): Iterator<TModel>;
keys(): Iterator<any>;
entries(): Iterator<[any, TModel]>;
[Symbol.iterator](): Iterator<TModel>;
private _prepareModel(attributes?: any, options?: any): any;
private _removeReference(model: TModel): void;
private _onModelEvent(event: string, model: TModel, collection: Collection<TModel>, options: any): void;