mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 782231 - Implement DirectoryIterator.prototype.forEach. r=froydnj
This commit is contained in:
parent
811fd6492f
commit
544ba638fc
@ -201,6 +201,22 @@ AbstractFile.AbstractIterator.prototype = {
|
||||
*/
|
||||
__iterator__: function __iterator__() {
|
||||
return this;
|
||||
},
|
||||
/**
|
||||
* Apply a function to all elements of the directory sequentially.
|
||||
*
|
||||
* @param {Function} cb This function will be applied to all entries
|
||||
* of the directory. It receives as arguments
|
||||
* - the OS.File.Entry corresponding to the entry;
|
||||
* - the index of the entry in the enumeration;
|
||||
* - the iterator itself - calling |close| on the iterator stops
|
||||
* the loop.
|
||||
*/
|
||||
forEach: function forEach(cb) {
|
||||
let index = 0;
|
||||
for (let entry in this) {
|
||||
cb(entry, index++, this);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user