products-administrator
Advanced tools
Comparing version 1.0.5 to 1.0.6
20
index.js
@@ -46,8 +46,12 @@ var products = [ | ||
this.getIndexById = function (id){ | ||
for (var index in products){ | ||
var product = products[index]; | ||
if(product.id == id){ | ||
return index; | ||
if (isNaN(id)){ | ||
return "error"; | ||
} else { | ||
for (var index in products){ | ||
var product = products[index]; | ||
if(product.id == id){ | ||
return index; | ||
} | ||
} | ||
} | ||
} | ||
return null; | ||
@@ -65,3 +69,3 @@ } | ||
exports.selectProduct = function (id){ | ||
if (this.getIndexById(id) != null){ | ||
if (this.getIndexById(id) != null && this.getIndexById(id) != "error"){ | ||
var product = products[this.getIndexById(id)]; | ||
@@ -71,3 +75,5 @@ if(product.id == id){ | ||
} | ||
} else { | ||
} else if (this.getIndexById(id) == "error"){ | ||
return "error"; | ||
} else { | ||
return null; | ||
@@ -74,0 +80,0 @@ } |
{ | ||
"name": "products-administrator", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "\"a fake products administrator for e-commerce\"", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2354
105