A programming language that compiles into JavaScript, offering more concise and readable syntax while maintaining full JavaScript compatibility.
77
Build a utility module that compiles and evaluates CoffeeScript code featuring complex destructuring patterns. The module should provide functions that demonstrate and test CoffeeScript's destructuring capabilities, including nested structures, default values, rest operators, and object property aliasing.
[a, [b, c]] = [1, [2, 3]] and returns valid JavaScript @test[a, , c] = [1, 2, 3] and returns valid JavaScript @test{old: new} = {old: 'value'} and returns valid JavaScript @test{a: {b: c}} = {a: {b: 5}} and returns valid JavaScript @test[a = 10, b = 20] = [1] and returns valid JavaScript @test{x = 5, y = 10} = {x: 3} and returns valid JavaScript @test[first, rest...] = [1, 2, 3, 4] and returns valid JavaScript @test[{name}, {age}] = [{name: 'Alice'}, {age: 30}] and returns valid JavaScript @test@generates
/**
* Compiles CoffeeScript code to JavaScript
* @param {string} coffeeCode - The CoffeeScript code to compile
* @returns {string} The compiled JavaScript code
*/
function compileDestructuring(coffeeCode) {
// Implementation
}
/**
* Compiles and evaluates CoffeeScript code with destructuring
* @param {string} coffeeCode - The CoffeeScript code to compile and evaluate
* @returns {any} The result of evaluating the code
*/
function evalDestructuring(coffeeCode) {
// Implementation
}
module.exports = {
compileDestructuring,
evalDestructuring
};Provides CoffeeScript compilation and evaluation support, particularly for complex destructuring patterns.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-coffeescriptevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10