CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-babel--plugin-transform-parameters

Babel plugin that compiles ES2015 default and rest parameters to ES5-compatible code

91

1.02x
Overview
Eval results
Files

task.mdevals/scenario-10/

Async Utilities Library

A library that provides utilities for working with asynchronous JavaScript operations.

Capabilities

Array async mapping

Create a utility function that maps an array through an async transformation.

  • When given an array [1, 2, 3] and an async mapper function that doubles each value, it returns [2, 4, 6] @test
  • When any promise in the chain rejects, the utility properly propagates the error @test

Async generator processing

Create a utility that collects values from an async generator.

  • When given an async generator yielding numbers 1-5, it collects all values into an array [1, 2, 3, 4, 5] @test
  • When the generator throws an error, the utility catches and re-throws it properly @test

Class-based async operations

Create a class that manages and executes async operations.

  • A class instance can queue multiple async operations and await their completion @test
  • The class properly handles errors from async operations @test

Implementation

@generates

API

/**
 * Maps an array of values through an async transformation function.
 *
 * @param {Array} items - Array of items to process
 * @param {Function} mapper - Async function to transform each item
 * @returns {Promise<Array>} Promise resolving to array of transformed items
 */
async function asyncMap(items, mapper) {
  // IMPLEMENTATION HERE
}

/**
 * Collects all values from an async generator into an array.
 *
 * @param {AsyncGenerator} generator - Async generator to collect from
 * @returns {Promise<Array>} Promise resolving to collected values
 */
async function collectAsync(generator) {
  // IMPLEMENTATION HERE
}

/**
 * Class that manages a queue of async operations.
 */
class AsyncQueue {
  constructor() {
    // IMPLEMENTATION HERE
  }

  /**
   * Adds an async operation to the queue.
   *
   * @param {Function} operation - Async function to execute
   * @returns {Promise} Promise that resolves when operation completes
   */
  async enqueue(operation) {
    // IMPLEMENTATION HERE
  }

  /**
   * Waits for all queued operations to complete.
   *
   * @returns {Promise<Array>} Promise resolving to array of results
   */
  async waitAll() {
    // IMPLEMENTATION HERE
  }
}

module.exports = {
  asyncMap,
  collectAsync,
  AsyncQueue,
};

Build Configuration

The library should be configured to use external runtime helpers to avoid code duplication when these utilities are used across multiple modules in a larger project. The build output should be optimized for production use with minimal helper code inlined.

Dependencies { .dependencies }

@babel/plugin-transform-runtime { .dependency }

Provides runtime helper externalization and optimization for transformed code.

@babel/runtime { .dependency }

Provides the runtime helper library referenced by transformed code.

Install with Tessl CLI

npx tessl i tessl/npm-babel--plugin-transform-parameters

tile.json