123456789101112131415161718192021222324252627282930 |
- /**
- * Is current user logged in ?
- *
- * @returns {boolean}
- * True if the user is logged in, false otherwise.
- */
- isLoggedIn = () => {
- return !!Meteor.userId();
- };
- /**
- * Convert a document to a string containing its unique words.
- *
- * @param {Object} doc
- * The source Website document. Extraction uses title and description only.
- * @returns {string}
- * A string made of the lower-case, orderd, deduplicated words in the document.
- */
- toWords = (doc) => {
- const NONWORD_REGEX = /[\W]/g;
- const aTitle = doc.title.split(NONWORD_REGEX);
- const aDescription = doc.description.split(NONWORD_REGEX);
- const aWords = aTitle.concat(aDescription);
- const aLCWords = aWords.map(function (s) { return s.toLocaleLowerCase(); });
- const aDWords = _.uniq(aLCWords);
- const aDSWords = aDWords.sort();
- const result = aDSWords.join(" ").trim();
- Meteor._debug(doc, result);
- return result;
- };
|