-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
/
features.js
35 lines (31 loc) 路 1021 Bytes
/
features.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// @flow
export const FEATURES = Object.freeze({
unicodeFlag: 1 << 0,
dotAllFlag: 1 << 1,
unicodePropertyEscape: 1 << 2,
namedCaptureGroups: 1 << 3,
});
// We can't use a symbol because this needs to always be the same, even if
// this package isn't deduped by npm. e.g.
// - node_modules/
// - @babel/plugin-regexp-features
// - @babel/plugin-proposal-unicode-property-regex
// - node_modules
// - @babel-plugin-regexp-features
export const featuresKey = "@babel/plugin-regexp-features/featuresKey";
export const runtimeKey = "@babel/plugin-regexp-features/runtimeKey";
type unicodeFlag = 1;
type dotAllFlag = 2;
type unicodePropertyEscape = 4;
type namedCaptureGroups = 8;
type featureType =
| unicodeFlag
| dotAllFlag
| unicodePropertyEscape
| namedCaptureGroups;
export function enableFeature(features: number, feature: featureType): number {
return features | feature;
}
export function hasFeature(features: number, feature: featureType) {
return !!(features & feature);
}