CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-safe-stable-stringify

Deterministic and safely JSON.stringify to quickly serialize JavaScript objects

90

1.08x

Evaluation90%

1.08x

Agent success when using this tile

Overview
Eval results
Files

task.mdevals/scenario-6/

Financial Transaction Serializer

Build a serialization utility for financial transaction records that can handle large monetary values represented as BigInts.

Capabilities

Serialize transaction objects with BigInt amounts

  • When given a transaction object with amount: 9007199254740993n (a value beyond JavaScript's safe integer range), it serializes to a JSON string with the amount as a number without throwing an error. @test
  • When given a transaction object with timestamp: 1640995200000000000n (a nanosecond timestamp), it serializes to include the timestamp value. @test

Handle transactions with mixed numeric types

  • When given a transaction with both regular numbers (like fee: 2.50) and BigInt amounts (like totalCents: 250000000000000n), both values are included in the serialized output. @test

Provide consistent output for transaction records

  • When given two transaction objects with the same properties but in different insertion order, the serialized output is identical. @test

Implementation

@generates

API

/**
 * Serializes a financial transaction record to a JSON string.
 * Handles BigInt values for large amounts and timestamps.
 * Produces deterministic output with alphabetically sorted keys.
 *
 * @param {Object} transaction - The transaction object to serialize
 * @returns {string} JSON string representation of the transaction
 */
function serializeTransaction(transaction) {
  // IMPLEMENTATION HERE
}

module.exports = { serializeTransaction };

Dependencies { .dependencies }

safe-stable-stringify { .dependency }

Provides JSON serialization with BigInt support and deterministic output.

Install with Tessl CLI

npx tessl i tessl/npm-safe-stable-stringify

tile.json