1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | (function (global, factory) {
|
8 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
9 | typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
10 | (global = global || self, factory((global.ssw = global.ssw || {}, global.ssw.unicode8 = global.ssw.unicode8 || {}, global.ssw.unicode8.symbol = {})));
|
11 | }(this, (function (exports) { 'use strict';
|
12 |
|
13 | |
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | let re = {
|
21 | 'base': '(?:\uD836[\uDC00-\uDE8B])',
|
22 | 'fill': '(?:\uD836[\uDE9B-\uDE9F])',
|
23 | 'rotation': '(?:\uD836[\uDEA1-\uDEAF])'
|
24 | };
|
25 | re.full = `(${re.base})(${re.fill})?(${re.rotation})?`;
|
26 |
|
27 | |
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 | const parse = symbolString => {
|
43 | const regex = `^${re.full}`;
|
44 | const m = (typeof symbolString === 'string' ? symbolString.match(new RegExp(regex)) : []) || [];
|
45 | return {
|
46 | 'base': !m[1] ? undefined : m[1],
|
47 | 'fill': !m[2] ? undefined : m[2],
|
48 | 'rotation': !m[3] ? undefined : m[3]
|
49 | };
|
50 | };
|
51 |
|
52 | |
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 | const compose = symbolObject => {
|
69 | if (typeof symbolObject !== 'object' || symbolObject === null) return undefined;
|
70 | const sym = (symbolObject.base ? symbolObject.base : '') + (symbolObject.fill ? symbolObject.fill : '') + (symbolObject.rotation ? symbolObject.rotation : '');
|
71 | return sym ? sym : undefined;
|
72 | };
|
73 |
|
74 | exports.compose = compose;
|
75 | exports.parse = parse;
|
76 | exports.re = re;
|
77 |
|
78 | Object.defineProperty(exports, '__esModule', { value: true });
|
79 |
|
80 | })));
|
81 |
|
82 |
|