CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-lodash-kebabcase

The lodash method kebabCase exported as a standalone Node.js module for converting strings to kebab-case format

Overall
score

68%

Evaluation68%

1.08x

Agent success when using this tile

Overview
Eval results
Files

task.mdevals/scenario-6/

Configurable Rule Filter

Build a utility that turns concise rule definitions into reusable predicates for filtering and projecting catalog entries.

Capabilities

Build predicates from rule definitions

  • For the string rule "status.active", the predicate returns true for { status: { active: true } } and false for { status: { active: 0 } }. @test
  • For the object rule { region: "us", tags: ["sale"] }, the predicate passes { region: "us", tags: ["sale", "fresh"] } and fails { region: "us", tags: ["new"] }. @test
  • For the tuple rule ["score.primary", 90], the predicate returns true for { score: { primary: 90 } } and false for { score: { primary: 80 } }. @test
  • When the rule is already a function such as (item) => item.source === "trusted", the returned predicate is that exact function reference and is invoked without extra wrapping. @test

Combine predicates into a rule set

  • Combining ["score.primary", 90] and { region: "us" } with mode "any" accepts { score: { primary: 90 }, region: "ca" }, while the default "all" mode rejects that item and only accepts one that meets both rules. @test

Filter items and project results

  • Given catalog entries { name: "Alpha", region: "eu", featured: true }, { name: "Beta", region: "us", featured: true }, and { name: "Gamma", region: "eu", featured: false }, filtering with rules [ { region: "eu" }, "featured" ] and projecting with ["name", "region"] returns [ { name: "Alpha", region: "eu" } ]. @test

Implementation

@generates

API

/**
 * Converts a single rule definition into a predicate function that receives a catalog entry.
 * Supported rules:
 * - string paths for truthy checks,
 * - [path, expected] tuples for strict equality checks,
 * - plain objects for matching nested property values,
 * - predicate functions (returned as-is).
 */
function buildPredicate(ruleDef);

/**
 * Compiles an array of rule definitions into a combined predicate.
 * @param {Array} rules - List of rule definitions accepted by buildPredicate.
 * @param {Object} [options]
 * @param {"all"|"any"} [options.mode="all"] - Whether every or any rule must pass.
 */
function compileRuleSet(rules, options);

/**
 * Filters catalog entries using a compiled rule set and projects fields for matches.
 * @param {Array} items - List of catalog entries.
 * @param {Array} rules - Rule definitions to compile and apply.
 * @param {string|string[]|Function} projector - Field selector(s) or mapper to shape the output.
 * @param {Object} [options] - Same options accepted by compileRuleSet.
 * @returns {Array} Filtered and projected results.
 */
function filterAndProject(items, rules, projector, options);

Dependencies { .dependencies }

lodash { .dependency }

Utility toolkit for building predicates from shorthand rule definitions.

Install with Tessl CLI

npx tessl i tessl/npm-lodash-kebabcase

tile.json