mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-20 23:08:50 +01:00
26 lines
603 B
JavaScript
26 lines
603 B
JavaScript
|
import { satisfies } from 'semver';
|
||
|
|
||
|
import features from '../data/features.json';
|
||
|
|
||
|
import { getCurrentInstance } from './store-utils';
|
||
|
|
||
|
const supportsCache = {};
|
||
|
|
||
|
function supports(feature) {
|
||
|
try {
|
||
|
const { version, domain } = getCurrentInstance();
|
||
|
const key = `${domain}-${feature}`;
|
||
|
if (supportsCache[key]) return supportsCache[key];
|
||
|
const range = features[feature];
|
||
|
if (!range) return false;
|
||
|
return (supportsCache[key] = satisfies(version, range, {
|
||
|
includePrerelease: true,
|
||
|
loose: true,
|
||
|
}));
|
||
|
} catch (e) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export default supports;
|