How to deduce p5.js version?

This is a rhetorical question, I have already solved it. I thought I’d publish my method.

I’ve proposed to p5.js on more than one occasion that an accessible release number would be useful, but they seem very reluctant to do that.

So, here’s my method. Hope it helps somewhere.

  if(typeof deltaTime === "number" ) p5version = "0.9.0 or later";    
  else if (typeof resetShader === "function") p5version = "0.8.0";
  else if (typeof circle === "function") p5version = "0.7.3";
  else p5version = "0.7.2 or earlier" 

Thanks for sharing this!

Should the “0.8.0” and “0.7.3” be given as ranges as well?

Is there an open issue / feature request?

Hi Jeremy,

I think the 0.8.0 and 0.7.3 are precise. Those features were introduced at those revs. The test runs from the top down, and tries to find the latest rev it can be. “0.9.0 or later” is just there because 0.9.1, 0.10.0 etc. might have further distinguishing features but we don’t know them yet. “0.7.2 or earlier” is just because I didn’t bother to progress further back. I have some code that runs properly at 0.7.3, but breaks at 0.8.0 or later, and also needs features not available at 0.7.2, and I like to have a warning in it about that. (I can’t make the time at present to update that code). The 0.8.0 to 0.9.0 transition has not broken anything for me, which is great.

Re. open issues, here’s the main one, which produced some useful discussion, but didn’t progress.

Rgds, GE.

1 Like

Ah, I see. Because there is no eg 7.4 or 7.5 release, these aren’t ranges. Got it!

Yup. Sorry, I should have mentioned that. Ciao.