interfaces.Interface

The base foundation for every interface. Interface provides a mechanism for checking whether properties/functions are properly implemented during runtime, through the super callchain. This speeds up development and ensures that classes function the way they need to. The Interface and NE_JSObject classes actually exist inside of /interface, not in /interfaces as documented. They have been grouped there for convenience.

Extends

Classes

Interface

Methods

static Interface.ensureAbstract(funcs) → {Interface|*}

Utility function to be placed inside of constructors to ensure an instance being created has not come from an abstract class.
Parameters:
Name Type Description
funcs Iterable.<(string|function())> The iterable containing properties that are checked.
Throws:
Error if a required prototype or static property is missing.
Returns:
Interface | * - The checked instance.
See:
  • {interfaces.Interface.isImplemented}

static Interface.isImplemented(funcs, objopt, _) → {Interface|*}

Determines during runtime at object creation whether the object in question successfully implements functions or properties. Currently, checking for difference between a property implemented as a function vs a property is not implemented. To do so, pass in functions for funcs parameter.
Parameters:
Name Type Attributes Default Description
funcs Iterable.<(string|function())> The iterable containing properties that are checked. Could be an array of string virtual function names, for example. When not provided, object.funcs is pulled instead and errors during checking will assume that object is an instance and, if defined, will assume object is a class. As such, the error message will switch between checking static/member properties. If an item in the iterable is a function, it must accept proto as an argument and only throw an error if there is a problem with the instance in regards to an instance implementing an interface. Return value is ignored otherwise. For safety reasons, the order of items within this Iterable should not matter.
obj Object <optional>
this The specific object on which to check against whether items in f are defined as functions. However, if such an item is a function, this will be passed as the only argument to that function.
_ undefined Legacy parameter: should be undefined always. Enforces this function is called properly compared to legacy implementations. Pending future removal.
Throws:
Error if a required prototype or static property is missing.
Returns:
Interface | * - The checked object.

isImplemented(funcs) → {Interface|*}

Determines during runtime at object creation whether the object in question successfully implements functions or properties. Forwards calls to class method version.
Parameters:
Name Type Description
funcs Iterable.<(string|function())> The iterable containing properties that are checked.
Throws:
Error if a required prototype or static property is missing.
Returns:
Interface | * - The checked instance.
See:
  • interfaces.Interface.isImplemented