or run

npx @tessl/cli init
Log in

Version

Files

docs

function-utilities.mdindex.mdlist-operations.mdmathematical-operations.mdobject-operations.mdstring-processing.md
tile.json

task.mdevals/scenario-8/

Order List Processing

A small utility module for cleaning and summarizing order records using list traversal and selection primitives.

Capabilities

Normalize order summaries

  • Converts each order into { id, total, itemCount, status, city } summaries, preserving input order and leaving the original array untouched. @test

Remove unusable records

  • Returns a new list without falsy entries or orders missing id, total, or status, keeping all other fields intact. @test

Split by minimum total

  • Splits orders into two lists: those with totals meeting or exceeding minTotal and all others, preserving intra-group order. @test

Find priority order

  • Finds the first order from the requested city whose status is "pending"; returns undefined if none match. @test

Implementation

@generates

API

/**
 * Produces summary objects for each order.
 * @param {Array<{ id: string, total: number, status: string, city: string, items: Array<unknown> }>} orders
 * @returns {Array<{ id: string, total: number, itemCount: number, status: string, city: string }>}
 */
export function normalizeOrders(orders);

/**
 * Removes unusable order entries.
 * @param {Array<unknown>} orders
 * @returns {Array<{ id: string, total: number, status: string, city?: string, items?: Array<unknown> }>}
 */
export function removeInvalidEntries(orders);

/**
 * Splits orders by a minimum total threshold.
 * @param {Array<{ id: string, total: number, status: string, city?: string, items?: Array<unknown> }>} orders
 * @param {number} minTotal
 * @returns {[Array<object>, Array<object>]}
 */
export function splitByMinimum(orders, minTotal);

/**
 * Finds the first pending order for a given city.
 * @param {Array<{ id: string, total: number, status: string, city: string }>} orders
 * @param {string} city
 * @returns {object | undefined}
 */
export function findPriorityOrder(orders, city);

Dependencies { .dependencies }

prelude-ls { .dependency }

Functional utilities for list iteration, filtering, partitioning, and selection.