lib/iterator.js
function VersionIterable(task) {
        var _ref = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

        var name = _ref.name;
        var _ref$range = _ref.range;
        var range = _ref$range === undefined ? '*' : _ref$range;
        var _ref$dir = _ref.dir;
        var dir = _ref$dir === undefined ? '.' : _ref$dir;
        var _ref$restore = _ref.restore;
        var restore = _ref$restore === undefined ? true : _ref$restore;

        _classCallCheck(this, VersionIterable);

        _get(Object.getPrototypeOf(VersionIterable.prototype), 'constructor', this).call(this);
        if (typeof task !== 'function') throw new TypeError('expects task as a function');

        var versionFilter = typeof range === 'function' ? range : function (v) {
            return (0, _semver.satisfies)(v, range);
        };

        var _url$parse = _url2['default'].parse(name);

        var pathname = _url$parse.pathname;

        if (_path2['default'].extname(pathname) == '.git') {
            // check the name is kind of git repo url
            var repoName = _path2['default'].basename(pathname, '.git');
            this.name = repoName;
            this.source = makeGitSource(repoName, name, /* passing url */versionFilter, dir, restore);
            this.sourceName = 'git';
        } else {
            this.name = pathname;
            this.source = makeNPMPackageSource(pathname, versionFilter, dir, restore);
            this.sourceName = 'npm';
        }

        this.task = task;
    }
function VersionIterable(task) {
        var _ref = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

        var name = _ref.name;
        var _ref$range = _ref.range;
        var range = _ref$range === undefined ? '*' : _ref$range;
        var _ref$dir = _ref.dir;
        var dir = _ref$dir === undefined ? '.' : _ref$dir;
        var _ref$restore = _ref.restore;
        var restore = _ref$restore === undefined ? true : _ref$restore;

        _classCallCheck(this, VersionIterable);

        _get(Object.getPrototypeOf(VersionIterable.prototype), 'constructor', this).call(this);
        if (typeof task !== 'function') throw new TypeError('expects task as a function');

        var versionFilter = typeof range === 'function' ? range : function (v) {
            return (0, _semver.satisfies)(v, range);
        };

        var _url$parse = _url2['default'].parse(name);

        var pathname = _url$parse.pathname;

        if (_path2['default'].extname(pathname) == '.git') {
            // check the name is kind of git repo url
            var repoName = _path2['default'].basename(pathname, '.git');
            this.name = repoName;
            this.source = makeGitSource(repoName, name, /* passing url */versionFilter, dir, restore);
            this.sourceName = 'git';
        } else {
            this.name = pathname;
            this.source = makeNPMPackageSource(pathname, versionFilter, dir, restore);
            this.sourceName = 'npm';
        }

        this.task = task;
    }
function VersionIterable ( task ) { var _ref = arguments . length <= 1 || arguments [ 1 ] === undefined ? { } : arguments [ 1 ] ; var name = _ref . name ; var _ref$range = _ref . range ; var range = _ref$range === undefined ? '*' : _ref$range ; var _ref$dir = _ref . dir ; var dir = _ref$dir === undefined ? '.' : _ref$dir ; var _ref$restore = _ref . restore ; var restore = _ref$restore === undefined ? true : _ref$restore ; _classCallCheck ( this , VersionIterable ) ; _get ( Object . getPrototypeOf ( VersionIterable . prototype ) , 'constructor' , this ) . call ( this ) ; if ( typeof task !== 'function' ) throw new TypeError ( 'expects task as a function' ) ; var versionFilter = typeof range === 'function' ? range : function ( v ) { return ( 0 , _semver . satisfies ) ( v , range ) ; } ; var _url$parse = _url2 [ 'default' ] . parse ( name ) ; var pathname = _url$parse . pathname ; if ( _path2 [ 'default' ] . extname ( pathname ) == '.git' ) { // check the name is kind of git repo url var repoName = _path2 [ 'default' ] . basename ( pathname , '.git' ) ; this . name = repoName ; this . source = makeGitSource ( repoName , name , /* passing url */ versionFilter , dir , restore ) ; this . sourceName = 'git' ; } else { this . name = pathname ; this . source = makeNPMPackageSource ( pathname , versionFilter , dir , restore ) ; this . sourceName = 'npm' ; } this . task = task ; }
construct iterable published versions via npm

@param {Function} [task] ({name, version}) => {}
@param {Object} [opts]
@param {String} [opts.name] package name or git URL
@param {String|Function} [opts.range] iterating version ranges in semver format
or customized version filter
@param {String} [opts.dir] installing package directory
@public
construct iterable published versions via npm