Ctrl + k

or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/lodash.unescape@4.0.x
tile.json

tessl/npm-lodash-unescape

tessl install tessl/npm-lodash-unescape@4.0.0

Converts HTML entities to their corresponding characters in a string

Agent Success

Agent success rate when using this tile

85%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.39x

Baseline

Agent success rate without this tile

61%

task.mdevals/scenario-7/

Product Analytics Aggregator

A utility for processing and organizing product analytics data from an e-commerce platform.

Requirements

Build a product analytics processing system that organizes product data in different ways for reporting purposes. The system should handle arrays of product objects and provide three different organization methods:

  1. Category Grouping: Organize products into groups based on their category
  2. Product Lookup: Create a fast lookup structure indexed by product ID
  3. Stock Partitioning: Separate products into two groups based on stock availability

Input Data Format

Products are represented as objects with the following properties:

  • id: Unique product identifier (string)
  • name: Product name (string)
  • category: Product category (string)
  • price: Price in dollars (number)
  • inStock: Stock availability (boolean)

Functionality

Organize by Category

Create a function organizeByCategory(products) that groups products by their category. The function should return an object where keys are category names and values are arrays of products in that category.

  • Products with the same category should be grouped together @test
  • The result should preserve all product properties @test
  • Empty input should return an empty object @test

Create Product Index

Create a function createProductIndex(products) that creates a lookup object indexed by product ID. The function should return an object where keys are product IDs and values are the corresponding product objects.

  • Each product should be accessible by its ID @test
  • The result should have exactly one entry per product @test

Separate by Stock Status

Create a function separateByStock(products) that divides products into two arrays: in-stock and out-of-stock. The function should return an array containing exactly two arrays: [inStockProducts, outOfStockProducts].

  • Products with inStock: true should be in the first array @test
  • Products with inStock: false should be in the second array @test
  • Both arrays should be present even if one is empty @test

Implementation

@generates

API

/**
 * Organizes products by their category.
 *
 * @param {Array} products - Array of product objects
 * @returns {Object} Object with categories as keys and arrays of products as values
 */
function organizeByCategory(products) {
  // Implementation
}

/**
 * Creates a product lookup index by product ID.
 *
 * @param {Array} products - Array of product objects
 * @returns {Object} Object with product IDs as keys and product objects as values
 */
function createProductIndex(products) {
  // Implementation
}

/**
 * Separates products into in-stock and out-of-stock groups.
 *
 * @param {Array} products - Array of product objects
 * @returns {Array} Two-element array: [inStockProducts, outOfStockProducts]
 */
function separateByStock(products) {
  // Implementation
}

module.exports = {
  organizeByCategory,
  createProductIndex,
  separateByStock
};

Dependencies { .dependencies }

lodash { .dependency }

Provides utility functions for data manipulation and collection operations.