0ad/binaries/data/mods/public/simulation/ai/common-api/class.js

21 lines
365 B
JavaScript
Raw Normal View History

/**
* Provides a nicer syntax for defining classes,
* with support for OO-style inheritance.
*/
export function Class(data)
{
2016-06-02 11:08:14 -07:00
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;
}