Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

socialblade-com-api

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

socialblade-com-api - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

functions.js

39

.eslintrc.json
{
"env": {
"commonjs": true,
"es6": true,
"node": true
},
"extends": [
"standard"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
}
"env": {
"commonjs": true,
"es6": true,
"node": true,
"mocha": true
},
"extends": [
"standard"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
"quote-props": [
"error",
"consistent-as-needed"
]
}
}
const axios = require('axios')
const cheerio = require('cheerio')
function cleanRows (rows) {
const days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
return rows
.map(row => row.replace(new RegExp(/(\t|\s|,|\+)+/, 'g'), ''))
.filter(row => row && !days.includes(row))
}
const { cleanRows, createArrayOfArrays, fillArray, convertArrayToObject } = require('./functions')
function createArrayOfArrays (n) {
const arrays = []
for (let i = 0; i < n; i++) {
arrays.push([])
}
return arrays
}
function fillArray (arrays, tableRows) {
for (let i = 0, j = 0; i < tableRows.length; i++) {
if (i % 7 === 0 && i !== 0) {
j++
}
arrays[j].push(tableRows[i])
}
return arrays
}
function convertArrayToObject (arrays) {
return arrays.map(array => {
const [date, followersDelta, followers, followingDelta, following, postsDelta, posts] = array
return {
date: date.replace(/-/g, '/'),
followersDelta: +followersDelta || 0,
followers: +followers || 0,
followingDelta: +followingDelta || 0,
following: +following || 0,
postsDelta: +postsDelta || 0,
posts: +posts || 0
}
})
}
async function socialblade (username) {

@@ -51,3 +13,3 @@ const html = await axios(`https://socialblade.com/twitter/user/${username}/monthly`)

let arrays = createArrayOfArrays(tableRows.length / itemsPerRow)
arrays = fillArray(arrays, tableRows)
arrays = fillArray(arrays, tableRows, itemsPerRow)
const array2obj = convertArrayToObject(arrays)

@@ -54,0 +16,0 @@ return array2obj

{
"name": "socialblade-com-api",
"version": "1.0.2",
"version": "1.1.0",
"description": "Unofficial APIs for Socialblade.com website.",

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

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