Skip to content

Commit

Permalink
Ordered methods alphabetically
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Kolarski authored and mvolz committed Jan 25, 2018
1 parent 1281c8c commit 9d5aab8
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,26 @@ exports = module.exports = function(urlOrOpts, callback) {
};

/**
* Returns Object containing all available datatypes, keyed
* using the same keys as in metadataFunctions.
* Exported function that takes html file and
* returns a BBPromise for all available metadata
*
* @param {Object} chtml html Cheerio object to parse
* @param {Function} [callback] optional callback function
* @param {String} path path Path to HTML file
* @param {Object} [opts] opts Additional options such as encoding
* @param {Function} [callback] Optional callback
* @return {Object} BBPromise for metadata
*/
exports.parseAll = function(chtml, callback){
return index.parseAll(chtml).nodeify(callback);
exports.loadFromFile = function(path, opts, callback) {
var defaultEncoding = 'utf-8';

opts = opts || defaultEncoding;
if (typeof opts === 'function') {
callback = opts;
opts = defaultEncoding;
}

return fs.readFileAsync(path, opts).then(html =>
index.parseAll(cheerio.load(html)).nodeify(callback)
);
};

/**
Expand All @@ -58,26 +69,15 @@ exports.loadFromString = function(html, callback) {
};

/**
* Exported function that takes html file and
* returns a BBPromise for all available metadata
* Returns Object containing all available datatypes, keyed
* using the same keys as in metadataFunctions.
*
* @param {String} path path Path to HTML file
* @param {Object} [opts] opts Additional options such as encoding
* @param {Function} [callback] Optional callback
* @param {Object} chtml html Cheerio object to parse
* @param {Function} [callback] optional callback function
* @return {Object} BBPromise for metadata
*/
exports.loadFromFile = function(path, opts, callback) {
var defaultEncoding = 'utf-8';

opts = opts || defaultEncoding;
if (typeof opts === 'function') {
callback = opts;
opts = defaultEncoding;
}

return fs.readFileAsync(path, opts).then(html =>
index.parseAll(cheerio.load(html)).nodeify(callback)
);
exports.parseAll = function(chtml, callback){
return index.parseAll(chtml).nodeify(callback);
};

/**
Expand Down

0 comments on commit 9d5aab8

Please sign in to comment.