source: imaps-frontend/node_modules/core-js/modules/esnext.observable.from.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.3 KB
Line 
1'use strict';
2var $ = require('../internals/export');
3var getBuiltIn = require('../internals/get-built-in');
4var call = require('../internals/function-call');
5var anObject = require('../internals/an-object');
6var isConstructor = require('../internals/is-constructor');
7var getIterator = require('../internals/get-iterator');
8var getMethod = require('../internals/get-method');
9var iterate = require('../internals/iterate');
10var wellKnownSymbol = require('../internals/well-known-symbol');
11
12var $$OBSERVABLE = wellKnownSymbol('observable');
13
14// `Observable.from` method
15// https://github.com/tc39/proposal-observable
16$({ target: 'Observable', stat: true, forced: true }, {
17 from: function from(x) {
18 var C = isConstructor(this) ? this : getBuiltIn('Observable');
19 var observableMethod = getMethod(anObject(x), $$OBSERVABLE);
20 if (observableMethod) {
21 var observable = anObject(call(observableMethod, x));
22 return observable.constructor === C ? observable : new C(function (observer) {
23 return observable.subscribe(observer);
24 });
25 }
26 var iterator = getIterator(x);
27 return new C(function (observer) {
28 iterate(iterator, function (it, stop) {
29 observer.next(it);
30 if (observer.closed) return stop();
31 }, { IS_ITERATOR: true, INTERRUPTED: true });
32 observer.complete();
33 });
34 }
35});
Note: See TracBrowser for help on using the repository browser.