pulsar-edit / package-backend

Pulsar Server Backend for Packages
https://api.pulsar-edit.dev
MIT License
12 stars 11 forks source link

git refactoring: fixed PackageJSON pseudo object class #71

Closed Digitalone1 closed 1 year ago

Digitalone1 commented 1 year ago

Description of the Change

@confused-Techie In the past, for reasons I don't remember, I disabled Github notifications for having only email notifications and in the last days my provider is having issues delivering mails, so I wasn't notified at all about new changes to git refactoring (now I reenabled web notifications while email service is still down).

So I was testing the pseudo object and only at the end I discovered you deleted it.

But, anyway, I did this and wanted to show you. Then, if we don't need it, you can discard the PR.

I tested the pseudo object PackageJSON class on jsfiddle and saw little issues, so I started to fix them. You can test it here.

I added private properties and fixed the getters/setters. In practice some pseudo properties were retrieved and self-assigned into both getters and setters and this was leading to an infinite loop because getter and setter were invoked over and over. So I fixed that with different protected properties and methods.

Basically this is not allowed:

get name() {
  // ...
  this.name = this._name:
  // ...
}

set name(v) {
  // ...
  this._name = this.name:
  // ...
}

Please, take a look at it and test here if you want (reload Javascript 1.7 in language option and signaled errors will disappear).

If you feel this is worth to be reintroduced, merge it, otherwise just close.

confused-Techie commented 1 year ago

@Digitalone1 So while I really do appreciate all this effort, yeah I'm sorry I ended up totally removing it.

For what I wanted that to do just become to large scope for including it directly.

I've restructure things quite a bit, but if you'd like all that code and a lot more was moved over to my package repo.

Essentially the idea there is to have a NPM module at @confused-techie/package that can either do one of these things, or in a perfect world do all of these.

The first 2 are what it currently does. The last one is what I'd really want to use here.

For example for the backend and frontend instead of checking package.author or looking at package.repository and using regex to see if any of those match the author type you are looking for or then finally checking package.author.name and so on. You could just use package.get("author"); and it will automatically search all those locations and parse them appropriatly.

That way we could reduce the complexity here and keep the responsibility seperate.

But obviously that repo is far far off from doing that.


I'll definitely look over this code out of curiosity, but will likely close it. And if I end up reintroducing this into my other repo will list you as co-author for those commits. Otherwise feel free to take a look at it.

Digitalone1 commented 1 year ago

No problem. So I close it. If you want to take a look at it in the future, you know where to find it.