diff --git a/lib/createdb.js b/lib/createdb.js index bda00cd..0695e99 100755 --- a/lib/createdb.js +++ b/lib/createdb.js @@ -1,7 +1,6 @@ #!/usr/bin/env node const args = require("commander"); const packageInfo = require("../package"); -const { startsWith } = require("./mapper"); var postgresClient = require("pg-native"); var sqlite3 = require("sqlite3"); @@ -55,7 +54,7 @@ const createDbPostgres = function (sessions) { const main = function (argv_) { const argv = argv_ || process.argv; args.parse(argv); - if (startsWith(args.sessions, "postgresql://")) { + if (args.sessions.startsWith("postgresql://")) { createDbPostgres(args.sessions); } else { createDbSqlite(args.sessions); diff --git a/lib/mapper.js b/lib/mapper.js index 9dd3dcd..ae26584 100644 --- a/lib/mapper.js +++ b/lib/mapper.js @@ -3,19 +3,6 @@ var sqlite3 = require("sqlite3"); var postgresClient = require("pg-native"); var watchFile = require("node-watch"); -var startsWith = function (subjectString, searchString) { - var reversedSubjectString = subjectString.split('').reverse().join(''); - var reversedSearchString = searchString.split('').reverse().join(''); - return endsWith(reversedSubjectString, reversedSearchString); -} - -var endsWith = function (subjectString, searchString) { - var position = subjectString.length; - position -= searchString.length; - var lastIndex = subjectString.indexOf(searchString, position); - return lastIndex !== -1 && lastIndex === position; -}; - var updateFromJson = function (path, map) { var content = fs.readFileSync(path, "utf8"); var keyToSession = JSON.parse(content); @@ -155,12 +142,12 @@ var mapFor = function (path, pollingInterval) { var map = {}; var loadMap; var watch; - if (endsWith(path, ".sqlite")) { + if (path.endsWith(".sqlite")) { loadMap = function () { updateFromSqlite(path, map); }; watch = watchFile; - } else if (startsWith(path, "postgresql://")) { + } else if (path.startsWith("postgresql://")) { loadMap = function () { updateFromPostgres(path, map); }; @@ -179,6 +166,4 @@ var mapFor = function (path, pollingInterval) { return map; }; -exports.endsWith = endsWith; exports.mapFor = mapFor; -exports.startsWith = startsWith;