{"size": 1240, "ext": "js", "max_stars_repo_path": "src/ZipLoadingManager.js", "max_stars_repo_name": "ruliusuifeng/THREE.ZipLoader", "max_stars_repo_stars_event_min_datetime": "2018-02-28T04:00:25.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-15T16:29:29.000Z", "max_issues_repo_path": "src/ZipLoadingManager.js", "max_issues_repo_name": "ruliusuifeng/THREE.ZipLoader", "max_issues_repo_issues_event_min_datetime": "2019-05-03T09:04:30.000Z", "max_issues_repo_issues_event_max_datetime": "2020-07-17T14:45:30.000Z", "max_forks_repo_path": "src/ZipLoadingManager.js", "max_forks_repo_name": "ruliusuifeng/THREE.ZipLoader", "max_forks_repo_forks_event_min_datetime": "2018-12-22T07:11:02.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-11T16:07:27.000Z"}
{"max_stars_count": 11, "max_issues_count": 4, "max_forks_count": 5, "avg_line_length": 20.0, "max_line_length": 112, "alphanum_fraction": 0.6161290323}
/**
 * @author Takahiro / https://github.com/takahirox
 */

function ZipLoadingManager( onLoad, onProgress, onError ) {

	THREE.LoadingManager.call( this, onLoad, onProgress, onError );

}

ZipLoadingManager.prototype = Object.assign( Object.create( THREE.LoadingManager.prototype ), {

	constructor: ZipLoadingManager

} );

ZipLoadingManager.uncompress = function ( url, exts, onLoad, onProgress, onError ) {

	var manager = new THREE.ZipLoadingManager( onLoad, onProgress, onError );

	if ( url.match( /\.zip$/ ) === null ) return Promise.resolve( { urls: [ url ], manager: manager } );

	if ( ! Array.isArray( exts ) ) exts = [ exts ];

	var str = '(';

	for ( var i = 0, il = exts.length; i < il; i ++ ) {

		if ( i > 0 ) str += '|';

		str += exts[ i ].replace( '.', '\\.' );

	}

	str += ')$';

	return new THREE.ZipLoader( manager ).load( url ).then( function ( zip ) {

		var files = zip.find( new RegExp( str, 'i' ) );

		if ( files.length === 0 ) {

			return Promise.reject( new Error( 'THREE.ZipLoadingManager: No ' + exts.join( ', ' ) + ' file in ' + url ) );

		}

		manager.setURLModifier( zip.urlResolver );

		return {

			urls: files,
			manager: manager

		};

	} ).catch( onError );

};


export { ZipLoadingManager };
