add feature flag stuff

Signed-off-by: Katalina Okano <git@kat.cafe>
This commit is contained in:
41666 2021-07-27 23:03:00 -04:00
parent 3074db0a21
commit dde05c402e
4 changed files with 53 additions and 0 deletions

View file

@ -0,0 +1,8 @@
import { Features } from '@roleypoly/types';
import { hasFeature } from './hasFeature';
it('correctly matches against features', () => {
const features = Features.LegacyGuild;
expect(hasFeature(Features.LegacyGuild, features)).toBe(true);
expect(hasFeature(Features.LegacyGuild, Features.None)).toBe(false);
});

View file

@ -0,0 +1,5 @@
import { Features } from '@roleypoly/types';
export const hasFeature = (feature: Features, features: number): boolean => {
return (features & feature) === feature;
};