CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-ulid

A universally-unique, lexicographically-sortable, identifier generator

78

1.34x
Overview
Eval results
Files

task.mdevals/scenario-6/

ULID Time Range Filter

Build a utility function that filters a collection of ULID strings to return only those created within a specified time range.

Requirements

Your implementation should:

  • Accept an array of ULID strings, a start timestamp (in milliseconds), and an end timestamp (in milliseconds)
  • Return an array containing only the ULIDs that were created within the specified time range (inclusive)
  • Handle invalid ULIDs gracefully by skipping them
  • Return an empty array if no ULIDs fall within the time range

Test Cases

  • Given ULIDs with timestamps 1000, 2000, and 3000, filtering for range 1500-2500 returns only the ULID with timestamp 2000 @test
  • Given ULIDs with timestamps 1000, 2000, and 3000, filtering for range 1000-3000 returns all three ULIDs (inclusive boundaries) @test
  • Given an array containing valid ULIDs and invalid strings, only valid ULIDs within range are returned @test
  • Given ULIDs with timestamps 1000, 2000, and 3000, filtering for range 5000-6000 returns an empty array @test

Implementation

@generates

API

/**
 * Filters an array of ULIDs to return only those created within the specified time range.
 *
 * @param ulids - Array of ULID strings to filter
 * @param startTime - Start of time range in milliseconds (inclusive)
 * @param endTime - End of time range in milliseconds (inclusive)
 * @returns Array of ULIDs that fall within the specified time range
 */
export function filterULIDsByTimeRange(
  ulids: string[],
  startTime: number,
  endTime: number
): string[];

Dependencies { .dependencies }

ulid { .dependency }

Provides ULID generation and decoding functionality.

Install with Tessl CLI

npx tessl i tessl/npm-ulid

tile.json