bt-core-app 1.4.2 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/package.json +8 -2
  2. package/dist/useApi.d.ts +0 -0
  3. package/src/assets/vue.svg +0 -1
  4. package/src/components/BT-Btn.vue +0 -41
  5. package/src/components/BT-Col.vue +0 -36
  6. package/src/components/BT-Field-Checkbox.vue +0 -70
  7. package/src/components/BT-Field-Date.vue +0 -108
  8. package/src/components/BT-Field-Entity.vue +0 -48
  9. package/src/components/BT-Field-Select.vue +0 -67
  10. package/src/components/BT-Field-String.vue +0 -78
  11. package/src/components/BT-Field-Switch.vue +0 -68
  12. package/src/components/BT-Field-Tags.vue +0 -66
  13. package/src/components/BT-Field-Textarea.vue +0 -67
  14. package/src/components/BT-Field-Trigger.vue +0 -315
  15. package/src/components/BT-Header-Option.vue +0 -39
  16. package/src/components/BT-Json.vue +0 -67
  17. package/src/components/BT-Nav-Menu-Item.vue +0 -60
  18. package/src/components/BT-Nav-Sidebar.vue +0 -78
  19. package/src/components/BT-Select-List-Box.vue +0 -258
  20. package/src/components/BT-Select.vue +0 -46
  21. package/src/components/BT-Snack.vue +0 -31
  22. package/src/components/BT-Span.vue +0 -21
  23. package/src/components/Dialog-Confirm.vue +0 -47
  24. package/src/components/Dialog-Select-Date.vue +0 -89
  25. package/src/components/Dialog-Select.vue +0 -140
  26. package/src/components/Dialog-Text.vue +0 -59
  27. package/src/composables/actions-tracker.ts +0 -99
  28. package/src/composables/actions.ts +0 -354
  29. package/src/composables/api.ts +0 -479
  30. package/src/composables/auth.ts +0 -452
  31. package/src/composables/cosmetics.ts +0 -177
  32. package/src/composables/csv.ts +0 -198
  33. package/src/composables/dates.ts +0 -86
  34. package/src/composables/demo.ts +0 -33
  35. package/src/composables/dialogs.ts +0 -114
  36. package/src/composables/document-meta.ts +0 -44
  37. package/src/composables/draggable.ts +0 -189
  38. package/src/composables/filters.ts +0 -264
  39. package/src/composables/forage.ts +0 -49
  40. package/src/composables/helpers.ts +0 -647
  41. package/src/composables/id.ts +0 -20
  42. package/src/composables/list.ts +0 -604
  43. package/src/composables/navigation.ts +0 -222
  44. package/src/composables/presets.ts +0 -28
  45. package/src/composables/pwa.ts +0 -97
  46. package/src/composables/resizable.ts +0 -382
  47. package/src/composables/rules.ts +0 -40
  48. package/src/composables/stores.ts +0 -818
  49. package/src/composables/track.ts +0 -55
  50. package/src/composables/urls.ts +0 -66
  51. package/src/core.ts +0 -113
  52. package/src/index.ts +0 -48
  53. package/src/types.ts +0 -17
  54. package/src/useApi.ts +0 -68
  55. package/src/vite-env.d.ts +0 -1
  56. package/test/api.test.ts +0 -84
  57. package/test/auth.test.ts +0 -74
  58. package/test/forage.test.ts +0 -31
  59. package/test/helpers.test.ts +0 -231
  60. package/test/navigation.test.ts +0 -99
  61. package/test/stores-last-update.test.ts +0 -138
  62. package/test/stores-session.test.ts +0 -118
  63. package/test/track.test.ts +0 -29
  64. package/test/urls.test.ts +0 -42
  65. package/test/utils.ts +0 -15
  66. package/tsconfig.json +0 -28
  67. package/tsconfig.node.json +0 -11
  68. package/vite.config.ts +0 -45
@@ -1,647 +0,0 @@
1
- import { firstBy } from 'thenby'
2
-
3
- export function appendUrl(originalVal?: string, additionalVal?: string) {
4
- let original = originalVal ?? ''
5
- let additional = additionalVal ?? ''
6
-
7
- if (original.endsWith('/')) {
8
- do {
9
- original = original.slice(0, original.length - 1)
10
- } while (original.endsWith('/'));
11
- }
12
-
13
- if (additional.startsWith('/')) {
14
- do {
15
- additional = additional.slice(1, additional.length)
16
- } while (additional.startsWith('/'));
17
- }
18
-
19
- return `${original}/${additional}`
20
- }
21
-
22
- export function extensionExists(elementId: string = 'blitzItExtensionExists') {
23
- try {
24
- var el = document.getElementById(elementId);
25
- return el != null;
26
- }
27
- catch (ex) {
28
- console.log(extractErrorDescription(ex));
29
- return false;
30
- }
31
- }
32
-
33
- //#region area and space
34
-
35
- interface GeoCoordinate {
36
- lat: number
37
- lng: number
38
- }
39
-
40
- // /**
41
- // * confirms if area is a certain size
42
- // * @param boundary array of 4 x { lat: number, lng: number }
43
- // * @param size
44
- // * @returns
45
- // */
46
- // export function isAreaOfSize(boundary?: GeoCoordinate[], size?: number) {
47
- // if (boundary == null || size == null || boundary.length != 4) {
48
- // return false;
49
- // }
50
-
51
- // var middleLat = boundary[0].lat + size;
52
- // var middleLng = boundary[0].lng - size;
53
-
54
- // if ((boundary[1].lat + size) != middleLat) {
55
- // return false;
56
- // }
57
- // if ((boundary[1].lng + size) != middleLng) {
58
- // return false;
59
- // }
60
-
61
- // if ((boundary[2].lat - size) != middleLat) {
62
- // return false;
63
- // }
64
- // if ((boundary[2].lng + size) != middleLng) {
65
- // return false;
66
- // }
67
-
68
- // if ((boundary[3].lat - size) != middleLat) {
69
- // return false;
70
- // }
71
- // if ((boundary[3].lng - size) != middleLng) {
72
- // return false;
73
- // }
74
-
75
- // return true;
76
- // }
77
-
78
- /**
79
- * get area around a certain location with a space of the given size
80
- * @param location
81
- * @param radius
82
- * @returns
83
- */
84
- export function getAreaAround(location: GeoCoordinate, radius: number) {
85
- return [
86
- { lat: location.lat - radius, lng: location.lng + radius },
87
- { lat: location.lat - radius, lng: location.lng - radius },
88
- { lat: location.lat + radius, lng: location.lng - radius },
89
- { lat: location.lat + radius, lng: location.lng + radius }
90
- ];
91
- }
92
-
93
- /**get square area using the location as the far right line */
94
- export function getAreaToLeft(location: GeoCoordinate, radius: number) {
95
- return [
96
- { lat: location.lat - (radius * 2), lng: location.lng + radius },
97
- { lat: location.lat - (radius * 2), lng: location.lng - radius },
98
- { lat: location.lat, lng: location.lng - radius },
99
- { lat: location.lat, lng: location.lng + radius }
100
- ];
101
- }
102
-
103
- /**get square area using the location as the far left line */
104
- export function getAreaToRight(location: GeoCoordinate, radius: number) {
105
- return [
106
- { lat: location.lat, lng: location.lng + radius },
107
- { lat: location.lat, lng: location.lng - radius },
108
- { lat: location.lat + (radius * 2), lng: location.lng - radius },
109
- { lat: location.lat + (radius * 2), lng: location.lng + radius }
110
- ];
111
- }
112
-
113
- //#endregion
114
-
115
- //#region locations
116
-
117
- /**
118
- *
119
- * @param value converts location to a single string and standardizes state and road names, etc.
120
- * @returns
121
- */
122
- export function getGoogleMapsLocationLine(value: any) {
123
- var str = getLocationLine(value, true);
124
-
125
- str = str.toLowerCase(); //str.replaceAll(' ', '').toLowerCase();
126
- //replace values
127
- str = str.replace(' victoria ', 'vic');
128
- str = str.replace(' queensland ', 'qld');
129
- str = str.replace(' new south wales ', 'nsw');
130
- str = str.replace(' northern territory ', 'nt');
131
- str = str.replace(' western australia ', 'wa');
132
- str = str.replace(' tasmania ', 'tas');
133
- str = str.replace(' south australia ', 'sa');
134
- str = str.replace(' australian captial territory ', 'act');
135
-
136
- str = str.replace(' & ', ' and ');
137
- str = str.replace(' road', ' rd');
138
- str = str.replace(' street', ' st');
139
- str = str.replace(' lane', ' ln');
140
- str = str.replace(' alley', ' aly');
141
- str = str.replace(' arcade', ' arc');
142
- str = str.replace(' boulevard', ' blvd');
143
- str = str.replace(' court', ' ct');
144
- str = str.replace(' cove', ' cv');
145
- str = str.replace(' highway', ' hwy');
146
-
147
- return str.replaceAll(' ', '');
148
- }
149
-
150
- export function getLocationLine(value: any, forGoogle: boolean = false) {
151
- if (value == null) {
152
- return '';
153
- }
154
-
155
- if (typeof value !== 'object') {
156
- return value;
157
- }
158
-
159
- var rStr = '';
160
-
161
- if (value.addressLineOne != null && !forGoogle) {
162
- rStr = value.addressLineOne + ' ';
163
- }
164
- if (value.streetNumber != null) {
165
- rStr = rStr + value.streetNumber + ' ';
166
- }
167
- if (value.streetName != null) {
168
- rStr = rStr + value.streetName + ', ';
169
- }
170
- if (value.suburb != null) {
171
- rStr = rStr + value.suburb + ' ';
172
- }
173
- if (value.state != null) {
174
- rStr = rStr + value.state + ' ';
175
- }
176
- if (value.postcode != null) {
177
- rStr = rStr + value.postcode;
178
- }
179
-
180
- return rStr;
181
- }
182
-
183
-
184
-
185
- //#endregion
186
-
187
- //#region images
188
-
189
- export function checkImage(url?: string, goodCallback?: any, badCallback?: any) {
190
- if (!url)
191
- return
192
-
193
- var img = new Image();
194
- img.onload = goodCallback;
195
- img.onerror = badCallback;
196
- img.src = url;
197
- }
198
-
199
- export async function getImageData(url?: string, throwErrorOnFail: boolean = true) {
200
- return new Promise((resolve, reject) => {
201
- if (url == null)
202
- reject('no url given')
203
-
204
- var img = new Image();
205
- img.setAttribute('crossOrigin', 'anonymous');
206
- img.onload = function () {
207
- var canvas = document.createElement('canvas');
208
- //@ts-ignore
209
- canvas.width = this.width;
210
- //@ts-ignore
211
- canvas.height = this.height;
212
-
213
- var ctx = canvas.getContext('2d');
214
-
215
- //@ts-ignore
216
- ctx?.drawImage(this, 0, 0);
217
-
218
- resolve(canvas.toDataURL('image/png'));
219
- };
220
-
221
- img.onerror = function () {
222
- console.log('errr');
223
- if (throwErrorOnFail) {
224
- reject('image could not be loaded for some reason');
225
- }
226
- else {
227
- resolve(null);
228
- }
229
- };
230
-
231
- if (url != null)
232
- img.src = url;
233
- })
234
- }
235
-
236
- //#endregion
237
-
238
- //#region string and character
239
-
240
- /**
241
- *
242
- * @param val Converts string from camel case to every word being capitalized and spaces between
243
- * @returns
244
- */
245
- export function fromCamelCase(val?: string) {
246
- if (!val)
247
- return val
248
-
249
- return val
250
- .replace(/([A-Z])/g, ' $1')
251
- .replace(/^./, (str) => {
252
- return str.toUpperCase();
253
- })
254
- }
255
-
256
- /**
257
- * Converts props to camel casing
258
- * @param value
259
- * @returns
260
- */
261
- export function toCamelCase(value: any) { //for JSON parse
262
- if (value != null && typeof value === 'object'){
263
- for (var k in value) {
264
- if (/^[A-Z]/.test(k) && Object.hasOwnProperty.call(value, k)) {
265
- value[k.charAt(0).toLowerCase() + k.substring(1)] = value[k];
266
- delete value[k];
267
- }
268
- }
269
- }
270
- return value;
271
- }
272
-
273
-
274
- export function capitalizeWords(val?: string) {
275
- if (val == null)
276
- return val
277
-
278
- return val.replace(/\w\S*/g, (w) => (w.replace(/^\w/, (c) => c.toUpperCase())));
279
- }
280
-
281
- //#endregion
282
-
283
- //#region weekday
284
-
285
- export const weekdayPairs = [
286
- { value: 1, short: 'sun', values: ['sun', 'sunday'] },
287
- { value: 2, short: 'mon', values: ['mon', 'monday'] },
288
- { value: 3, short: 'tue', values: ['tue', 'tues', 'tuesday'] },
289
- { value: 4, short: 'wed', values: ['wed', 'wednesday'] },
290
- { value: 5, short: 'thu', values: ['thu', 'thur', 'thurs', 'thursday'] },
291
- { value: 6, short: 'fri', values: ['fri', 'friday'] },
292
- { value: 7, short: 'sat', values: ['sat', 'saturday'] },
293
- { value: 0, short: 'always', values: ['always', null, undefined] }
294
- ]
295
-
296
- /**returns the sort value of the weekday csv string
297
- * returns minimum if csv list
298
- */
299
- export function weekdayValue(wkDay?: string) {
300
- if (wkDay == null) {
301
- return 0
302
- }
303
-
304
- const wkDaySplit = wkDay.replaceAll(' ', '').split(',').map(z => z.toLowerCase())
305
- const valList = weekdayPairs.filter(x => x.values.some(v => wkDaySplit.some(s => v == s))).map(z => z.value)
306
- if (valList.length == 0)
307
- return 8
308
-
309
- return Math.min(...valList)
310
- }
311
-
312
- /**returns the sort value of the weekday csv string
313
- * returns minimum if csv list
314
- */
315
- export function weekdayShortName(wkDay?: string) {
316
- if (wkDay == null) {
317
- return wkDay
318
- }
319
-
320
- return wkDay.toLowerCase().replaceAll(' ', '').split(',').map(day => {
321
- let pair = weekdayPairs.find(x => x.values.some(v => v == day))
322
- return pair != null ? pair.short : ''
323
- }).filter(z => z != null && z.length > 0).toString()
324
-
325
- // const valList = weekdayPairs.filter(x => x.values.some(v => wkDaySplit.some(s => v == s))).map(z => z.short)
326
- // if (valList.length == 0)
327
- // return 8
328
-
329
- // return Math.min(...valList)
330
- }
331
-
332
- /**whether the csv string contains the weekday
333
- * returns true if either prop is undefined
334
- */
335
- export function containsWeekday(weekdays?: string, wkDay?: string) {
336
- if (weekdays == null || wkDay == null) {
337
- return true;
338
- }
339
-
340
- const wkDaySplit = weekdays.replaceAll(' ', '').split(',').map(z => z.toLowerCase())
341
- const weekday = wkDay.replaceAll(' ', '').toLowerCase()
342
- const pair = weekdayPairs.find(pair => pair.values.some(v => v == weekday))
343
- return pair != null && wkDaySplit.some(s => s == pair.short || pair.values.some(v => v == s))
344
- }
345
-
346
- /**adds and sorts the weekday string */
347
- export function addWeekday(weekdays?: string, day?: string) {
348
- if (day == null) {
349
- return weekdays;
350
- }
351
-
352
- let wDays = weekdays ?? ''
353
- wDays = `${wDays},${day}`
354
-
355
- let res = [...new Set(wDays.replaceAll(' ', '').toLowerCase().split(',').map(z => {
356
- return weekdayPairs.find(x => x.values.some(v => v == z))
357
- })
358
- .filter(z => z != null)
359
- .sort(firstBy(z => z?.value ?? 0))
360
- .map(z => z?.short))].toString()
361
-
362
- return res.length > 0 ? res : undefined
363
- }
364
-
365
- export function removeWeekday(weekdays?: string, day?: string) {
366
- if (day == null || weekdays == null) {
367
- return weekdays;
368
- }
369
-
370
- let wDays = weekdays ?? ''
371
- let wDay = day.replaceAll(' ', '').toLowerCase()
372
-
373
- let res = [...new Set(wDays.replaceAll(' ', '').toLowerCase().split(',').map(z => {
374
- return weekdayPairs.find(x => x.values.some(v => v == z && v != wDay))
375
- })
376
- .filter(z => z != null)
377
- .sort(firstBy(z => z?.value ?? 0))
378
- .map(z => z?.short))].toString()
379
-
380
- return res.length > 0 ? res : undefined
381
- }
382
-
383
- //#endregion
384
-
385
- //region arrays
386
-
387
- export function isArrayOfLength(val: any, l: number) {
388
- return val != null && Array.isArray(val) && val.length == l;
389
- }
390
-
391
- export function isLengthyArray(val: any, greaterThan: number = 0) {
392
- return val != null && Array.isArray(val) && val.length > greaterThan
393
- }
394
-
395
- //#endregion
396
-
397
- //#region dates
398
-
399
- export function isMinDate(d?: string) {
400
- return '0001-01-01T00:00:00Z' == d;
401
- }
402
-
403
- export function getMinDate() {
404
- return new Date('0001-01-01T00:00:00Z').getTime();
405
- }
406
-
407
- export function getMinDateString() {
408
- return '0001-01-01T00:00:00Z'
409
- }
410
-
411
- /**
412
- * rounds the given value to a certain number of decimal places
413
- * @param v
414
- * @param dPlaces
415
- * @returns
416
- */
417
- export function roundTo(val: number, dPlaces: number) {
418
- let m = '1';
419
- let i = 0;
420
-
421
- if (i < dPlaces) {
422
- do {
423
- m = m + '0';
424
- i += 1;
425
- } while (i < dPlaces);
426
- }
427
-
428
- let d = Number.parseInt(m);
429
-
430
- return Math.round(val * d) / d;
431
- }
432
-
433
- //#endregion
434
-
435
- //#region csv
436
-
437
- export function toggleCSV(value?: string, tag?: string) {
438
- let rVal = value ?? ''
439
- if (tag != null) {
440
- if (csvContains(rVal, tag)) {
441
- //remove
442
- rVal = rVal.split(',').filter(x => x != tag).toString();
443
- }
444
- else {
445
- //add
446
- if (rVal != null) {
447
- rVal = `${rVal},${tag}`;
448
- }
449
- else {
450
- rVal = tag;
451
- }
452
- }
453
- }
454
-
455
- return rVal != null && rVal.length > 0 ? rVal : null
456
- }
457
-
458
- export function csvContains(value?: string, tag?: string) {
459
- if (value == null || value.length == 0) {
460
- return false;
461
- }
462
-
463
- if (!tag) {
464
- return true;
465
- }
466
-
467
- var csvList = value.split(',');
468
- var tagList = tag.split(',');
469
-
470
- return csvList.some(x => tagList.some(y => y == x));
471
- }
472
-
473
- //#end region
474
-
475
- /**copies object and all descendant properties */
476
- export function copyDeep(aObject: any) {
477
- if (!aObject) {
478
- return aObject;
479
- }
480
- let v;
481
- let bObject: any = Array.isArray(aObject) ? [] : {};
482
- for (const k in aObject) {
483
- v = aObject[k];
484
- bObject[k] = (typeof v === 'object') ? copyDeep(v) : v;
485
- }
486
-
487
- return bObject;
488
- }
489
-
490
- /**copies object and returns copied object with descendant properties placed in alphabetical order */
491
- export function copyItemByAlphabet(aObject: any) {
492
- if (!aObject) {
493
- return aObject;
494
- }
495
- return Object.keys(aObject)
496
- .sort()
497
- .reduce(function (acc: any, key) {
498
- let v = aObject[key];
499
- acc[key] = (typeof v === 'object' && v !== null) ? copyItemByAlphabet(v) : v;
500
- return acc;
501
- }, Array.isArray(aObject) ? [] : {});
502
- }
503
-
504
- /**whether string is contained somewhere in this value */
505
- export function containsSearch(value?: string, str?: string) {
506
- if (str == null) {
507
- return true;
508
- }
509
- if (value == null) {
510
- return false;
511
- }
512
-
513
- return value.toLowerCase().includes(str.toLowerCase());
514
- }
515
-
516
- /**must be an object. Returns a flat map of all items in the prop selector */
517
- export function deepSelect(obj: any, propSelector: Function = (obj: any) => obj) {
518
- if (obj == null) {
519
- return []
520
- }
521
-
522
- const arr = Array.isArray(obj) ? obj : propSelector(obj)
523
-
524
- if (!isLengthyArray(arr)) {
525
- return []
526
- }
527
-
528
- return [...arr.reduce((a: any, b: any) => {
529
- a.push(b)
530
- const v = deepSelect(b, propSelector)
531
- if (isLengthyArray(v)) {
532
- a.push(...v)
533
- }
534
- return a
535
- }, [])]
536
- }
537
-
538
- export function DataURIToBlob(dataURI: any) {
539
- const splitDataURI = dataURI.split(',')
540
- const byteString = splitDataURI[0].indexOf('base64') >= 0 ? atob(splitDataURI[1]) : decodeURI(splitDataURI[1])
541
- const mimeString = splitDataURI[0].split(':')[1].split(';')[0]
542
-
543
- const ia = new Uint8Array(byteString.length)
544
- for (let i = 0; i < byteString.length; i++)
545
- ia[i] = byteString.charCodeAt(i)
546
-
547
- return new Blob([ia], { type: mimeString })
548
- }
549
-
550
-
551
- export function extractErrorDescription(error: any) {
552
- var msg = '';
553
- if (error) {
554
- if (error.message)
555
- msg = error.message
556
-
557
- if (error.response && error.response.data) {
558
- if (error.response.data.errors) {
559
- for (var i = 0; i < error.response.data.errors.length; i++) {
560
- msg = msg + ' | ' + error.response.data.errors[i];
561
- }
562
- }
563
- if (error.response.data.message) {
564
- msg = msg + ' | ' + error.response.data.message;
565
- }
566
-
567
- msg = msg + ' | ' + JSON.stringify(error.response.data);
568
- }
569
-
570
- return msg;
571
- }
572
-
573
- return 'hmmm no error was supplied';
574
- }
575
-
576
- export function getRandomColor() {
577
- const rColor = "#" + Math.floor(Math.random() * 16777215).toString(16);
578
- if (rColor.length !== 7) {
579
- return getRandomColor();
580
- } else {
581
- return rColor;
582
- }
583
- }
584
-
585
- /**tests for whether string is contains in any of the given props of the given value */
586
- export function hasSearch(value: any, str?: string, props?: string[]) {
587
- if (str == null) {
588
- return true;
589
- }
590
-
591
- if (value == null || props == null) {
592
- return false;
593
- }
594
-
595
- for (let i = 0; i < props.length; i++) {
596
- const propName = props[i];
597
- var propVal = nestedValue(value, propName);
598
- if (propVal != undefined) {
599
- if (typeof(propVal) === 'string') {
600
- if (containsSearch(propVal, str)) {
601
- return true;
602
- }
603
- }
604
- }
605
- }
606
-
607
- return false;
608
- }
609
-
610
- export function toCompareString(str?: string) {
611
- if (str != null) {
612
- return str.replaceAll(' ', '').toLowerCase();
613
- }
614
- else {
615
- return null;
616
- }
617
- }
618
-
619
- export function twiddleThumbs(mSec = 2000) {
620
- return new Promise<void>((resolve) => {
621
- setTimeout(() => resolve(), mSec);
622
- })
623
- }
624
-
625
- export function nestedValue(obj: any, path?: string) {
626
- if (obj == null || obj == undefined || !path) {
627
- return null;
628
- }
629
-
630
- var props = path.split('.');
631
- let propCnt = props.length;
632
- var r = obj;
633
-
634
- for (var i = 0; i < propCnt; i++) {
635
- r = r[props[i]]
636
- if (r == null) {
637
- return null;
638
- }
639
- }
640
-
641
- return r;
642
- }
643
-
644
- export function validEmail(email?: string) {
645
- if (!email) return false
646
- return /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(email);
647
- }
@@ -1,20 +0,0 @@
1
- // Returns a random Universally Unique Identifier (UUID)
2
- export function useId(pattern?: string) {
3
- // Accept any desired pattern. If no pattern is provided
4
- // default to a RFC4122 UUID pattern.
5
- const _pattern = pattern ? pattern : 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
6
-
7
- // Replace each character in the pattern
8
- // leaving any non x|y character alone.
9
- return _pattern.replace(/[xy]/g, replacePattern);
10
- }
11
-
12
- function replacePattern(c: string) {
13
- // Random hexadecimal number
14
- const r = (Math.random() * 16) | 0;
15
-
16
- // If 'x' return hexadecimal number,
17
- // if 'y' return [8-11] randomly
18
- const v = c == 'x' ? r : (r & 0x3) | 0x8;
19
- return v.toString(16);
20
- }