UNPKG

fabric

Version:

Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.

1 lines 1.2 kB
{"version":3,"file":"applyMixins.min.mjs","sources":["../../../src/util/applyMixins.ts"],"sourcesContent":["import type { Constructor } from '../typedefs';\n\n/***\n * https://www.typescriptlang.org/docs/handbook/mixins.html#alternative-pattern\n */\nexport function applyMixins<T extends Constructor, S extends Constructor>(\n derivedCtor: T,\n constructors: S[],\n) {\n constructors.forEach((baseCtor) => {\n Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {\n name !== 'constructor' &&\n Object.defineProperty(\n derivedCtor.prototype,\n name,\n Object.getOwnPropertyDescriptor(baseCtor.prototype, name) ||\n Object.create(null),\n );\n });\n });\n return derivedCtor as T & { prototype: InstanceType<T & S> };\n}\n"],"names":["applyMixins","derivedCtor","constructors","forEach","baseCtor","Object","getOwnPropertyNames","prototype","name","defineProperty","getOwnPropertyDescriptor","create"],"mappings":"AAKO,SAASA,EACdC,EACAC,GAaA,OAXAA,EAAaC,SAASC,IACpBC,OAAOC,oBAAoBF,EAASG,WAAWJ,SAASK,IAC7C,gBAATA,GACEH,OAAOI,eACLR,EAAYM,UACZC,EACAH,OAAOK,yBAAyBN,EAASG,UAAWC,IAClDH,OAAOM,OAAO,MACjB,GACH,IAEGV,CACT"}