brenapp / vexdb Goto Github PK
View Code? Open in Web Editor NEWA simple API library for the VexDB API
Home Page: https://npm.im/vexdb
License: MIT License
A simple API library for the VexDB API
Home Page: https://npm.im/vexdb
License: MIT License
This library is designed to be isomorphic and in order to do that, I have used axios, which is an isomorphic Promise-based fetch library. However, it is 10Kb big built and gzipped and has many features which are not required for this application. I will look to create a tiny promise-based library to replace it
Steps to reproduce:
Insert a debug line into the request
function to see what network requests are made:
async function request(endpoint, params) {
if (cache.has(endpoint, params)) return cache.resolve(endpoint, params);
console.log("GET", endpoint, params);
const vexdb = require("vexdb")
vexdb.get("matches", {
sku: "RE-VRC-17-3805",
team: async team =>
(await vexdb.size("teams", {
team,
region: "South Carolina"
})) > 0
}).then(console.log)
Run the code and see that the request for GET teams { region: 'South Carolina', nodata: true }
is being called for every match evaluated
.getAll()
will throw an error if no parameters are passed
1 failed
getAll » .getAll() resolves for correct requests
C:\Users\bmcgui7575\Documents\vexdb\main.js:185
185: (v, i) => get(endpoint, Object.assign(params, { limit_start: 5000 * i }))
Error: Cannot convert undefined or null to object
Promise.all.map (main.js:185:44)
size.then.items (main.js:184:12)
This is because of the lack of || {}
after params
The current iteration method is clunky, and could be optimizied
I've resolved the problem down to the permutationsObject()
function. I think it's the result of my array spread
It's pulling down Code Coverage! ;-)
Right now, size is really stupid:
async function size(endpoint, params) {
return get(endpoint, params)
.then(res => res.length)
}
This can be improved by:
nodata: true
requests can be madevexdb
tries to do too much for the user. vexbot, which is one of the most in-depth uses for vexdb
never uses any of the advanced features, and basically only needs caching, nice type support, and getting all records on a request. Right now, vexdb is trying to do too many things, and it's inflating the source code.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.