UNPKG

6.13 kBJavaScriptView Raw
1/**
2 * A record of a white space character.
3 *
4 * @typedef {object} CharRecord
5 * @property {number} code - The character code.
6 * @property {string} description - A description of the character.
7 * @property {boolean} es5 - Whether the spec lists this as a white space.
8 * @property {boolean} es2015 - Whether the spec lists this as a white space.
9 * @property {boolean} es2016 - Whether the spec lists this as a white space.
10 * @property {boolean} es2017 - Whether the spec lists this as a white space.
11 * @property {boolean} es2018 - Whether the spec lists this as a white space.
12 * @property {string} string - The character string.
13 */
14
15/**
16 * An array of the whitespace char codes, string, descriptions and language
17 * presence in the specifications.
18 *
19 * @type Array.<CharRecord>
20 */
21export const list = [
22 {
23 code: 0x0009,
24 description: 'Tab',
25 es5: true,
26 es2015: true,
27 es2016: true,
28 es2017: true,
29 es2018: true,
30 string: '\u0009',
31 },
32 {
33 code: 0x000a,
34 description: 'Line Feed',
35 es5: true,
36 es2015: true,
37 es2016: true,
38 es2017: true,
39 es2018: true,
40 string: '\u000a',
41 },
42 {
43 code: 0x000b,
44 description: 'Vertical Tab',
45 es5: true,
46 es2015: true,
47 es2016: true,
48 es2017: true,
49 es2018: true,
50 string: '\u000b',
51 },
52 {
53 code: 0x000c,
54 description: 'Form Feed',
55 es5: true,
56 es2015: true,
57 es2016: true,
58 es2017: true,
59 es2018: true,
60 string: '\u000c',
61 },
62 {
63 code: 0x000d,
64 description: 'Carriage Return',
65 es5: true,
66 es2015: true,
67 es2016: true,
68 es2017: true,
69 es2018: true,
70 string: '\u000d',
71 },
72 {
73 code: 0x0020,
74 description: 'Space',
75 es5: true,
76 es2015: true,
77 es2016: true,
78 es2017: true,
79 es2018: true,
80 string: '\u0020',
81 },
82 /*
83 {
84 code: 0x0085,
85 description: 'Next line',
86 es5: false,
87 es2015: false,
88 es2016: false,
89 es2017: false,
90 es2018: false,
91 string: '\u0085'
92 }
93 */
94 {
95 code: 0x00a0,
96 description: 'No-break space',
97 es5: true,
98 es2015: true,
99 es2016: true,
100 es2017: true,
101 es2018: true,
102 string: '\u00a0',
103 },
104 {
105 code: 0x1680,
106 description: 'Ogham space mark',
107 es5: true,
108 es2015: true,
109 es2016: true,
110 es2017: true,
111 es2018: true,
112 string: '\u1680',
113 },
114 {
115 code: 0x180e,
116 description: 'Mongolian vowel separator',
117 es5: true,
118 es2015: true,
119 es2016: true,
120 es2017: false,
121 es2018: false,
122 string: '\u180e',
123 },
124 {
125 code: 0x2000,
126 description: 'En quad',
127 es5: true,
128 es2015: true,
129 es2016: true,
130 es2017: true,
131 es2018: true,
132 string: '\u2000',
133 },
134 {
135 code: 0x2001,
136 description: 'Em quad',
137 es5: true,
138 es2015: true,
139 es2016: true,
140 es2017: true,
141 es2018: true,
142 string: '\u2001',
143 },
144 {
145 code: 0x2002,
146 description: 'En space',
147 es5: true,
148 es2015: true,
149 es2016: true,
150 es2017: true,
151 es2018: true,
152 string: '\u2002',
153 },
154 {
155 code: 0x2003,
156 description: 'Em space',
157 es5: true,
158 es2015: true,
159 es2016: true,
160 es2017: true,
161 es2018: true,
162 string: '\u2003',
163 },
164 {
165 code: 0x2004,
166 description: 'Three-per-em space',
167 es5: true,
168 es2015: true,
169 es2016: true,
170 es2017: true,
171 es2018: true,
172 string: '\u2004',
173 },
174 {
175 code: 0x2005,
176 description: 'Four-per-em space',
177 es5: true,
178 es2015: true,
179 es2016: true,
180 es2017: true,
181 es2018: true,
182 string: '\u2005',
183 },
184 {
185 code: 0x2006,
186 description: 'Six-per-em space',
187 es5: true,
188 es2015: true,
189 es2016: true,
190 es2017: true,
191 es2018: true,
192 string: '\u2006',
193 },
194 {
195 code: 0x2007,
196 description: 'Figure space',
197 es5: true,
198 es2015: true,
199 es2016: true,
200 es2017: true,
201 es2018: true,
202 string: '\u2007',
203 },
204 {
205 code: 0x2008,
206 description: 'Punctuation space',
207 es5: true,
208 es2015: true,
209 es2016: true,
210 es2017: true,
211 es2018: true,
212 string: '\u2008',
213 },
214 {
215 code: 0x2009,
216 description: 'Thin space',
217 es5: true,
218 es2015: true,
219 es2016: true,
220 es2017: true,
221 es2018: true,
222 string: '\u2009',
223 },
224 {
225 code: 0x200a,
226 description: 'Hair space',
227 es5: true,
228 es2015: true,
229 es2016: true,
230 es2017: true,
231 es2018: true,
232 string: '\u200a',
233 },
234 /*
235 {
236 code: 0x200b,
237 description: 'Zero width space',
238 es5: false,
239 es2015: false,
240 es2016: false,
241 es2017: false,
242 es2018: false,
243 string: '\u200b'
244 },
245 */
246 {
247 code: 0x2028,
248 description: 'Line separator',
249 es5: true,
250 es2015: true,
251 es2016: true,
252 es2017: true,
253 es2018: true,
254 string: '\u2028',
255 },
256 {
257 code: 0x2029,
258 description: 'Paragraph separator',
259 es5: true,
260 es2015: true,
261 es2016: true,
262 es2017: true,
263 es2018: true,
264 string: '\u2029',
265 },
266 {
267 code: 0x202f,
268 description: 'Narrow no-break space',
269 es5: true,
270 es2015: true,
271 es2016: true,
272 es2017: true,
273 es2018: true,
274 string: '\u202f',
275 },
276 {
277 code: 0x205f,
278 description: 'Medium mathematical space',
279 es5: true,
280 es2015: true,
281 es2016: true,
282 es2017: true,
283 es2018: true,
284 string: '\u205f',
285 },
286 {
287 code: 0x3000,
288 description: 'Ideographic space',
289 es5: true,
290 es2015: true,
291 es2016: true,
292 es2017: true,
293 es2018: true,
294 string: '\u3000',
295 },
296 {
297 code: 0xfeff,
298 description: 'Byte Order Mark',
299 es5: true,
300 es2015: true,
301 es2016: true,
302 es2017: true,
303 es2018: true,
304 string: '\ufeff',
305 },
306];
307
308/**
309 * A string of the ES5 to ES2016 whitespace characters.
310 *
311 * @type string
312 */
313let stringES2016 = '';
314
315/**
316 * A string of the ES2017 to ES2018 whitespace characters.
317 *
318 * @type string
319 */
320let stringES2018 = '';
321const {length} = list;
322for (let i = 0; i < length; i += 1) {
323 if (list[i].es2016) {
324 stringES2016 += list[i].string;
325 }
326
327 if (list[i].es2018) {
328 stringES2018 += list[i].string;
329 }
330}
331
332const string2018 = stringES2018;
333
334export default string2018;
335export const string2016 = stringES2016;