CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-mdn-data

Open Web data by the Mozilla Developer Network containing structured JSON data for web technologies including CSS properties, selectors, functions, at-rules, Web API inheritance, and localization strings used in MDN Web Docs

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

api-data.mddocs/

API Data

Web API interface inheritance relationships and mixin implementations that describe the structure of the Web API object model.

Capabilities

Inheritance Data Access

Access complete inheritance relationships for Web API interfaces.

/**
 * Web API interface inheritance data
 * Maps interface names to their inheritance information
 */
const inheritance: InheritanceData;

interface InheritanceData {
  [interfaceName: string]: InheritanceEntry;
}

interface InheritanceEntry {
  /** The parent interface this interface inherits from, or null if no inheritance */
  inherits: string | null;
  /** Array of mixin interfaces this interface implements */
  implements: string[];
}

Usage Examples:

const { api } = require('mdn-data');

// Check what DocumentFragment inherits from
const docFragment = api.inheritance.DocumentFragment;
console.log(docFragment);
// Output: { "inherits": "Node", "implements": ["ParentNode", "LegacyQueryInterface"] }

// Find all interfaces that inherit from EventTarget
const eventTargetChildren = Object.entries(api.inheritance)
  .filter(([name, data]) => data.inherits === 'EventTarget')
  .map(([name]) => name);

// Check what mixins an interface implements
const analyserNode = api.inheritance.AnalyserNode;
console.log(analyserNode.implements);
// Output: ["AudioNodePassThrough"]

// Find interfaces with no parent (top-level interfaces)
const topLevelInterfaces = Object.entries(api.inheritance)
  .filter(([name, data]) => data.inherits === null)
  .map(([name]) => name);

Interface Lookup

Direct access to specific interface inheritance information.

/**
 * Get inheritance information for a specific interface
 * @param interfaceName - Name of the Web API interface
 * @returns Inheritance entry or undefined if not found
 */
function getInheritanceInfo(interfaceName: string): InheritanceEntry | undefined {
  return api.inheritance[interfaceName];
}

Inheritance Tree Navigation

Helper patterns for navigating the inheritance hierarchy.

/**
 * Common patterns for working with inheritance data
 */

// Get all parent interfaces in the inheritance chain
function getInheritanceChain(interfaceName: string): string[] {
  const chain = [];
  let current = api.inheritance[interfaceName];
  
  while (current && current.inherits) {
    chain.push(current.inherits);
    current = api.inheritance[current.inherits];
  }
  
  return chain;
}

// Get all child interfaces that inherit from a given interface
function getChildInterfaces(parentInterface: string): string[] {
  return Object.entries(api.inheritance)
    .filter(([name, data]) => data.inherits === parentInterface)
    .map(([name]) => name);
}

// Get all interfaces that implement a specific mixin
function getInterfacesImplementingMixin(mixinName: string): string[] {
  return Object.entries(api.inheritance)
    .filter(([name, data]) => data.implements.includes(mixinName))
    .map(([name]) => name);
}

Data Structure Details

The inheritance data provides:

  • Complete Coverage: All Web API interfaces with their inheritance relationships
  • Mixin Support: Tracks which interfaces implement specific mixins
  • Null Inheritance: Top-level interfaces have inherits: null
  • Empty Arrays: Interfaces without mixins have implements: []

Common Use Cases

  1. API Documentation Generation: Understanding interface hierarchies for documentation tools
  2. Type System Integration: Building TypeScript definitions or other type systems
  3. Polyfill Development: Understanding what methods/properties are inherited
  4. Testing Frameworks: Validating that implementations follow the correct inheritance model
  5. IDE Support: Providing accurate autocomplete and error checking for Web APIs

docs

api-data.md

css-data.md

index.md

l10n-data.md

tile.json