Skip to content

Commit fe8bd37

Browse files
authored
Merge pull request #118 from scotttrinh/78-iteration-number
docs/test: Document and test iteration number
2 parents a0e968f + ffd1714 commit fe8bd37

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Iterate supports early exit by returning non `undefined` value inside `iteratorC
7878
Resulting value will be passed to the promise as the result of iteration.
7979
You can use this to make a search in your data:
8080
```js
81-
$localForage.iterate(function(value, key) {
81+
$localForage.iterate(function(value, key, iterationNumber) {
8282
if(angular.isInt(value) && value > 10) {
8383
return key;
8484
}

tests/angular-localForage.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,18 @@ describe('Module: LocalForageModule', function() {
150150
}, done);
151151
});
152152

153+
it('should have an iterationNumber with a 1-index', function(done) {
154+
var count;
155+
156+
$localForage.iterate(function(value, key, iterationNumber) {
157+
count = iterationNumber;
158+
}).then(function() {
159+
stopDigests(interval);
160+
expect(count).toEqual(3);
161+
done();
162+
}, done);
163+
})
164+
153165
it('key/value filter should work', function(done) {
154166
//test key filter
155167
$localForage.iterate(function(value, key) {

0 commit comments

Comments
 (0)