CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/npm-ulid

tessl install tessl/npm-ulid@3.0.0

A universally-unique, lexicographically-sortable, identifier generator

Agent Success

Agent success rate when using this tile

78%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.34x

Baseline

Agent success rate without this tile

58%

task.mdevals/scenario-9/

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.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/ulid@3.0.x
tile.json