I have a situation where I have an API version and my web frontend is aware of that version at application start. When doing live updates of the backend, I want to be able to decide which connections coming from frontend can be considered API stable with my backend (does this make sense?).
Example
- Server runs version
0.1.2
- User starts and thus now runs on version
0.1.2
- Server application gets upgraded to
0.1.3
- User interacts with server, but now there is a version mismatch.
In this case, I want to say 0.1.2 satisfies 0.1.x, so the APIs are compatible. Because all version information comes from variables here, I'm wondering how I should go about generating the 0.1.x range, or >=0.1.0 <0.2.0 range. To generate the latter I was thinking of this:
var version = '0.1.2';
var str = '>=' + semver.truncate(version, 'patch') + ' <' + semver.inc(version, 'minor');
// now do a satisfies check
The inc() method already exists, but truncate() does not. Do you think it would make sense to add a method like that?
I have a situation where I have an API version and my web frontend is aware of that version at application start. When doing live updates of the backend, I want to be able to decide which connections coming from frontend can be considered API stable with my backend (does this make sense?).
Example
0.1.20.1.20.1.3In this case, I want to say
0.1.2satisfies0.1.x, so the APIs are compatible. Because all version information comes from variables here, I'm wondering how I should go about generating the0.1.xrange, or>=0.1.0 <0.2.0range. To generate the latter I was thinking of this:The
inc()method already exists, buttruncate()does not. Do you think it would make sense to add a method like that?