Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

oversmash

Package Overview
Dependencies
85
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.5.0 to 1.5.1

tests/data_snapshot.js

2

build/index.js

@@ -98,3 +98,3 @@ 'use strict';

const log = (0, _debug2.default)('oversmash');
const log = (0, _debug2.default)('oversmash:main');

@@ -101,0 +101,0 @@ const defaultOptions = {

@@ -26,3 +26,3 @@ 'use strict';

const log = (0, _debug2.default)('oversmash');
const log = (0, _debug2.default)('oversmash:scraper');
const careerTypes = ['quickplay', 'competitive'];

@@ -96,6 +96,3 @@

if (options.normalizeValues) {
if (isNaN(value)) {
// NaN becomes null for clarity
return null;
} else if (value.indexOf('%') !== -1 && !options.percentsToInts || value.indexOf(':') !== -1) {
if (value.indexOf('%') !== -1 && !options.percentsToInts || value.indexOf(':') !== -1) {
// If percentsToInts is not true, don't convert percentages

@@ -144,3 +141,13 @@ // to integers - just pass the value through

const elems = p(e).find('td');
groupStats[normalizeKeyName(options, elems.first().text())] = normalizeValue(options, elems.last().text());
const rawName = elems.first().text();
const rawValue = elems.last().text();
const normalName = normalizeKeyName(options, rawName);
const normalValue = normalizeValue(options, rawValue);
if (normalValue === null) {
log(`null-value(${rawName}): ${rawValue} ~ ${normalValue}`);
}
groupStats[normalName] = normalValue;
});

@@ -200,3 +207,3 @@

log('scrape', careerType, heroName, heroStats[heroName]);
log(`finish scrape(${careerType}/${heroName})`);
});

@@ -203,0 +210,0 @@

{
"name": "oversmash",
"version": "1.5.0",
"version": "1.5.1",
"license": "MIT",

@@ -18,3 +18,4 @@ "homepage": "https://github.com/filp/oversmash",

"start": "babel-node lib/index.js",
"test": "DEBUG=oversmash babel-node tests/test_oversmash.js",
"test": "DEBUG=oversmash:* babel-node tests/test_oversmash.js",
"snapshot": "DEBUG=oversmash:snapshot babel-node tests/data_snapshot.js",
"build": "rm -rf ./build && babel lib -d build",

@@ -34,10 +35,12 @@ "prepublish": "npm run build"

"babel-cli": "^6.11.4",
"babel-core": "^6.18.2",
"babel-preset-node6": "^11.0.0",
"babel-preset-stage-3": "^6.17.0",
"babel-core": "^6.18.2",
"eslint": "^3.12.0",
"eslint-config-standard": "^6.2.1",
"eslint-plugin-promise": "^3.4.0",
"eslint-plugin-standard": "^2.0.1"
"eslint-plugin-standard": "^2.0.1",
"object-path": "^0.11.4",
"traverse": "^0.6.6"
}
}
import assert from 'assert'
import oversmash from '../lib'
import { promisify } from 'util'
import { readFile } from 'fs'
import objectPath from 'object-path'
import traverse from 'traverse'
import debug from 'debug'
async function testPlayerProfile (ow) {
const log = debug('oversmash:snapshot')
const readFileAsync = promisify(readFile)
async function loadSnapshot (name) {
const data = await readFileAsync(`./tests/snapshots/${name}.json`)
return JSON.parse(data)
}
function compareToSnapshot (snapshot, data) {
traverse(data).forEach(function (node) {
if (Array.isArray(node) || (typeof node === 'object' && node !== null)) return
const path = this.path.join('.')
const compareTo = objectPath.get(snapshot, path)
const t = typeof node
const ct = typeof compareTo
if (t === 'undefined' || node === null) {
log(`bad-value(${path}): is ${t === null ? 'null' : 'undefined'}`)
}
if (t !== ct) {
log(`type-diverged(${path}): ${t} !== ${ct}`)
}
if (node !== compareTo) {
log(`diverged(${path}): ${node} !== ${compareTo}`)
}
})
}
async function testPlayerProfile (ow, snapshot) {
const p = await ow.player('FATCOTTON420#2476')

@@ -9,5 +45,7 @@

assert.equal(p.accounts.length, 1)
compareToSnapshot(snapshot, p)
}
async function testPlayerStats (ow) {
async function testPlayerStats (ow, snapshot) {
const p = await ow.playerStats('FATCOTTON420-2476', 'pc')

@@ -27,2 +65,4 @@

assert(p.stats.quickplay.lucio.combat.all_damage_done > 0)
compareToSnapshot(snapshot, p)
}

@@ -33,4 +73,4 @@

await testPlayerProfile(ow)
await testPlayerStats(ow)
await testPlayerProfile(ow, await loadSnapshot('profile'))
await testPlayerStats(ow, await loadSnapshot('stats'))
}

@@ -37,0 +77,0 @@

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc