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-4/

Prototype Rebinding Helper

Implement a helper that mutates plain objects to adopt a provided blueprint as their prototype, retaining compatibility in environments that may not support native prototype reassignment.

Capabilities

Adopts blueprint prototype

  • Mutates the given target object, returns the same reference, and allows methods from the blueprint prototype to be callable on the result. @test

Preserves existing fields during fallback copy

  • When direct prototype replacement is unavailable, copies enumerable properties from the blueprint only into missing slots on the target, leaving existing own properties untouched. @test

Supports null prototype detachment

  • Accepts null as the blueprint to remove the target's prototype, keeping its own properties intact. @test

Implementation

@generates

Attempt prototype reassignment through the provided dependency before applying any fallback copying behavior.

API

export function rebasePrototype<T extends object>(target: T, blueprint: object | null): T;

Dependencies { .dependencies }

setprototypeof { .dependency }

Provides cross-environment prototype reassignment support, including environments where Object.setPrototypeOf is missing and only __proto__ assignment works.

Install with Tessl CLI

npx tessl i tessl/npm-setprototypeof

tile.json