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

Prototype Reference Keeper

A utility that updates object prototypes without changing the original object reference.

Capabilities

Rebind single prototype

  • Changing a plain object's prototype to a provided template exposes the template's method while keeping === identity with the original object @test
  • Existing own properties remain accessible after rebinding @test

Remove prototype

  • Setting an object's prototype to null returns the same object and results in a null prototype chain @test

Bulk rebind

  • Applying a new prototype to an array of objects mutates each in place, returns the same array instance, and gives every entry access to prototype methods @test

Implementation

@generates

API

function rebind(target, newPrototype);
function removePrototype(target);
function rebindAll(targets, newPrototype);

module.exports = { rebind, removePrototype, rebindAll };

Dependencies { .dependencies }

setprototypeof { .dependency }

Cross-runtime helper for changing an object's prototype while keeping the same reference.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-setprototypeof

tile.json