Namespace: interfaces

gpf. interfaces

Root namespace for GPF interfaces

Since:
  • 0.1.8

Methods


<static> isImplementedBy(interfaceSpecifier, inspectedObject)

Verify that the object (or class) implements the current interface

Parameters:
Name Type Description
interfaceSpecifier function | String

Interface specifier

inspectedObject Object | function

object (or class) to inspect.

Since:
  • 0.1.8
Returns:

True if implemented

Type
Boolean

<static> promisify(interfaceSpecifier)

Build promisified interface wrapper

Parameters:
Name Type Description
interfaceSpecifier function

Reference interface

Since:
  • 0.2.8
Returns:

Interface Wrapper constructor

Type
function
Example

IXmlContentHandler wrapper

var wrapXmlContentHandler = gpf.interfaces.promisify(gpf.interfaces.IXmlContentHandler),
    writer = new gpf.xml.Writer(),
    output = new gpf.stream.WritableString();
gpf.stream.pipe(writer, output).then(function () {
    console.log(output.toString());
});
wrapXmlContentHandler(writer)
    .startDocument()
    .startElement("document")
    .endElement();
// <document/>

<static> query(interfaceSpecifier, queriedObject)

Retrieve an object implementing the expected interface from an object:

  • Either the object implements the interface, it is returned
  • Or the object implements IUnknown, then queryInterface is used
Parameters:
Name Type Description
interfaceSpecifier function | String

Interface specifier

queriedObject Object

Object to query

Since:
  • 0.1.8
Returns:

Object implementing the interface or null, undefined is returned when IUnknown is not implemented

Type
Object | null | undefined