massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / core-js / modules / esnext.iterator.filter.js
1 'use strict';
2 // https://github.com/tc39/proposal-iterator-helpers
3 var $ = require('../internals/export');
4 var apply = require('../internals/function-apply');
5 var aCallable = require('../internals/a-callable');
6 var anObject = require('../internals/an-object');
7 var createIteratorProxy = require('../internals/iterator-create-proxy');
8 var callWithSafeIterationClosing = require('../internals/call-with-safe-iteration-closing');
9
10 var IteratorProxy = createIteratorProxy(function (args) {
11   var iterator = this.iterator;
12   var filterer = this.filterer;
13   var next = this.next;
14   var result, done, value;
15   while (true) {
16     result = anObject(apply(next, iterator, args));
17     done = this.done = !!result.done;
18     if (done) return;
19     value = result.value;
20     if (callWithSafeIterationClosing(iterator, filterer, value)) return value;
21   }
22 });
23
24 $({ target: 'Iterator', proto: true, real: true }, {
25   filter: function filter(filterer) {
26     return new IteratorProxy({
27       iterator: anObject(this),
28       filterer: aCallable(filterer)
29     });
30   }
31 });