<commit_before>// Return the first not null-like value.
const coalesce = require('extant')

class Queue {
    constructor (turnstile, method, object) {
        this.turnstile = turnstile
        this._entry = { method, object: coalesce(object) }
    }

    push (value) {
        this.turnstile.enter({ ...this._entry, body: value })
    }

    enqueue (value, callback) {
        return new Promise(resolve => {
            this.turnstile.enter({
                method: (entry) => {
                    resolve(this._entry.method.call(this._entry.object, entry))
                },
                body: value
            })
        })
    }
}

module.exports = Queue<commit_msg>Nested method in `enqueue` needs to be `async`.<commit_after>// Return the first not null-like value.
const coalesce = require('extant')

class Queue {
    constructor (turnstile, method, object) {
        this.turnstile = turnstile
        this._entry = { method, object: coalesce(object) }
    }

    push (value) {
        this.turnstile.enter({ ...this._entry, body: value })
    }

    enqueue (value) {
        return new Promise(resolve => {
            this.turnstile.enter({
                method: async (entry) => {
                    resolve(await this._entry.method.call(this._entry.object, entry))
                },
                body: value
            })
        })
    }
}

module.exports = Queue
{'fraction_non_alphanumeric': 0.12303290414878398, 'fraction_numerical': 0.0, 'mean_word_length': 1.8092369477911647, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5536009', 'n_tokens_mistral': 414, 'n_tokens_neox': 398, 'n_words': 93}