webcheck-to-string

0.0.1 • Public • Published

webcheck-to-string

Converts a webcheck buffer into a string if possible

How to install

npm install --save webcheck-to-string

How to use

var Webcheck = require('webcheck');
var ToStringPlugin = require('webcheck-to-string');

var plugin = ToStringPlugin();

var webcheck = new Webcheck();
webcheck.addPlugin(plugin);

plugin.enable();

// now continue with your code...

webcheck.on('result', function (result) {
    result.getString(function (err, str) {
        if (err) {
            return console.error(err);
        }

        // Now you are able to handle your string.

    });
});

Options

  • filterUrl: Filter urls that should serve a getString (default all urls).
  • filterStatusCode: Filter HTTP status code (default all).
  • filterContentType: Filter allowed content type (defaults to text, html and xml).

Note for filters

Filters are regular expressions, but the plugin uses only the .test(str) method to proof. You are able to write your own and much complexer functions by writing the logic in the test method of an object like this:

opts = {
   filterSomething: {
       test: function (val) {
           return false || true;
       }
   }
}

Package Sidebar

Install

npm i webcheck-to-string

Weekly Downloads

2

Version

0.0.1

License

ISC

Last publish

Collaborators

  • atd