CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-webrtc-adapter

A shim to insulate apps from WebRTC spec changes and browser prefix differences

Overall
score

98%

Overview
Eval results
Files

task.mdevals/scenario-3/

Browser Information Utility

A utility library that detects browser information from user agent strings and provides structured browser details.

Capabilities

Parse browser type from user agent

  • Given a Chrome user agent string "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36", the parser identifies the browser as "chrome" @test
  • Given a Firefox user agent string "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0", the parser identifies the browser as "firefox" @test
  • Given a Safari user agent string "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Safari/605.1.15", the parser identifies the browser as "safari" @test

Extract version number from user agent

  • Given a Chrome user agent with version 91.0.4472.124, the parser extracts version number 91 @test
  • Given a Firefox user agent with version 89.0, the parser extracts version number 89 @test
  • Given a Safari user agent with Version/14.1.1, the parser extracts version number 14 @test

Provide structured browser details

  • The utility exposes a browserDetails object with properties: browser (string), version (number) @test

Implementation

@generates

API

/**
 * Returns structured information about the current browser.
 *
 * @returns {Object} An object containing:
 *   - browser: A string identifying the browser type (e.g., 'chrome', 'firefox', 'safari')
 *   - version: A number representing the major version of the browser
 */
function getBrowserDetails() {
  // IMPLEMENTATION HERE
}

/**
 * Extracts a version number from a user agent string using a regular expression.
 *
 * @param {string} uastring - The user agent string to parse
 * @param {string} expr - The regular expression pattern to match the version
 * @param {number} pos - The position in the regex match array to extract (typically 1 or 2)
 * @returns {number|null} The extracted version number, or null if not found
 */
function extractVersion(uastring, expr, pos) {
  // IMPLEMENTATION HERE
}

module.exports = {
  getBrowserDetails,
  extractVersion,
};

Dependencies { .dependencies }

webrtc-adapter { .dependency }

Provides browser detection and version extraction utilities for WebRTC compatibility.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-webrtc-adapter

tile.json