<commit_before>#
# Timber is a javascript game engine.
#
# It uses the following units for it's (very basic) physics
# calculations:
#
#   length = pixels
#   time   = ms
#


timber = {}

# Export timber to global scope.

root = this
root.timber = timber


#
# Utility functions.
#

timber.square = (n) ->
    return n * n



#
# The timber logger.
#

class timber.Logger

    # Create a timber logger.
    #
    # @param module {String} an identifier for the logger
    constructor : (module) ->
        @module = module

    _write : (level, message) ->
        console.log([level, @module, message].join(" | ")) if console

    # Log a message at the debug level.
    #
    # @param message {String} the message to log.
    debug : (message) ->
        @_write("DEBUG", message)

    # Log a message at the info level.
    #
    # @param message {String} the message to log.
    info : (message) ->
        @_write("INFO", message)


#
# The timber canvas.
#

class timber.Canvas

    # Create a timber canvas object.
    #
    # @param id: the id of the Canvas element.
    constructor : (id) ->
        @logger = new timber.Logger("timber.Canvas")
        @logger.debug("creating canvas with id #{id}")
        @id = id

        # Set-up the canvas.
        @canvas = document.getElementById(@id)
        throw new Error("No element with id: #{id}") if not @canvas

        @context = @canvas.getContext("2d")
        throw new Error("no context") if not @context<commit_msg>Private methods at the bottom of classes.<commit_after>#
# Timber is a javascript game engine.
#
# It uses the following units for it's (very basic) physics
# calculations:
#
#   length = pixels
#   time   = ms
#


timber = {}

# Export timber to global scope.

root = this
root.timber = timber


#
# Utility functions.
#

timber.square = (n) ->
    return n * n



#
# The timber logger.
#

class timber.Logger

    # Create a timber logger.
    #
    # @param module {String} an identifier for the logger
    constructor : (module) ->
        @module = module

    # Log a message at the debug level.
    #
    # @param message {String} the message to log.
    debug : (message) ->
        @_write("DEBUG", message)

    # Log a message at the info level.
    #
    # @param message {String} the message to log.
    info : (message) ->
        @_write("INFO", message)

    _write : (level, message) ->
        console.log([level, @module, message].join(" | ")) if console



#
# The timber canvas.
#

class timber.Canvas

    # Create a timber canvas object.
    #
    # @param id: the id of the Canvas element.
    constructor : (id) ->
        @logger = new timber.Logger("timber.Canvas")
        @logger.debug("creating canvas with id #{id}")
        @id = id

        # Set-up the canvas.
        @canvas = document.getElementById(@id)
        throw new Error("No element with id: #{id}") if not @canvas

        @context = @canvas.getContext("2d")
        throw new Error("no context") if not @context
{'fraction_non_alphanumeric': 0.12211441953830712, 'fraction_numerical': 0.0006691201070592171, 'mean_word_length': 2.3633295838020247, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '1410371', 'n_tokens_mistral': 944, 'n_tokens_neox': 896, 'n_words': 321}