1 | "use strict";
|
2 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4 | };
|
5 | Object.defineProperty(exports, "__esModule", { value: true });
|
6 | const lib_1 = require("./lib");
|
7 | const NativeString_1 = __importDefault(require("./NativeString"));
|
8 |
|
9 | function starkString(value) {
|
10 | if (typeof value === "number" || typeof value === "string")
|
11 | value = String(value);
|
12 | else if (Array.isArray(value))
|
13 | value = value.join("");
|
14 | else if (value === undefined || value === null)
|
15 | value = "";
|
16 | else
|
17 | throw new Error(`StarkString value must be type of string, number or Array<string|number> instead of ${typeof value}`);
|
18 | return new StarkString(value);
|
19 | }
|
20 | class StarkString extends NativeString_1.default {
|
21 | constructor(value) {
|
22 | super(value);
|
23 | }
|
24 |
|
25 | clone() {
|
26 | return starkString(this._value);
|
27 | }
|
28 |
|
29 | set(value) {
|
30 | this._value = String(value);
|
31 | return this;
|
32 | }
|
33 |
|
34 | persianChar() {
|
35 | this._value = lib_1.persianChar(this.toString());
|
36 | return this;
|
37 | }
|
38 |
|
39 | englishNumber() {
|
40 | this._value = lib_1.englishNumber(this._value);
|
41 | return this;
|
42 | }
|
43 |
|
44 | persianNumber() {
|
45 | this._value = lib_1.persianNumber(this._value);
|
46 | return this;
|
47 | }
|
48 |
|
49 | arabicNumber() {
|
50 | this._value = lib_1.arabicNumber(this._value);
|
51 | return this;
|
52 | }
|
53 | |
54 |
|
55 |
|
56 |
|
57 |
|
58 | fixURL() {
|
59 | this._value = lib_1.decodeURL(this._value);
|
60 | return this;
|
61 | }
|
62 | |
63 |
|
64 |
|
65 |
|
66 |
|
67 | decodeURL() {
|
68 | this._value = lib_1.decodeURL(this._value);
|
69 | return this;
|
70 | }
|
71 |
|
72 | switchKey() {
|
73 | this._value = lib_1.switchKey(this._value);
|
74 | return this;
|
75 | }
|
76 |
|
77 | digitsToWords() {
|
78 | this._value = lib_1.digitsToWords(this._value);
|
79 | return this;
|
80 | }
|
81 |
|
82 | halfSpace() {
|
83 | this._value = lib_1.halfSpace(this._value);
|
84 | return this;
|
85 | }
|
86 |
|
87 | isInteger() {
|
88 | return lib_1.isInteger(this._value);
|
89 | }
|
90 |
|
91 | isValidBankCard() {
|
92 | return lib_1.isValidBankCard(this._value);
|
93 | }
|
94 |
|
95 | currency() {
|
96 | this._value = lib_1.currency(this._value);
|
97 | return this;
|
98 | }
|
99 |
|
100 | parseNumber({ max } = {}) {
|
101 | this._value = lib_1.parseNumber(this._value);
|
102 | if (typeof max === "number") {
|
103 | if (Number(this._value) > max) {
|
104 | this._value = String(max);
|
105 | }
|
106 | }
|
107 | return this;
|
108 | }
|
109 |
|
110 | security() {
|
111 | this._value = lib_1.security(this._value);
|
112 | return this;
|
113 | }
|
114 |
|
115 | toNumber() {
|
116 | return Number(this._value);
|
117 | }
|
118 | }
|
119 |
|
120 |
|
121 | exports.default = starkString;
|
122 |
|
\ | No newline at end of file |