<commit_before># BEAL file for Safari
#
# @author <NAME> (@bgotink)
# @license MIT

((module) ->
    exports = module.extension = {}

    # firefox does something weird with objects being sent through
    # i.e.: arrays have length undefined, prototype is _not_ correct etc
    clone = (e) ->
        if typeof e is 'object'
            Object.clone e, true
        else if typeof e is 'array'
            Array.clone e, true
        else
            e

    messageCallbacks = Object.extended {}
    messageCallbacks.nextId = 0

    exports.sendMessage = (message, callback) ->
        messageId = '' + ++messageCallbacks.nextId
        messageCallbacks[messageId] = callback

        self.port.emit 'iidentity-request-to-background',
            id: messageId
            message: message

    exports.addMessageListener = (func) ->
        self.port.on 'iidentity-request-from-background', func

    exports.getLastError = null

    exports.getURL = (rel) ->
        self.options.baseURI + rel

    exports.init = ->
        module.log.log 'Initializing IngressIdentity on %s', document.location.href

        self.port.on 'iidentity-answer-from-background', (message) ->
                callbackId = message.id

                return unless messageCallbacks.has callbackId

                if message.message?
                    messageCallbacks[callbackId] clone message.message

                delete messageCallbacks[callbackId]

)(iidentity or (iidentity = window.iidentity = {}))<commit_msg>[firefox] fixed nullpointer, document.location can be null apparently<commit_after># BEAL file for Safari
#
# @author <NAME> (@bgotink)
# @license MIT

((module) ->
    exports = module.extension = {}

    # firefox does something weird with objects being sent through
    # i.e.: arrays have length undefined, prototype is _not_ correct etc
    clone = (e) ->
        if typeof e is 'object'
            Object.clone e, true
        else if typeof e is 'array'
            Array.clone e, true
        else
            e

    messageCallbacks = Object.extended {}
    messageCallbacks.nextId = 0

    exports.sendMessage = (message, callback) ->
        messageId = '' + ++messageCallbacks.nextId
        messageCallbacks[messageId] = callback

        self.port.emit 'iidentity-request-to-background',
            id: messageId
            message: message

    exports.addMessageListener = (func) ->
        self.port.on 'iidentity-request-from-background', func

    exports.getLastError = null

    exports.getURL = (rel) ->
        self.options.baseURI + rel

    exports.init = ->
        self.port.on 'iidentity-answer-from-background', (message) ->
                callbackId = message.id

                return unless messageCallbacks.has callbackId

                if message.message?
                    messageCallbacks[callbackId] clone message.message

                delete messageCallbacks[callbackId]

)(iidentity or (iidentity = window.iidentity = {}))
{'fraction_non_alphanumeric': 0.0961344537815126, 'fraction_numerical': 0.0006722689075630252, 'mean_word_length': 2.2138228941684663, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '3384667', 'n_tokens_mistral': 814, 'n_tokens_neox': 771, 'n_words': 217}