@bbn/bbn 1.0.313 → 1.0.314
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.
- package/dist/bbn.js +1 -1
- package/dist/bbn.js.map +1 -1
- package/dist/fn/phone/fphone.d.ts +1 -0
- package/dist/fn/phone/fphone.js +51 -0
- package/dist/fn.d.ts +2 -0
- package/dist/fn.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function fphone(st: any): any;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import isNumber from '../type/isNumber.js';
|
|
2
|
+
import isString from '../type/isString.js';
|
|
3
|
+
import each from '../loop/each.js';
|
|
4
|
+
export default function fphone(st) {
|
|
5
|
+
var _a;
|
|
6
|
+
if (isNumber(st)) {
|
|
7
|
+
st = st.toString();
|
|
8
|
+
}
|
|
9
|
+
if (isString(st)) {
|
|
10
|
+
var phoneCodes = ((_a = bbn.var) === null || _a === void 0 ? void 0 : _a.phoneCodes) || [];
|
|
11
|
+
var res = '';
|
|
12
|
+
var prefix_1 = '';
|
|
13
|
+
var mask_1 = '';
|
|
14
|
+
if (phoneCodes.length) {
|
|
15
|
+
// Get phone prefix and mask
|
|
16
|
+
each(phoneCodes, function (c) {
|
|
17
|
+
if (st.startsWith(c.prefix) && (c.prefix.length > prefix_1.length)) {
|
|
18
|
+
prefix_1 = c.prefix;
|
|
19
|
+
mask_1 = c.mask || '';
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
if (!mask_1.length) {
|
|
24
|
+
if (st.startsWith('+')) {
|
|
25
|
+
if (!prefix_1.length) {
|
|
26
|
+
prefix_1 = st.substr(0, 3);
|
|
27
|
+
}
|
|
28
|
+
var tmpSt = st.slice(prefix_1.length);
|
|
29
|
+
for (var i = 0; i < tmpSt.length; i++) {
|
|
30
|
+
if (((i + 1) <= tmpSt.length) && ((i % 2) === 0)) {
|
|
31
|
+
mask_1 += '0' + (tmpSt[i + 1] ? '0' : '') + ' ';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
mask_1 = mask_1.trim();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (mask_1.length) {
|
|
38
|
+
if (prefix_1.length) {
|
|
39
|
+
res = prefix_1 + ' ';
|
|
40
|
+
st = st.slice(prefix_1.length);
|
|
41
|
+
}
|
|
42
|
+
var i_1 = 0;
|
|
43
|
+
res += mask_1.replace(/[0-9]/g, function () {
|
|
44
|
+
return st[i_1++] || '';
|
|
45
|
+
});
|
|
46
|
+
return res;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return st;
|
|
50
|
+
}
|
|
51
|
+
;
|
package/dist/fn.d.ts
CHANGED
|
@@ -85,6 +85,7 @@ import formatBytes from './fn/string/formatBytes.js';
|
|
|
85
85
|
import formatDate from './fn/datetime/formatDate.js';
|
|
86
86
|
import formatSize from './fn/string/formatSize.js';
|
|
87
87
|
import formdata from './fn/form/formdata.js';
|
|
88
|
+
import fphone from './fn/phone/fphone.js';
|
|
88
89
|
import fromXml from './fn/convert/fromXml.js';
|
|
89
90
|
import ftime from './fn/datetime/ftime.js';
|
|
90
91
|
import getAllTags from './fn/html/getAllTags.js';
|
|
@@ -324,6 +325,7 @@ declare const _default: {
|
|
|
324
325
|
formatDate: typeof formatDate;
|
|
325
326
|
formatSize: typeof formatSize;
|
|
326
327
|
formdata: typeof formdata;
|
|
328
|
+
fphone: typeof fphone;
|
|
327
329
|
fromXml: typeof fromXml;
|
|
328
330
|
ftime: typeof ftime;
|
|
329
331
|
getAllTags: typeof getAllTags;
|
package/dist/fn.js
CHANGED
|
@@ -85,6 +85,7 @@ import formatBytes from './fn/string/formatBytes.js';
|
|
|
85
85
|
import formatDate from './fn/datetime/formatDate.js';
|
|
86
86
|
import formatSize from './fn/string/formatSize.js';
|
|
87
87
|
import formdata from './fn/form/formdata.js';
|
|
88
|
+
import fphone from './fn/phone/fphone.js';
|
|
88
89
|
import fromXml from './fn/convert/fromXml.js';
|
|
89
90
|
import ftime from './fn/datetime/ftime.js';
|
|
90
91
|
import getAllTags from './fn/html/getAllTags.js';
|
|
@@ -324,6 +325,7 @@ export default {
|
|
|
324
325
|
formatDate: formatDate,
|
|
325
326
|
formatSize: formatSize,
|
|
326
327
|
formdata: formdata,
|
|
328
|
+
fphone: fphone,
|
|
327
329
|
fromXml: fromXml,
|
|
328
330
|
ftime: ftime,
|
|
329
331
|
getAllTags: getAllTags,
|