mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-19 06:43:58 -07:00
The common-api already used a coding pattern which was called modules. That is replaced with native js-modules. Refs: #8081
20 lines
365 B
JavaScript
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;
|
|
}
|