Son CV dans un terminal web en Javascript!
https://terminal-cv.gregandev.fr
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
2.1 KiB
56 lines
2.1 KiB
'use strict';
|
|
var call = require('../internals/function-call');
|
|
var aCallable = require('../internals/a-callable');
|
|
var anObject = require('../internals/an-object');
|
|
var create = require('../internals/object-create');
|
|
var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
|
|
var redefineAll = require('../internals/redefine-all');
|
|
var wellKnownSymbol = require('../internals/well-known-symbol');
|
|
var InternalStateModule = require('../internals/internal-state');
|
|
var getMethod = require('../internals/get-method');
|
|
var IteratorPrototype = require('../internals/iterators-core').IteratorPrototype;
|
|
|
|
var setInternalState = InternalStateModule.set;
|
|
var getInternalState = InternalStateModule.get;
|
|
|
|
var TO_STRING_TAG = wellKnownSymbol('toStringTag');
|
|
|
|
module.exports = function (nextHandler, IS_ITERATOR) {
|
|
var IteratorProxy = function Iterator(state) {
|
|
state.next = aCallable(state.iterator.next);
|
|
state.done = false;
|
|
state.ignoreArg = !IS_ITERATOR;
|
|
setInternalState(this, state);
|
|
};
|
|
|
|
IteratorProxy.prototype = redefineAll(create(IteratorPrototype), {
|
|
next: function next(arg) {
|
|
var state = getInternalState(this);
|
|
var args = arguments.length ? [state.ignoreArg ? undefined : arg] : IS_ITERATOR ? [] : [undefined];
|
|
state.ignoreArg = false;
|
|
var result = state.done ? undefined : call(nextHandler, state, args);
|
|
return { done: state.done, value: result };
|
|
},
|
|
'return': function (value) {
|
|
var state = getInternalState(this);
|
|
var iterator = state.iterator;
|
|
state.done = true;
|
|
var $$return = getMethod(iterator, 'return');
|
|
return { done: true, value: $$return ? anObject(call($$return, iterator, value)).value : value };
|
|
},
|
|
'throw': function (value) {
|
|
var state = getInternalState(this);
|
|
var iterator = state.iterator;
|
|
state.done = true;
|
|
var $$throw = getMethod(iterator, 'throw');
|
|
if ($$throw) return call($$throw, iterator, value);
|
|
throw value;
|
|
}
|
|
});
|
|
|
|
if (!IS_ITERATOR) {
|
|
createNonEnumerableProperty(IteratorProxy.prototype, TO_STRING_TAG, 'Generator');
|
|
}
|
|
|
|
return IteratorProxy;
|
|
};
|
|
|