CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/npm-coffeescript

tessl install tessl/npm-coffeescript@2.7.0

A programming language that compiles into JavaScript, offering more concise and readable syntax while maintaining full JavaScript compatibility.

Agent Success

Agent success rate when using this tile

77%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.01x

Baseline

Agent success rate without this tile

76%

task.mdevals/scenario-10/

Dynamic Configuration Loader

Build a dynamic configuration loader that executes CoffeeScript configuration files at runtime and evaluates configuration expressions in a sandboxed environment.

Requirements

Create a configuration loader with the following capabilities:

Configuration File Execution

Implement a function that loads and executes CoffeeScript configuration files. The configuration files should:

  • Be executed with proper file context (filename and directory information)
  • Return configuration objects that can be accessed by the caller
  • Support module-style exports

Expression Evaluation

Implement a function that evaluates CoffeeScript expressions in a controlled sandbox environment. The evaluator should:

  • Accept a CoffeeScript expression string and a context object
  • Execute the expression with the provided context variables available
  • Return the result of the evaluated expression
  • Isolate execution to prevent access to global scope

Error Handling

Both functions should handle errors appropriately:

  • Invalid CoffeeScript syntax should be caught and reported
  • Runtime errors during execution should be caught with meaningful messages
  • File not found errors should be handled gracefully

Test Cases

  • Loading a configuration file that exports an object with nested properties returns the correct configuration @test
  • Evaluating a simple arithmetic expression with context variables returns the correct result @test
  • Evaluating an expression that references sandbox context variables works correctly @test
  • Invalid CoffeeScript syntax in evaluation throws an appropriate error @test

@generates

API

/**
 * Loads and executes a CoffeeScript configuration file
 * @param {string} filepath - Path to the CoffeeScript file
 * @returns {any} The exported value from the configuration file
 * @throws {Error} If file cannot be loaded or contains invalid syntax
 */
function loadConfig(filepath) {
  // Implementation here
}

/**
 * Evaluates a CoffeeScript expression in a sandboxed environment
 * @param {string} expression - CoffeeScript expression to evaluate
 * @param {Object} context - Context object with variables to make available
 * @returns {any} Result of the evaluated expression
 * @throws {Error} If expression contains invalid syntax or runtime errors occur
 */
function evalExpression(expression, context) {
  // Implementation here
}

module.exports = {
  loadConfig,
  evalExpression
};

Dependencies { .dependencies }

coffeescript { .dependency }

Provides CoffeeScript compilation and execution capabilities.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/coffeescript@2.7.x
tile.json