]> git.wh0rd.org - chrome-ext/clearhistory-advance-fork.git/blobdiff - javascript/util.js
convert JS to ES6 modules
[chrome-ext/clearhistory-advance-fork.git] / javascript / util.js
index a428b3b7af768f28757091ba982ebbdcb2918951..c56589f951c53ac044d2a75b552c45cec1dc3b15 100644 (file)
@@ -4,40 +4,12 @@
  * @fileoverview Some basic, useful utility functions.
  */
 
-/**
- * Pours the data in template string.
- * @param {Object} datObject The data object to be filled in template string.
- * @return {string} The new string created from template string and filled
- *     with the given data.
- */
-String.prototype.supplant = function(datObject) {
-  return this.replace(/{([^{}]*)}/g,
-    function(match, firstSubMatch) {
-      var replace = datObject[firstSubMatch];
-      return (typeof replace === 'string' || typeof replace === 'number') ?
-          replace : match;
-    });
-};
-
-/**
- * Queries the DOM.
- * @param {string} selector Selector to execute.
- * @param {HTMLElement=} context HTMLElement to query (optional).
- * @return {Array.<HTMLElement>} Array of matched elements (non-live).
- */
-function $(selector, context) {
-  if (!(context && context instanceof HTMLElement)) {
-    context = document;
-  }
-  return Array.prototype.slice.call(context.querySelectorAll(selector));
-}
-
 /**
  * Provides units for time, given in hours, as hours or days.
  * @param {number} time The time, in hours.
  * @return {Object} The time and units of time (pluralized and localized).
  */
-function getUnitsForTime(time) {
+export function getUnitsForTime(time) {
   var units = 'hour';
   if (time >= 24) {
     units = 'day';