0ad/binaries/data/mods/public/simulation/ai/common-api/class.js
phosit 0a2bd6a5a4 Use proper js-modules for ai common-api
The common-api already used a coding pattern which was called modules.
That is replaced with native js-modules.

Refs: #8081
2025-08-13 14:04:16 +02:00

20 lines
365 B
JavaScript

/**
* Provides a nicer syntax for defining classes,
* with support for OO-style inheritance.
*/
export function Class(data)
{
let ctor;
if (data._init)
ctor = data._init;
else
ctor = function() { };
if (data._super)
ctor.prototype = { "__proto__": data._super.prototype };
for (const key in data)
ctor.prototype[key] = data[key];
return ctor;
}