<commit_before>const ee = require('sepal/ee')
const {map, of, switchMap} = require('rxjs')

const asset = ({id}, _bands) => {
    return {
        getImage$() {
            const mosaicCollection = () => {
                const collection = ee.ImageCollection(id)
                return ee.Image(
                    collection
                        .mosaic()
                        .copyProperties(collection, collection.propertyNames())
                ).clip(collection.geometry().bounds())
            }
            return ee.getAsset$(id, 0).pipe(
                map(({type}) => {
                    switch(type) {
                    case 'Image': return ee.Image(id)
                    case 'ImageCollection': return mosaicCollection()
                    default: throw Error(`Asset expected to be an Image or ImageCollection, was ${type}`)
                    }
                })
            )
        },
        getBands$() {
            return this.getImage$().pipe(
                switchMap(image =>
                    ee.getInfo$(image.bandNames(), 'asset band names')
                )
            )
        },
        getVisParams$() {
            return of({})
        },
        getGeometry$() {
            return this.getImage$().pipe(
                map(image => image.geometry())
            )
        }
    }
}

module.exports = asset<commit_msg>Fixed loading of bands and geometry of asset.<commit_after>const ee = require('sepal/ee')
const {map, of, switchMap} = require('rxjs')

const asset = ({id}, _bands) => {
    const getImage$ = () => {
        const mosaicCollection = () => {
            const collection = ee.ImageCollection(id)
            return ee.Image(
                collection
                    .mosaic()
                    .copyProperties(collection, collection.propertyNames())
            ).clip(collection.geometry().bounds())
        }
        return ee.getAsset$(id, 0).pipe(
            map(({type}) => {
                switch(type) {
                case 'Image': return ee.Image(id)
                case 'ImageCollection': return mosaicCollection()
                default: throw Error(`Asset expected to be an Image or ImageCollection, was ${type}`)
                }
            })
        )
    }
    return {
        getImage$,
        getBands$() {
            return getImage$().pipe(
                switchMap(image =>
                    ee.getInfo$(image.bandNames(), 'asset band names')
                )
            )
        },
        getVisParams$() {
            return of({})
        },
        getGeometry$() {
            return getImage$().pipe(
                map(image => image.geometry())
            )
        }
    }
}

module.exports = asset
{'fraction_non_alphanumeric': 0.12481698389458272, 'fraction_numerical': 0.0007320644216691069, 'mean_word_length': 1.308277027027027, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1658399', 'n_tokens_mistral': 715, 'n_tokens_neox': 671, 'n_words': 146}