<commit_before>"use strict";

const {PropTypes} = require("react");
const L = require("leaflet");
require("leaflet.markercluster");
const RL_MapLayer = require("react-leaflet").MapLayer;
const _ = require("underscore");
const shallowEqual = require("shallowequal");

const propTypes = {
    name: PropTypes.string.isRequired,
    data: PropTypes.arrayOf(
        PropTypes.shape({
            lat: PropTypes.number.isRequired,
            lng: PropTypes.number.isRequired
        }).isRequired
    ).isRequired
};

const defaultProps = {
    data: []
};

const markerIcon = L.icon({
    iconUrl: "https://asmaloney.com/wp-content/themes/asmaloney/maps_cluster/images/pin24.png",
    iconRetinaUrl: "https://asmaloney.com/wp-content/themes/asmaloney/maps_cluster/images/pin48.png",
    iconSize: [29, 24],
    iconAnchor: [9, 21],
    popupAnchor: [0, -14]
});

function datumToMarker(datum /*: object */) /*: L.Marker */ {
    const marker = L.marker([datum.lat, datum.lng], {icon: markerIcon}),
        popupHtml = datumToPopupHtml(datum);

    marker.bindPopup(popupHtml);
    return marker;
}

function datumToPopupHtml(datum /*: object */) /*: string */ {
    return Object.keys(datum).reduce((memo, key) => {
        if (key !== "lat" && key !== "lng") {
            return memo + `<br/><b>${key}:</b>  ${datum[key]}`;
        }
        else {
            return memo;
        }
    }, "");
}

class MarkerClusterGroupLayer extends RL_MapLayer {
    componentWillMount() {
        super.componentWillMount();
        this.leafletElement = L.markerClusterGroup();
    }

    componentDidMount() {
        super.componentDidMount();

        this.leafletElement.addLayers(
            this.props.data.map(d => datumToMarker(d))
        );
    }

    shouldComponentUpdate(nextProps /*: object */) /*: boolean */ {
        return !shallowEqual(
            _.pick(this.props, Object.keys(propTypes)),
            _.pick(nextProps, Object.keys(propTypes))
        );
    }
}

MarkerClusterGroupLayer.propTypes = propTypes;
MarkerClusterGroupLayer.defaultProps = defaultProps;

module.exports = MarkerClusterGroupLayer;
<commit_msg>in progress<commit_after>"use strict";

const {PropTypes} = require("react");
const L = require("leaflet");
require("leaflet.markercluster");
const RL_MapLayer = require("react-leaflet").MapLayer;
const _ = require("underscore");
const shallowEqual = require("shallowequal");

const propTypes = {
    name: PropTypes.string.isRequired,
    data: PropTypes.arrayOf(
        PropTypes.shape({
            lat: PropTypes.number.isRequired,
            lng: PropTypes.number.isRequired
        }).isRequired
    ).isRequired
};

const defaultProps = {
    data: []
};

const markerIcon = L.icon({
    iconUrl: "https://asmaloney.com/wp-content/themes/asmaloney/maps_cluster/images/pin24.png",
    iconRetinaUrl: "https://asmaloney.com/wp-content/themes/asmaloney/maps_cluster/images/pin48.png",
    iconSize: [29, 24],
    iconAnchor: [9, 21],
    popupAnchor: [0, -14]
});

function datumToMarker(datum /*: object */) /*: L.Marker */ {
    const marker = L.marker([datum.lat, datum.lng], {icon: markerIcon}),
        popupHtml = datumToPopupHtml(datum);

    return marker.bindPopup(popupHtml);
}

function datumToPopupHtml(datum /*: object */) /*: string */ {
    return Object.keys(datum).reduce((memo, key) => {
        if (key !== "lat" && key !== "lng") {
            return memo + `<br/><b>${key}:</b>  ${datum[key]}`;
        }
        else {
            return memo;
        }
    }, "");
}

class MarkerClusterGroupLayer extends RL_MapLayer {
    componentWillMount() {
        super.componentWillMount();
        this.leafletElement = L.markerClusterGroup();
    }

    componentDidMount() {
        super.componentDidMount();

        this.leafletElement.addLayers(
            this.props.data.map(d => datumToMarker(d))
        );
    }

    shouldComponentUpdate(nextProps /*: object */) /*: boolean */ {
        return !shallowEqual(
            _.pick(this.props, Object.keys(propTypes)),
            _.pick(nextProps, Object.keys(propTypes))
        );
    }
}

MarkerClusterGroupLayer.propTypes = propTypes;
MarkerClusterGroupLayer.defaultProps = defaultProps;

module.exports = MarkerClusterGroupLayer;

{'fraction_non_alphanumeric': 0.15176470588235294, 'fraction_numerical': 0.006588235294117647, 'mean_word_length': 2.9766136576239477, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 4, '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': '2118333', 'n_tokens_mistral': 1356, 'n_tokens_neox': 1333, 'n_words': 222}