mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-12-19 05:41:46 +03:00
ab5a115084
Also, semver wasn't even in package.json, it worked because a lot of deps use it
25 lines
613 B
JavaScript
25 lines
613 B
JavaScript
import { satisfies } from 'compare-versions';
|
|
|
|
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;
|