A small embed classification library for URL's. Give an an URL and it will give you information about how to embed it as well as provide methods that generated the embed code for you.
The module is released in the public npm registry and can be installed by running:
npm install --save whatsthis
The module exposes it's classification class as primary interface.
'use strict';var What = ;
It can be constructed with the following options:
- defaults Do you want to include the default classification methods. Defaults
var match = /* options here */ ;
The following methods are exposed on the instance.
The classification uses a middleware system called
supplies to allow adding of
middleware layers. These middleware layers are the actual functions that can
categorize the content that we feed them.
The use method adds a method at the end of all checks while the before method adds it at the beginning of the stack. To add your own or extra classification functionality you can register them as followed:
This is the core method of the module, it parses the content you supply it, finds a or the last URL in the content and tries to classify it's content based on the various of classification methods that are registered.
The method accepts 2 arguments:
- The message or content that needs to be parsed
- Completion callback function that follows an error first callback pattern.
As you can see from above you receive a
result object. This object contains
the following information:
- match The found URL in the content.
- source The supplied content.
- url The parsed result of the URL.
- service Generally the name of the parser that classified it.
- type Media type. Can be one of the following:
- html Generated embed content.