CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-setprototypeof

A small polyfill for Object.setPrototypeOf with cross-platform compatibility

82

1.02x
Overview
Eval results
Files

task.mdevals/scenario-5/

Legacy Prototype Bridge

A compatibility helper that links plain objects to a base behavior while still working in runtimes that cannot directly rewire prototypes.

Capabilities

Prototype link preserves identity

  • Given a target with its own data and a base that supplies a method, linking keeps the same object reference and exposes the base method for calls. @test

Existing fields are not overwritten

  • When both target and base define the same key, linking leaves the target's value intact while still exposing other base members. @test

Legacy mixin mode fills gaps

  • With legacy handling forced, the target gains enumerable properties from the base only where it lacks them, so it can call base helpers without losing its own fields. @test

Implementation

@generates

API

/**
 * Connects a target object to a base object, enabling prototype-style access where supported
 * and a legacy mixin fallback when requested.
 *
 * @param {object} target - The object to augment.
 * @param {object} base - The object whose behavior should be attached.
 * @param {{ forceLegacy?: boolean }} [options] - When true, skip prototype rewiring and perform the legacy mixin path even if prototypes are available.
 * @returns {object} The same target object after linkage.
 */
export function bridgePrototype(target, base, options = {});

Dependencies { .dependencies }

setprototypeof { .dependency }

Prototype-adjustment helper used to unify prototype linking with a legacy property-mixin fallback. @satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-setprototypeof

tile.json