<commit_before>'use strict';

import $ from 'jquery';

export default class ImageLoader {

    constructor(dataSrcAttr) {
        this.dataSrcAttr = dataSrcAttr || 'data-preload-src';
    }

    isInlineImage($el) {
        return $el.is('img');
    }

    getDataSrc($el) {
        return $el.attr(this.dataSrcAttr);
    }

    setInlineImageSrc($el, src) {
        $el.attr('src', src);
    }

    setBackgroundImageUrl($el, src) {
        var val = `url(${src})`;
        $el.css({'background-image': val});
    }

    setSrc($el, src) {
        if (this.isInlineImage($el)) {
            this.setInlineImageSrc($el, src);
        }
        else {
            this.setBackgroundImageUrl($el, src);
        }
    }

    load($image) {
        return new Promise((resolve, reject) => {
            var img = new Image(),
                src = this.getDataSrc($image);

            img.src = src;

            img.addEventListener('load', () => {
                this.setSrc($image, src);
                resolve($image);
            });

            img.addEventListener('error', () => {<commit_msg>Use ternary operator in image loader method<commit_after>'use strict';

import $ from 'jquery';

export default class ImageLoader {

    constructor(dataSrcAttr) {
        this.dataSrcAttr = dataSrcAttr || 'data-preload-src';
    }

    isInlineImage($el) {
        return $el.is('img');
    }

    getDataSrc($el) {
        return $el.attr(this.dataSrcAttr);
    }

    setInlineImageSrc($el, src) {
        $el.attr('src', src);
    }

    setBackgroundImageUrl($el, src) {
        var val = `url(${src})`;
        $el.css({'background-image': val});
    }

    setSrc($el, src) {
        return this.isInlineImage($el) ?
            this.setInlineImageSrc($el, src) :
            this.setBackgroundImageUrl($el, src);
    }

    load($image) {
        return new Promise((resolve, reject) => {
            var img = new Image(),
                src = this.getDataSrc($image);

            img.src = src;

            img.addEventListener('load', () => {
                this.setSrc($image, src);
                resolve($image);
            });

            img.addEventListener('error', () => {
{'fraction_non_alphanumeric': 0.15423111919927207, 'fraction_numerical': 0.0, 'mean_word_length': 1.8858267716535433, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '6597949', 'n_tokens_mistral': 675, 'n_tokens_neox': 657, 'n_words': 119}