<commit_before><link rel="import" href="../bower_components/polymer/polymer.html">
<dom-module id="gvisoc-timer">
    <template>
        <!-- local DOM for your element -->
        <p>{{value}}</p>
    </template>
    <script>
        Polymer({
            is: "gvisoc-timer",
            properties: {
                // Initial value for the timer to start from.
                initial: {
                    type: Number,
                    value: 0
                },
                // Value to reach.
                goal: {
                    type: Number,
                    value: 100
                },
                // Number of milliseconds between each value change.
                tick : {
                    type: Number,
                    value: 1000
                },
                // Direction of the counter. If <samp>growing</samp> is not present, then the timer goes towards lower values, otherwise if present. <span style="color:red">Defaults to false in oder to be validable</span> through observers.
                growing: {
                    type: Boolean,
                    value: false
                }
            },
            observers : [
                '_validateDeclaredProps(initial, goal, growing, tick)'
            ],
            /*This function validates the properties of the timer to prevent overflows. In detail:
                <ul>
                    <li><samp>goal</samp> and <samp>initial</samp> have to be different to prevent wasting browser resources</li>
                    <li><samp>growing</samp>, <samp>goal</samp> and <samp>initial</samp> have to be coherent: </li>
                    <ul>
                        <li>if <samp>growing</samp>, then <samp>goal</samp> has to be greater than <samp>initial</samp></li>
                        <li>if <samp>!growing</samp> then vice versa.</li>
                    </ul>
                </ul>
            */
            _validateDeclaredProps: function (initial, goal, growing, tick) {
                // TODO: test this function.
                var valid = true;
                if (tick <= 0) valid = false;
                if (growing && initial >= goal) valid = false;
                if (!growing && initial <= goal) valid = false;
                if(!valid) {
                    console.log("(gvisoc-timer) Validating: ",initial, goal, growing, tick, "; RESULT: ",valid);
                    // throw new Error("Misconfigurated (gvisoc-timer)"); // TODO: ellaborate errors - give fine grain
                    // JSON obj.
                    this.valid = false;
                }
            },
            // Timer implementation. Uses Polymer's <samp>this.async()</samp>.
            _counter: function () {
                // TODO: test this function.
                if (!this.valid)
                    return;
                if(this.growing)
                    this.value++;<commit_msg>Fixed component to follow best-practices (Failing silently is gold)<commit_after><link rel="import" href="../bower_components/polymer/polymer.html">
<dom-module id="gvisoc-timer">
    <template>
        <!-- local DOM for your element -->
        <p>{{value}}</p>
    </template>
    <script>
        Polymer({
            is: "gvisoc-timer",
            properties: {
                // Initial value for the timer to start from.
                initial: {
                    type: Number,
                    value: 0
                },
                // Value to reach.
                goal: {
                    type: Number,
                    value: 100
                },
                // Number of milliseconds between each value change.
                tick : {
                    type: Number,
                    value: 1000
                },
                // Direction of the counter. If <samp>growing</samp> is not present, then the timer goes towards lower values, otherwise if present. <span style="color:red">Defaults to false in oder to be validable</span> through observers.
                growing: {
                    type: Boolean,
                    value: false
                }
            },
            observers : [
                '_validateDeclaredProps(initial, goal, growing, tick)'
            ],
            /*This function validates the properties of the timer to prevent overflows. In detail:
                <ul>
                    <li><samp>goal</samp> and <samp>initial</samp> have to be different to prevent wasting browser resources</li>
                    <li><samp>growing</samp>, <samp>goal</samp> and <samp>initial</samp> have to be coherent: </li>
                    <ul>
                        <li>if <samp>growing</samp>, then <samp>goal</samp> has to be greater than <samp>initial</samp></li>
                        <li>if <samp>!growing</samp> then vice versa.</li>
                    </ul>
                </ul>
            */
            _validateDeclaredProps: function (initial, goal, growing, tick) {
                var valid = true;
                if (tick <= 0) valid = false;
                if (growing && initial >= goal) valid = false;
                if (!growing && initial <= goal) valid = false;
                if(!valid) {
                    console.log("(gvisoc-timer) Validating: ",initial, goal, growing, tick, "; RESULT: ",valid);
                    // Failing silently is golden (WebComponents best practices --see
                    // https://www.webcomponents.org/community/articles/web-components-best-practices)
                    this.valid = false;
                }
            },
            // Timer implementation. Uses Polymer's <samp>this.async()</samp>.
            _counter: function () {
                // TODO: test this function.
                if (!this.valid)
                    return;
                if(this.growing)
                    this.value++;
{'fraction_non_alphanumeric': 0.11135593220338984, 'fraction_numerical': 0.0030508474576271187, 'mean_word_length': 1.2626533742331287, 'pattern_counts': {'":': 0, '<': 95, '<?xml version=': 0, '>': 93, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, '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': '6913589', 'n_tokens_mistral': 1559, 'n_tokens_neox': 1401, 'n_words': 426}