<commit_before>'use strict'

/*
The goal of module is looking for link and call user function to do smth with it
params:
option - is object with string to parse and may be some option
searchCallback - user function to be call when link was found
replaceCallback - user function to be call to replace link after search
geturlCallback - user function to be call get url of link
usage:
var text = "to ream more click http://google.com";

function httpSearch(startLinkIndex, linkLength) {
  //do smth may be save startLinkIndex and linkLength
}
function httpReplace() {
  // replace link on startLinkIndex to what we need
  // use httpGeturl to get url
}
function httpGeturl(url) {
  // this function is useful in httpReplace()
}
var httpLink = autolink( { src: text }, httpSearch, httpReplace, httpGeturl);
httpLink.search();
httpLink.replace();

*/
module.exports = function autolink(option, searchCallback, replaceCallback, geturlCallback) {
  var src = option.src;
  var startLink = 0;
  var endLink = 0;
  var lengthLink = 0;
  var url = undefined;
  return {
    function search() {
      url = undefined;
      startLink = src.indexOf("http");
      lengthLink = "http".length;
      endLink = startLink+lengthLink;
      if ( typeof searchCallback === 'function' )
        searchCallback(startLink, lengthLink);
      return startLink;
    }
    function replace() {
      if ( typeof replaceCallback === 'function' ) 
        replaceCallback(); 
    }
    function getUrl() {
      if (url !== undefined) url = src.substring(startLink, lengthLink);
      if ( typeof geturlCallback === 'function' ) 
        geturlCallback(url);
    }
  };
}
<commit_msg>make autolink as object maner<commit_after>'use strict'

/*
The goal of module is looking for link and call user function to do smth with it
params:
option - is object with string to parse and may be some option
searchCallback - user function to be call when link was found
replaceCallback - user function to be call to replace link after search
geturlCallback - user function to be call get url of link
usage:
var text = "to ream more click http://google.com";

function httpSearch(startLinkIndex, linkLength) {
  //do smth may be save startLinkIndex and linkLength
}
function httpReplace() {
  // replace link on startLinkIndex to what we need
  // use httpGeturl to get url
}
function httpGeturl(url) {
  // this function is useful in httpReplace()
}
var httpLink = new Autolink( { src: text } );
httpLink.search( httpSearch );
httpLink.replace();

*/
function Autolink(option) {
  this.src = option.src;
  this.startLink = 0;
  this.endLink = 0;
  this.lengthLink = 0;
  this.currentLink = undefined;
}

Autolink.prototype.search = function (callback) {
  this.url = undefined;
  this.startLink = this.src.indexOf("http");
  this.lengthLink = "http".length;
  this.endLink = this.startLink+this.lengthLink;
  if ( typeof callback === 'function' ) {
    callback(this.startLink, this.lengthLink);
  }
};

Autolink.prototype.replace = function () {
};

Autolink.prototype.getUrl = function () {
};

module.exports = Autolink;

{'fraction_non_alphanumeric': 0.09912536443148688, 'fraction_numerical': 0.001943634596695821, 'mean_word_length': 3.6366366366366365, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2433263', 'n_tokens_mistral': 901, 'n_tokens_neox': 891, 'n_words': 328}