1
0
forked from mirrors/0ad
Files
0ad/binaries/data/mods/public/simulation/ai/common-api/class.js
T
Ralph Sennhauser a9987868c4 Fix eslint rule 'no-use-before-define'
Manual fixes needed for:
eslint --no-config-lookup --rule '"no-use-before-define": ["error", "nofunc"]

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-14 16:35:58 +02:00

27 lines
405 B
JavaScript

API3 = function(m)
{
/**
* Provides a nicer syntax for defining classes,
* with support for OO-style inheritance.
*/
m.Class = function(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;
};
return m;
}(API3);