Total Complexity | 2 |
Complexity/F | 1 |
Lines of Code | 46 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | /// <reference path="./config-types.d.ts"/> |
||
2 | |||
3 | export {} |
||
4 | |||
5 | const options = { |
||
6 | current: { |
||
7 | elementDelimiter: "__" as const, |
||
8 | modDelimiter: "--" as const, |
||
9 | blockModKey: "$" as const, |
||
10 | } |
||
11 | } |
||
12 | |||
13 | |||
14 | export { |
||
15 | setOpts, getOpts |
||
16 | } |
||
17 | |||
18 | function setOpts<e extends string, m extends string, b extends string>( |
||
19 | elementDelimiter: e, |
||
20 | modDelimiter: m, |
||
21 | blockModKey: b |
||
22 | ) { |
||
23 | const current = { |
||
24 | elementDelimiter, |
||
25 | modDelimiter, |
||
26 | blockModKey |
||
27 | } |
||
28 | |||
29 | //@ts-expect-error |
||
30 | options.current = current |
||
31 | } |
||
32 | |||
33 | function getOpts() { |
||
34 | return options.current as { |
||
35 | elementDelimiter: "elementDelimiter" extends keyof Bem.Options |
||
36 | ? Bem.Options["elementDelimiter"] |
||
37 | : Bem.Options["$default"]["elementDelimiter"] |
||
38 | modDelimiter: "modDelimiter" extends keyof Bem.Options |
||
39 | ? Bem.Options["modDelimiter"] |
||
40 | : Bem.Options["$default"]["modDelimiter"] |
||
41 | blockModKey: |
||
42 | "blockModKey" extends keyof Bem.Options |
||
43 | ? Bem.Options["blockModKey"] |
||
44 | : Bem.Options["$default"]["blockModKey"] |
||
45 | } |
||
46 | } |