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

madata

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

madata - npm Package Compare versions

Comparing version 0.0.1-alpha.4 to 0.0.1-alpha.5

2

package.json
{
"name": "madata",
"version": "0.0.1-alpha.4",
"version": "0.0.1-alpha.5",
"description": "",

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

@@ -220,11 +220,19 @@ /**

Class = Backend[o.type];
if (!Class) {
throw new Error(`No backend found for type "${o.type}"`);
}
}
if (url && !Class) {
else {
// Find a suitable backend
// If none found, fall back to basic read-only URL loading
Class = Backend.find(url, o) ?? Backend.Remote;
if (url && this.all.length > 0) {
Class = this.find(url, o) ?? Backend.Remote;
}
else {
// No registered backends under this, use this directly
Class = this;
}
}
// Can we re-use the existing object perhaps?
// Can we re-use an existing object perhaps?
if (o.existing) {

@@ -243,12 +251,31 @@ let existing = toArray(o.existing)

static async load (url, o) {
return this.from(url, o)?.load(url, o);
let backend = this.from(url, o);
if (backend) {
return backend.load(url, o);
}
else {
throw new Error(`No backend found for ${url}`);
}
}
static _all = [];
// Get all descendant backends
static get all () {
if (this === Backend) {
return Backend._all;
}
return Backend._all.filter(backend => backend.prototype instanceof this);
}
static find (url, o) {
if (url) {
for (let backend of Backend.all) {
let backends = this.all;
for (let backend of backends) {
// Check first if backend is a descendant class of this
// This allows calling create on child classes to narrow the scope of the search
// And then if the URL is one of the URLs handlded by it
if (backend.prototype instanceof this && backend.test?.(url, o)) {
if (backend.test?.(url, o)) {
return backend;

@@ -262,7 +289,5 @@ }

static all = []
static register (Class) {
Backend[Class.name] = Class;
Backend.all.push(Class);
Backend._all.push(Class);
return Class;

@@ -269,0 +294,0 @@ }

@@ -43,3 +43,5 @@ /**

if (o?.accessToken) {
this.login({accessToken: o.accessToken});
if (this.accessToken !== o.accessToken) {
this.deleteLocalUserInfo();
}
}

@@ -155,3 +157,3 @@

*/
async login ({passive = false, accessToken, ...rest} = {}) {
async login ({passive = false, accessToken = this.options.accessToken, ...rest} = {}) {
if (this.ready) {

@@ -304,2 +306,3 @@ await this.ready;

localStorage.removeItem(this.constructor.tokenKey);
delete this.user;
delete this.accessToken;

@@ -306,0 +309,0 @@ }

Sorry, the diff of this file is not supported yet

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