web-uptimer
Advanced tools
Comparing version 1.0.1-array to 1.0.1-b
@@ -46,10 +46,4 @@ /* Copyright Angelo II#0007 | ||
if (current && current.length) { | ||
current.forEach(u => { | ||
if (u.url === url) { | ||
throw new InvalidStringError('That url was already used from that id'); | ||
} | ||
}) | ||
if (current && current.find(x => x.url === url)) { | ||
throw new InvalidStringError('That url was already used from that id'); | ||
} | ||
@@ -73,21 +67,21 @@ | ||
let current = db.get(`urls_${id}`); | ||
let database = db.get(`urls_${id}`); | ||
if (!current) { | ||
if (!database) { | ||
throw new MissingError('No URLs on the database'); | ||
} | ||
if (current && current.length) { | ||
if (database) { | ||
let data = current.filter(a => a.url === url); | ||
let data = database.find(x => x.url === url); | ||
if (!data) { | ||
throw new InvalidStringError('Cannot delete that url, because dont exits on the database'); | ||
throw new MissingError('Cannot find and delete ' + url) | ||
} | ||
let value = current.indexOf(data); | ||
delete current[value]; | ||
let value = database.indexOf(data) | ||
delete database[value] | ||
var filter = current.filter(a => { | ||
return a != null && a != ''; | ||
var filter = database.filter(x => { | ||
return x != null && x != '' | ||
}) | ||
@@ -101,2 +95,6 @@ | ||
if (!id) { | ||
throw new MissingError('No ID given') | ||
} | ||
if (typeof (id) !== 'string') { | ||
@@ -128,5 +126,5 @@ throw new InvalidStringError('The ID must be a string'); | ||
var urls = all.filter(e => e.ID.startsWith(`urls`)); | ||
var urls = all.filter(e => e.ID.startsWith(`urls_`)); | ||
var array = []; | ||
let array = []; | ||
@@ -139,12 +137,7 @@ if (!urls) { | ||
if (!u.data) { | ||
return array; | ||
} | ||
u.data.forEach(data => { | ||
array.push(data.url); | ||
array.push(data.url); | ||
}) | ||
}) | ||
@@ -151,0 +144,0 @@ |
{ | ||
"name": "web-uptimer", | ||
"version": "1.0.1-array", | ||
"version": "1.0.1-b", | ||
"description": "Uptiming Websites", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
8362
162