Socket
Socket
Sign inDemoInstall

animality

Package Overview
Dependencies
Maintainers
2
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

animality - npm Package Compare versions

Comparing version 1.1.3 to 1.1.4

2

.upm/store.json

@@ -1,1 +0,1 @@

{"version":2,"languages":{"nodejs-npm":{"specfileHash":"ed334e0f2647d71ec0f18d7f2c3912d1","lockfileHash":"7a06ca71cf2f6e58e586d2b28afe529c","guessedImports":["node-fetch"],"guessedImportsHash":"51266e8e25b3d5e637d3474eb13a80d8"}}}
{"version":2,"languages":{"nodejs-npm":{"specfileHash":"b858b42218d4736c3e5fe8166c36457d","lockfileHash":"9c2b3bbd0a9a460d522814921c601211","guessedImports":["node-fetch"],"guessedImportsHash":"d534011cc471dd381a0ecfc25ccd7a0d"}}}

@@ -5,6 +5,28 @@ const fetch = require("node-fetch")

getAsync : async function(type){
if(typeof type != "string") throw new TypeError("Invalid type of arguments!")
if(typeof type != "string" && typeof type != "object") throw new TypeError("Invalid type of arguments! Arguments must be a string or an array!")
if(!type) throw new TypeError("No arguments provided!")
let img = `https://random-api.nitcord.repl.co/api/img/${type}`
let fact = `https://random-api.nitcord.repl.co/api/facts/${type}`
if(typeof type == "object"){
let data = []
let animals = ["cat", "dog", "bird", "panda", "redpanda", "koala", "fox", "whale", "kangaroo", "bunny"]
for(var i = 0; i < type.length; i++){
if(animals.includes(type[i])){
img = `https://random-api.nitcord.repl.co/api/img/${type[i]}`
fact = `https://random-api.nitcord.repl.co/api/facts/${type[i]}`
const imgData = await fetch(img).then(lang => lang.json())
const factData = await fetch(fact).then(lang => lang.json())
let factReceived = factData.fact
let imgReceived = imgData.link
let object = {}
object["name"] = type[i]
object["image"] = imgReceived
object["fact"] = factReceived
data[i] = object
} else{
throw new TypeError("Invalid argument! Invalid Animal Name!")
}
}
return data
}
if(type == "cat"){

@@ -11,0 +33,0 @@ const imgData = await fetch(img).then(lang => lang.json())

{
"name": "animality",
"version": "1.1.3",
"version": "1.1.4",
"description": "A simple API wrapper that generates images & facts of any animal",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -70,1 +70,33 @@ # animality

```
## Get information of multiple animals at once
```javascript
const animality = require("animality")
const animals = ["cat", "dog", "kangaroo"]
animality.getAsync(animals).then(data => {
console.log(data) //returns an array of objects
})
```
## Output:
```json
[
{
"name": "cat",
"image": "random cat image link",
"fact": "random cat fact"
},
{
"name": "dog",
"image": "random dog image link",
"fact": "random dog fact"
},
{
"name": "kangaroo",
"image": "random kangaroo image link",
"fact": "random kangaroo fact"
}
]
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc