elasticlunr
Version:
Lightweight full-text search engine in Javascript for browser search and offline search.
44 lines (39 loc) • 997 B
JavaScript
/*!
* elasticlunr.utils
* Copyright (C) @YEAR Oliver Nightingale
* Copyright (C) @YEAR Wei Song
*/
/**
* A namespace containing utils for the rest of the elasticlunr library
*/
elasticlunr.utils = {};
/**
* Print a warning message to the console.
*
* @param {String} message The message to be printed.
* @memberOf Utils
*/
elasticlunr.utils.warn = (function (global) {
return function (message) {
if (global.console && console.warn) {
console.warn(message);
}
};
})(this);
/**
* Convert an object to string.
*
* In the case of `null` and `undefined` the function returns
* an empty string, in all other cases the result of calling
* `toString` on the passed object is returned.
*
* @param {object} obj The object to convert to a string.
* @return {String} string representation of the passed object.
* @memberOf Utils
*/
elasticlunr.utils.toString = function (obj) {
if (obj === void 0 || obj === null) {
return "";
}
return obj.toString();
};