oakscriptjs 0.9.4 → 0.9.6
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/cjs/array/index.d.ts +88 -27
- package/dist/cjs/array/index.d.ts.map +1 -1
- package/dist/cjs/array/index.js +257 -117
- package/dist/cjs/array/index.js.map +3 -3
- package/dist/cjs/callsite/index.d.ts +122 -4
- package/dist/cjs/callsite/index.d.ts.map +1 -1
- package/dist/cjs/callsite/index.js +102 -3
- package/dist/cjs/callsite/index.js.map +2 -2
- package/dist/cjs/color/index.d.ts +7 -3
- package/dist/cjs/color/index.d.ts.map +1 -1
- package/dist/cjs/color/index.js +6 -1
- package/dist/cjs/color/index.js.map +2 -2
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/label/index.d.ts.map +1 -1
- package/dist/cjs/label/index.js +2 -1
- package/dist/cjs/label/index.js.map +2 -2
- package/dist/cjs/linefill/index.d.ts.map +1 -1
- package/dist/cjs/linefill/index.js +1 -0
- package/dist/cjs/linefill/index.js.map +2 -2
- package/dist/cjs/math/index.d.ts +79 -22
- package/dist/cjs/math/index.d.ts.map +1 -1
- package/dist/cjs/math/index.js +157 -43
- package/dist/cjs/math/index.js.map +3 -3
- package/dist/cjs/matrix/index.d.ts.map +1 -1
- package/dist/cjs/matrix/index.js +42 -36
- package/dist/cjs/matrix/index.js.map +2 -2
- package/dist/cjs/runtime/series.d.ts +9 -0
- package/dist/cjs/runtime/series.d.ts.map +1 -1
- package/dist/cjs/runtime/series.js +16 -2
- package/dist/cjs/runtime/series.js.map +2 -2
- package/dist/cjs/script/index.d.ts +15 -31
- package/dist/cjs/script/index.d.ts.map +1 -1
- package/dist/cjs/script/index.js +32 -0
- package/dist/cjs/script/index.js.map +2 -2
- package/dist/cjs/session/calendar.d.ts.map +1 -1
- package/dist/cjs/session/calendar.js +15 -2
- package/dist/cjs/session/calendar.js.map +2 -2
- package/dist/cjs/str/index.d.ts +50 -38
- package/dist/cjs/str/index.d.ts.map +1 -1
- package/dist/cjs/str/index.js +43 -15
- package/dist/cjs/str/index.js.map +2 -2
- package/dist/cjs/str/messageformat.d.ts +2 -1
- package/dist/cjs/str/messageformat.d.ts.map +1 -1
- package/dist/cjs/str/messageformat.js +4 -1
- package/dist/cjs/str/messageformat.js.map +2 -2
- package/dist/cjs/str/numberformat.d.ts +4 -0
- package/dist/cjs/str/numberformat.d.ts.map +1 -1
- package/dist/cjs/str/numberformat.js +26 -4
- package/dist/cjs/str/numberformat.js.map +3 -3
- package/dist/cjs/ta/index.d.ts +95 -46
- package/dist/cjs/ta/index.d.ts.map +1 -1
- package/dist/cjs/ta/index.js +193 -318
- package/dist/cjs/ta/index.js.map +3 -3
- package/dist/cjs/ta/running-sum.d.ts +54 -1
- package/dist/cjs/ta/running-sum.d.ts.map +1 -1
- package/dist/cjs/ta/running-sum.js +132 -47
- package/dist/cjs/ta/running-sum.js.map +2 -2
- package/dist/cjs/ta-series.d.ts +4 -4
- package/dist/cjs/ta-series.d.ts.map +1 -1
- package/dist/cjs/ta-series.js +4 -3
- package/dist/cjs/ta-series.js.map +2 -2
- package/dist/cjs/time/datestring.d.ts +1 -0
- package/dist/cjs/time/datestring.d.ts.map +1 -1
- package/dist/cjs/time/datestring.js +7 -0
- package/dist/cjs/time/datestring.js.map +2 -2
- package/dist/cjs/time/index.d.ts.map +1 -1
- package/dist/cjs/time/index.js +2 -1
- package/dist/cjs/time/index.js.map +2 -2
- package/dist/cjs/time/session.d.ts +28 -9
- package/dist/cjs/time/session.d.ts.map +1 -1
- package/dist/cjs/time/session.js +74 -28
- package/dist/cjs/time/session.js.map +2 -2
- package/dist/cjs/time/timezone.d.ts +5 -0
- package/dist/cjs/time/timezone.d.ts.map +1 -1
- package/dist/cjs/time/timezone.js +15 -1
- package/dist/cjs/time/timezone.js.map +2 -2
- package/dist/esm/array/index.d.ts +88 -27
- package/dist/esm/array/index.d.ts.map +1 -1
- package/dist/esm/array/index.js +408 -157
- package/dist/esm/array/index.js.map +1 -1
- package/dist/esm/callsite/index.d.ts +122 -4
- package/dist/esm/callsite/index.d.ts.map +1 -1
- package/dist/esm/callsite/index.js +228 -8
- package/dist/esm/callsite/index.js.map +1 -1
- package/dist/esm/color/index.d.ts +7 -3
- package/dist/esm/color/index.d.ts.map +1 -1
- package/dist/esm/color/index.js +15 -3
- package/dist/esm/color/index.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/label/index.d.ts.map +1 -1
- package/dist/esm/label/index.js +2 -1
- package/dist/esm/label/index.js.map +1 -1
- package/dist/esm/linefill/index.d.ts.map +1 -1
- package/dist/esm/linefill/index.js +3 -0
- package/dist/esm/linefill/index.js.map +1 -1
- package/dist/esm/math/index.d.ts +79 -22
- package/dist/esm/math/index.d.ts.map +1 -1
- package/dist/esm/math/index.js +229 -63
- package/dist/esm/math/index.js.map +1 -1
- package/dist/esm/matrix/index.d.ts.map +1 -1
- package/dist/esm/matrix/index.js +57 -43
- package/dist/esm/matrix/index.js.map +1 -1
- package/dist/esm/runtime/series.d.ts +9 -0
- package/dist/esm/runtime/series.d.ts.map +1 -1
- package/dist/esm/runtime/series.js +18 -1
- package/dist/esm/runtime/series.js.map +1 -1
- package/dist/esm/script/index.d.ts +15 -31
- package/dist/esm/script/index.d.ts.map +1 -1
- package/dist/esm/script/index.js +44 -1
- package/dist/esm/script/index.js.map +1 -1
- package/dist/esm/session/calendar.d.ts.map +1 -1
- package/dist/esm/session/calendar.js +22 -2
- package/dist/esm/session/calendar.js.map +1 -1
- package/dist/esm/str/index.d.ts +50 -38
- package/dist/esm/str/index.d.ts.map +1 -1
- package/dist/esm/str/index.js +103 -52
- package/dist/esm/str/index.js.map +1 -1
- package/dist/esm/str/messageformat.d.ts +2 -1
- package/dist/esm/str/messageformat.d.ts.map +1 -1
- package/dist/esm/str/messageformat.js +7 -2
- package/dist/esm/str/messageformat.js.map +1 -1
- package/dist/esm/str/numberformat.d.ts +4 -0
- package/dist/esm/str/numberformat.d.ts.map +1 -1
- package/dist/esm/str/numberformat.js +38 -4
- package/dist/esm/str/numberformat.js.map +1 -1
- package/dist/esm/ta/index.d.ts +95 -46
- package/dist/esm/ta/index.d.ts.map +1 -1
- package/dist/esm/ta/index.js +341 -414
- package/dist/esm/ta/index.js.map +1 -1
- package/dist/esm/ta/running-sum.d.ts +54 -1
- package/dist/esm/ta/running-sum.d.ts.map +1 -1
- package/dist/esm/ta/running-sum.js +166 -60
- package/dist/esm/ta/running-sum.js.map +1 -1
- package/dist/esm/ta-series.d.ts +4 -4
- package/dist/esm/ta-series.d.ts.map +1 -1
- package/dist/esm/ta-series.js +5 -4
- package/dist/esm/ta-series.js.map +1 -1
- package/dist/esm/time/datestring.d.ts +1 -0
- package/dist/esm/time/datestring.d.ts.map +1 -1
- package/dist/esm/time/datestring.js +12 -0
- package/dist/esm/time/datestring.js.map +1 -1
- package/dist/esm/time/index.d.ts.map +1 -1
- package/dist/esm/time/index.js +3 -1
- package/dist/esm/time/index.js.map +1 -1
- package/dist/esm/time/session.d.ts +28 -9
- package/dist/esm/time/session.d.ts.map +1 -1
- package/dist/esm/time/session.js +113 -42
- package/dist/esm/time/session.js.map +1 -1
- package/dist/esm/time/timezone.d.ts +5 -0
- package/dist/esm/time/timezone.d.ts.map +1 -1
- package/dist/esm/time/timezone.js +21 -1
- package/dist/esm/time/timezone.js.map +1 -1
- package/package.json +2 -2
- package/src/array/index.ts +382 -174
- package/src/callsite/index.ts +232 -8
- package/src/color/index.ts +15 -5
- package/src/index.ts +1 -1
- package/src/label/index.ts +2 -1
- package/src/linefill/index.ts +2 -0
- package/src/math/index.ts +261 -77
- package/src/matrix/index.ts +52 -52
- package/src/runtime/series.ts +22 -1
- package/src/script/index.ts +53 -1
- package/src/session/calendar.ts +22 -2
- package/src/str/index.ts +95 -51
- package/src/str/messageformat.ts +7 -2
- package/src/str/numberformat.ts +39 -4
- package/src/ta/index.ts +356 -458
- package/src/ta/running-sum.ts +187 -62
- package/src/ta-series.ts +8 -7
- package/src/time/datestring.ts +10 -0
- package/src/time/index.ts +3 -1
- package/src/time/session.ts +97 -47
- package/src/time/timezone.ts +21 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.js","sourceRoot":"","sources":["../../../src/session/calendar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"calendar.js","sourceRoot":"","sources":["../../../src/session/calendar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAiCtD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAW,EAAE,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;AAC/F,MAAM,KAAK,GAAG,CAAC,IAAa,EAAU,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,EAAE,IAAI,GAAG,GAAG,CAAC,CAAC;AAC1H,MAAM,OAAO,GAAG,CAAC,EAAU,EAAW,EAAE;IACtC,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,EAAE,CAAC,CAAC;IACvB,OAAO,SAAS,CAAC,CAAC,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC;AAC5E,CAAC,CAAC;AACF,M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,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACjG,wCAAwC;AACxC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAa,EAAW,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;AACvF,uCAAuC;AACvC,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAa,EAAW,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/esm/str/index.d.ts
CHANGED
|
@@ -26,20 +26,28 @@ export declare function length(str: simple_string): int;
|
|
|
26
26
|
* Converts a value to its string representation (PineScript `str.tostring`).
|
|
27
27
|
*
|
|
28
28
|
* @param value - The value to convert (number, boolean, string, etc.)
|
|
29
|
-
* @param format - Optional number format: a pattern ("#.##", "#,###.00", "0.00%", "0.00E0") or
|
|
30
|
-
* `format.percent` ("percent"), `format.volume` ("volume"), `format.
|
|
29
|
+
* @param format - Optional number format: a pattern ("#.##", "#,###.00", "0.00%", "0.00E0", "#.##;(#.##)") or
|
|
30
|
+
* `format.percent` ("percent"), `format.volume` ("volume"), `format.mintick` ("mintick"),
|
|
31
|
+
* `format.price` / `format.inherit`
|
|
32
|
+
* @param mintick - Tick size for `format.mintick` (PineScript `syminfo.mintick`, implicit there). Not part of the
|
|
33
|
+
* PineScript signature: the core function cannot see the chart, so pass it, as for `math.round_to_mintick`
|
|
31
34
|
* @returns String representation of the value
|
|
32
35
|
*
|
|
33
36
|
* @remarks
|
|
34
37
|
* As in PineScript:
|
|
35
38
|
* - without format, numbers show up to 10 decimals ("0.3333333333"); 1e21 and more use "1E21"
|
|
36
|
-
* - patterns round half away from zero on the shortest decimal form: 1.005 with "#.##" gives "1.01"
|
|
39
|
+
* - patterns round half away from zero on the shortest decimal form: 1.005 with "#.##" gives "1.01";
|
|
40
|
+
* at most 16 decimals from 1e-3 up (0.0012345678901234567 with 20 '#' decimals gives "0.0012345678901235")
|
|
41
|
+
* - "pos;neg" patterns: a negative number takes the text of the negative subpattern ("#.##;(#.##)": "(3.5)")
|
|
37
42
|
* - "#" is an optional digit ("1.5" with "#.##"), "0" a required digit ("1.50" with "0.00"),
|
|
38
43
|
* "," groups thousands, "%" multiplies by 100, 'text' is literal text
|
|
39
44
|
* - `format.percent` shows 2 decimals and "%" without multiplying; `format.volume` uses K, M, B, T
|
|
40
45
|
* - `format.price` and `format.inherit` give "price1" / "inherit1" in PineScript: they are patterns
|
|
41
46
|
* without digit characters, and oakscriptjs does the same
|
|
42
|
-
* - `format.mintick`
|
|
47
|
+
* - `format.mintick` rounds to the tick (`math.round_to_mintick`) and shows the tick's decimals ("#.##" for 0.01);
|
|
48
|
+
* it throws without `mintick`
|
|
49
|
+
* - na gives "NaN" ("NaN%" with `format.percent`); an infinity gives "NaN" too ("NaN%" for `format.percent`,
|
|
50
|
+
* "NaNT" for `format.volume`), except `format.mintick`, which gives "Infinity" / "-Infinity"
|
|
43
51
|
*
|
|
44
52
|
* @example
|
|
45
53
|
* ```typescript
|
|
@@ -49,26 +57,27 @@ export declare function length(str: simple_string): int;
|
|
|
49
57
|
* str.tostring(12345.678, format.volume) // "12.346K"
|
|
50
58
|
* ```
|
|
51
59
|
*/
|
|
52
|
-
export declare function tostring(value: any, format?: simple_string): string;
|
|
60
|
+
export declare function tostring(value: any, format?: simple_string, mintick?: float): string;
|
|
53
61
|
/**
|
|
54
62
|
* Converts a string to a number (float).
|
|
55
63
|
*
|
|
56
64
|
* @param str - The string to convert
|
|
57
|
-
* @returns The numeric value, or null if conversion fails
|
|
65
|
+
* @returns The numeric value, or null (na) if conversion fails
|
|
58
66
|
*
|
|
59
67
|
* @remarks
|
|
60
|
-
*
|
|
61
|
-
* -
|
|
62
|
-
* -
|
|
63
|
-
* -
|
|
64
|
-
*
|
|
68
|
+
* As in PineScript:
|
|
69
|
+
* - The whole text must be a number: a sign, digits and one optional "." ("0.5", ".5", "5.", "-12"); "12abc" is na
|
|
70
|
+
* - Scientific notation ("1e3"), "Infinity", "NaN", hexadecimal, "1,000" give na
|
|
71
|
+
* - The characters U+0000 to U+0020 (space, tab, line feed...) around the number are ignored; other spaces
|
|
72
|
+
* (no-break space U+00A0, U+3000) give na
|
|
65
73
|
*
|
|
66
74
|
* @example
|
|
67
75
|
* ```typescript
|
|
68
76
|
* str.tonumber("123") // Returns: 123
|
|
69
77
|
* str.tonumber("45.67") // Returns: 45.67
|
|
70
78
|
* str.tonumber("abc") // Returns: null
|
|
71
|
-
* str.tonumber("
|
|
79
|
+
* str.tonumber("12abc") // Returns: null
|
|
80
|
+
* str.tonumber("1e3") // Returns: null
|
|
72
81
|
* ```
|
|
73
82
|
*/
|
|
74
83
|
export declare function tonumber(str: simple_string): float | null;
|
|
@@ -81,6 +90,7 @@ export declare function tonumber(str: simple_string): float | null;
|
|
|
81
90
|
* @returns The extracted substring
|
|
82
91
|
*
|
|
83
92
|
* @remarks
|
|
93
|
+
* - An na `end` (NaN / null) is a runtime error in PineScript: it throws
|
|
84
94
|
* - If begin > end, indices are swapped (JavaScript behavior)
|
|
85
95
|
* - Negative indices are treated as 0
|
|
86
96
|
* - Indices beyond string length return empty string
|
|
@@ -145,39 +155,42 @@ export declare function contains(source: simple_string, str: simple_string): boo
|
|
|
145
155
|
*
|
|
146
156
|
* @param source - The string to search in
|
|
147
157
|
* @param str - The substring to search for
|
|
148
|
-
* @returns The 0-based index of the first occurrence, or
|
|
158
|
+
* @returns The 0-based index of the first occurrence, or na (NaN) if not found
|
|
149
159
|
*
|
|
150
160
|
* @remarks
|
|
151
161
|
* - Search is case-sensitive
|
|
152
162
|
* - Returns 0 for empty search string
|
|
153
|
-
* - Returns
|
|
163
|
+
* - Returns na (NaN) if substring is not found, as in PineScript
|
|
154
164
|
*
|
|
155
165
|
* @example
|
|
156
166
|
* ```typescript
|
|
157
167
|
* str.pos("hello world", "world") // Returns: 6
|
|
158
168
|
* str.pos("hello world", "o") // Returns: 4 (first occurrence)
|
|
159
|
-
* str.pos("hello", "xyz") // Returns:
|
|
169
|
+
* str.pos("hello", "xyz") // Returns: NaN (na)
|
|
160
170
|
* ```
|
|
161
171
|
*/
|
|
162
172
|
export declare function pos(source: simple_string, str: simple_string): int;
|
|
163
173
|
/**
|
|
164
|
-
* Replaces
|
|
174
|
+
* Replaces the Nth occurrence of a substring (PineScript `str.replace`).
|
|
165
175
|
*
|
|
166
176
|
* @param source - The source string
|
|
167
177
|
* @param target - The substring to replace
|
|
168
178
|
* @param replacement - The string to replace with
|
|
169
|
-
* @param occurrence -
|
|
170
|
-
* @returns The string with
|
|
179
|
+
* @param occurrence - 0-based occurrence to replace (default 0, the first one)
|
|
180
|
+
* @returns The string with one occurrence replaced
|
|
171
181
|
*
|
|
172
182
|
* @remarks
|
|
173
|
-
*
|
|
174
|
-
* -
|
|
175
|
-
* -
|
|
183
|
+
* PineScript rules:
|
|
184
|
+
* - only the Nth occurrence is replaced; an na occurrence is 0 (`str.replace("aaa", "a", "-", na)` is "-aa")
|
|
185
|
+
* - occurrences overlap: "aa" occurs at 0 and 1 in "aaa" (`str.replace("aaa", "aa", "-", 1)` is "a-")
|
|
186
|
+
* - an empty target inserts the replacement at character N, at most at the end
|
|
187
|
+
* (`str.replace("abc", "", "-", 2)` is "ab-c")
|
|
188
|
+
* - fewer than N + 1 occurrences (or a negative N) leave the source unchanged
|
|
176
189
|
*
|
|
177
190
|
* @example
|
|
178
191
|
* ```typescript
|
|
179
|
-
* str.replace("hello world hello", "hello", "hi"
|
|
180
|
-
* str.replace("hello world hello", "hello", "hi") // Returns: "
|
|
192
|
+
* str.replace("hello world hello", "hello", "hi") // Returns: "hi world hello"
|
|
193
|
+
* str.replace("hello world hello", "hello", "hi", 1) // Returns: "hello world hi"
|
|
181
194
|
* str.replace("test", "xyz", "abc") // Returns: "test"
|
|
182
195
|
* ```
|
|
183
196
|
*/
|
|
@@ -212,7 +225,7 @@ export declare function replace_all(source: simple_string, target: simple_string
|
|
|
212
225
|
* @returns Array of substrings
|
|
213
226
|
*
|
|
214
227
|
* @remarks
|
|
215
|
-
* - Empty separator splits into individual characters
|
|
228
|
+
* - Empty separator splits into individual characters; an empty string gives [""] (also with "")
|
|
216
229
|
* - If separator is not found, returns array with original string
|
|
217
230
|
* - Consecutive separators create empty strings in result
|
|
218
231
|
*
|
|
@@ -248,7 +261,8 @@ export declare function concat(...strings: simple_string[]): string;
|
|
|
248
261
|
* @remarks
|
|
249
262
|
* As in PineScript: numbers in `{n}` use
|
|
250
263
|
* "#,##0.###" (1234.5678 gives "1,234.568"); number patterns round half to even on the exact
|
|
251
|
-
* value; `'...'` is literal text and `''` a quote;
|
|
264
|
+
* value (16 decimals at most from 1e-3 up); an array gives "[a, b]"; `'...'` is literal text and `''` a quote;
|
|
265
|
+
* a missing argument leaves `{n}` in the text.
|
|
252
266
|
* Dates are formatted in UTC here; PineScript uses the exchange time zone.
|
|
253
267
|
*
|
|
254
268
|
* @example
|
|
@@ -370,25 +384,23 @@ export declare function trimLeft(str: simple_string): string;
|
|
|
370
384
|
*/
|
|
371
385
|
export declare function trimRight(str: simple_string): string;
|
|
372
386
|
/**
|
|
373
|
-
*
|
|
387
|
+
* Returns the first substring of `source` that matches the `regex` (PineScript `str.match`).
|
|
374
388
|
*
|
|
375
|
-
* @param source -
|
|
376
|
-
* @param regex -
|
|
377
|
-
* @returns
|
|
389
|
+
* @param source - Source string
|
|
390
|
+
* @param regex - Regular expression
|
|
391
|
+
* @returns The first match (searched anywhere in the string), or na (null) when nothing matches or the match is empty
|
|
378
392
|
*
|
|
379
393
|
* @remarks
|
|
394
|
+
* - As PineScript: "Hello World!" with "o" gives "o", with "[a-z]+" gives "ello"; no match gives na
|
|
380
395
|
* - Uses JavaScript regex syntax
|
|
381
|
-
* - Match is case-sensitive by default
|
|
382
|
-
* - Pattern is tested against entire string
|
|
383
396
|
*
|
|
384
397
|
* @example
|
|
385
398
|
* ```typescript
|
|
386
|
-
* str.match("
|
|
387
|
-
* str.match("
|
|
388
|
-
* str.match("abc", "[A-Z]+") // Returns: false
|
|
399
|
+
* str.match("abc123def", "[0-9]+") // Returns: "123"
|
|
400
|
+
* str.match("abc", "[0-9]+") // Returns: null (na)
|
|
389
401
|
* ```
|
|
390
402
|
*/
|
|
391
|
-
export declare function match(source: simple_string, regex: simple_string):
|
|
403
|
+
export declare function match(source: simple_string, regex: simple_string): simple_string | null;
|
|
392
404
|
/**
|
|
393
405
|
* Formats a timestamp as a string according to the specified format.
|
|
394
406
|
*
|
|
@@ -429,15 +441,15 @@ export declare function match(source: simple_string, regex: simple_string): bool
|
|
|
429
441
|
* Constructs a new string containing the source string repeated N times with an optional separator.
|
|
430
442
|
*
|
|
431
443
|
* @param source - The string to repeat
|
|
432
|
-
* @param count - Number of times to repeat
|
|
444
|
+
* @param count - Number of times to repeat
|
|
433
445
|
* @param separator - String to inject between repeated instances. Optional, defaults to empty string.
|
|
434
|
-
* @returns The repeated string, or null if source is
|
|
446
|
+
* @returns The repeated string, or null (na) if source is na or count is 0 / negative / na, as in PineScript
|
|
435
447
|
*
|
|
436
448
|
* @example
|
|
437
449
|
* ```typescript
|
|
438
450
|
* str.repeat("ab", 3) // Returns: "ababab"
|
|
439
451
|
* str.repeat("?", 3, ",") // Returns: "?,?,?"
|
|
440
|
-
* str.repeat("hello", 0) // Returns:
|
|
452
|
+
* str.repeat("hello", 0) // Returns: null (na)
|
|
441
453
|
* str.repeat("x", 1) // Returns: "x"
|
|
442
454
|
* ```
|
|
443
455
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/str/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/str/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,OAAO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;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,GAAE,aAAkB,GAAG,MAAM,GAAG,IAAI,CAI7G;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,GAAE,aAAwC,EAAE,QAAQ,GAAE,aAAyB,GAAG,MAAM,CAE3I"}
|
package/dist/esm/str/index.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import { formatNumber } from './numberformat.js';
|
|
12
12
|
import { formatMessage } from './messageformat.js';
|
|
13
13
|
import { formatDate } from './dateformat.js';
|
|
14
|
+
import { round_to_mintick } from '../math/index.js';
|
|
14
15
|
/**
|
|
15
16
|
* Returns the length of a string.
|
|
16
17
|
*
|
|
@@ -30,20 +31,28 @@ export function length(str) {
|
|
|
30
31
|
* Converts a value to its string representation (PineScript `str.tostring`).
|
|
31
32
|
*
|
|
32
33
|
* @param value - The value to convert (number, boolean, string, etc.)
|
|
33
|
-
* @param format - Optional number format: a pattern ("#.##", "#,###.00", "0.00%", "0.00E0") or
|
|
34
|
-
* `format.percent` ("percent"), `format.volume` ("volume"), `format.
|
|
34
|
+
* @param format - Optional number format: a pattern ("#.##", "#,###.00", "0.00%", "0.00E0", "#.##;(#.##)") or
|
|
35
|
+
* `format.percent` ("percent"), `format.volume` ("volume"), `format.mintick` ("mintick"),
|
|
36
|
+
* `format.price` / `format.inherit`
|
|
37
|
+
* @param mintick - Tick size for `format.mintick` (PineScript `syminfo.mintick`, implicit there). Not part of the
|
|
38
|
+
* PineScript signature: the core function cannot see the chart, so pass it, as for `math.round_to_mintick`
|
|
35
39
|
* @returns String representation of the value
|
|
36
40
|
*
|
|
37
41
|
* @remarks
|
|
38
42
|
* As in PineScript:
|
|
39
43
|
* - without format, numbers show up to 10 decimals ("0.3333333333"); 1e21 and more use "1E21"
|
|
40
|
-
* - patterns round half away from zero on the shortest decimal form: 1.005 with "#.##" gives "1.01"
|
|
44
|
+
* - patterns round half away from zero on the shortest decimal form: 1.005 with "#.##" gives "1.01";
|
|
45
|
+
* at most 16 decimals from 1e-3 up (0.0012345678901234567 with 20 '#' decimals gives "0.0012345678901235")
|
|
46
|
+
* - "pos;neg" patterns: a negative number takes the text of the negative subpattern ("#.##;(#.##)": "(3.5)")
|
|
41
47
|
* - "#" is an optional digit ("1.5" with "#.##"), "0" a required digit ("1.50" with "0.00"),
|
|
42
48
|
* "," groups thousands, "%" multiplies by 100, 'text' is literal text
|
|
43
49
|
* - `format.percent` shows 2 decimals and "%" without multiplying; `format.volume` uses K, M, B, T
|
|
44
50
|
* - `format.price` and `format.inherit` give "price1" / "inherit1" in PineScript: they are patterns
|
|
45
51
|
* without digit characters, and oakscriptjs does the same
|
|
46
|
-
* - `format.mintick`
|
|
52
|
+
* - `format.mintick` rounds to the tick (`math.round_to_mintick`) and shows the tick's decimals ("#.##" for 0.01);
|
|
53
|
+
* it throws without `mintick`
|
|
54
|
+
* - na gives "NaN" ("NaN%" with `format.percent`); an infinity gives "NaN" too ("NaN%" for `format.percent`,
|
|
55
|
+
* "NaNT" for `format.volume`), except `format.mintick`, which gives "Infinity" / "-Infinity"
|
|
47
56
|
*
|
|
48
57
|
* @example
|
|
49
58
|
* ```typescript
|
|
@@ -53,11 +62,17 @@ export function length(str) {
|
|
|
53
62
|
* str.tostring(12345.678, format.volume) // "12.346K"
|
|
54
63
|
* ```
|
|
55
64
|
*/
|
|
56
|
-
export function tostring(value, format) {
|
|
65
|
+
export function tostring(value, format, mintick) {
|
|
57
66
|
if (typeof value !== 'number')
|
|
58
67
|
return String(value);
|
|
59
|
-
if (
|
|
60
|
-
return
|
|
68
|
+
if (Number.isNaN(value))
|
|
69
|
+
return format === 'percent' ? 'NaN%' : 'NaN';
|
|
70
|
+
if (!Number.isFinite(value)) {
|
|
71
|
+
// the chart formatter has no infinity: NaN with the format's suffix
|
|
72
|
+
if (format === 'mintick')
|
|
73
|
+
return String(value);
|
|
74
|
+
return format === 'percent' ? 'NaN%' : format === 'volume' ? 'NaNT' : 'NaN';
|
|
75
|
+
}
|
|
61
76
|
if (format === undefined || format === '') {
|
|
62
77
|
if (Math.abs(value) >= 1e21 && Number.isFinite(value)) {
|
|
63
78
|
return String(value).replace('e+', 'E').replace(/\.0+E/, 'E');
|
|
@@ -75,8 +90,16 @@ export function tostring(value, format) {
|
|
|
75
90
|
}
|
|
76
91
|
return formatNumber(value, '#', 'halfUpShortest');
|
|
77
92
|
}
|
|
78
|
-
case 'mintick':
|
|
79
|
-
|
|
93
|
+
case 'mintick': {
|
|
94
|
+
if (mintick === undefined) {
|
|
95
|
+
throw new Error('str.tostring(x, format.mintick) needs the tick size: pass it as str.tostring(x, format.mintick, syminfo.mintick)');
|
|
96
|
+
}
|
|
97
|
+
// mask: one '#' per decimal of the tick ("#.##" for 0.01, "#" for 1)
|
|
98
|
+
const m = /^\d+(?:\.(\d+))?(?:e-(\d+))?$/.exec(String(mintick));
|
|
99
|
+
const decimals = m ? (m[1]?.length ?? 0) + Number(m[2] ?? 0) : 0;
|
|
100
|
+
const mask = decimals ? '#.' + '#'.repeat(decimals) : '#';
|
|
101
|
+
return formatNumber(round_to_mintick(value, mintick), mask, 'halfUpShortest');
|
|
102
|
+
}
|
|
80
103
|
default:
|
|
81
104
|
return formatNumber(value, format, 'halfUpShortest');
|
|
82
105
|
}
|
|
@@ -85,26 +108,36 @@ export function tostring(value, format) {
|
|
|
85
108
|
* Converts a string to a number (float).
|
|
86
109
|
*
|
|
87
110
|
* @param str - The string to convert
|
|
88
|
-
* @returns The numeric value, or null if conversion fails
|
|
111
|
+
* @returns The numeric value, or null (na) if conversion fails
|
|
89
112
|
*
|
|
90
113
|
* @remarks
|
|
91
|
-
*
|
|
92
|
-
* -
|
|
93
|
-
* -
|
|
94
|
-
* -
|
|
95
|
-
*
|
|
114
|
+
* As in PineScript:
|
|
115
|
+
* - The whole text must be a number: a sign, digits and one optional "." ("0.5", ".5", "5.", "-12"); "12abc" is na
|
|
116
|
+
* - Scientific notation ("1e3"), "Infinity", "NaN", hexadecimal, "1,000" give na
|
|
117
|
+
* - The characters U+0000 to U+0020 (space, tab, line feed...) around the number are ignored; other spaces
|
|
118
|
+
* (no-break space U+00A0, U+3000) give na
|
|
96
119
|
*
|
|
97
120
|
* @example
|
|
98
121
|
* ```typescript
|
|
99
122
|
* str.tonumber("123") // Returns: 123
|
|
100
123
|
* str.tonumber("45.67") // Returns: 45.67
|
|
101
124
|
* str.tonumber("abc") // Returns: null
|
|
102
|
-
* str.tonumber("
|
|
125
|
+
* str.tonumber("12abc") // Returns: null
|
|
126
|
+
* str.tonumber("1e3") // Returns: null
|
|
103
127
|
* ```
|
|
104
128
|
*/
|
|
105
129
|
export function tonumber(str) {
|
|
106
|
-
|
|
107
|
-
|
|
130
|
+
// remove the characters U+0000..U+0020 at both ends
|
|
131
|
+
let start = 0;
|
|
132
|
+
let end = str.length;
|
|
133
|
+
while (start < end && str.charCodeAt(start) <= 0x20)
|
|
134
|
+
start++;
|
|
135
|
+
while (end > start && str.charCodeAt(end - 1) <= 0x20)
|
|
136
|
+
end--;
|
|
137
|
+
const text = str.slice(start, end);
|
|
138
|
+
if (!/^[+-]?(?:\d+\.?\d*|\.\d+)$/.test(text))
|
|
139
|
+
return null;
|
|
140
|
+
return parseFloat(text);
|
|
108
141
|
}
|
|
109
142
|
/**
|
|
110
143
|
* Extracts a substring from a string.
|
|
@@ -115,6 +148,7 @@ export function tonumber(str) {
|
|
|
115
148
|
* @returns The extracted substring
|
|
116
149
|
*
|
|
117
150
|
* @remarks
|
|
151
|
+
* - An na `end` (NaN / null) is a runtime error in PineScript: it throws
|
|
118
152
|
* - If begin > end, indices are swapped (JavaScript behavior)
|
|
119
153
|
* - Negative indices are treated as 0
|
|
120
154
|
* - Indices beyond string length return empty string
|
|
@@ -127,6 +161,8 @@ export function tonumber(str) {
|
|
|
127
161
|
* ```
|
|
128
162
|
*/
|
|
129
163
|
export function substring(str, begin, end) {
|
|
164
|
+
if (end === null || Number.isNaN(end))
|
|
165
|
+
throw new Error('str.substring: the end position is na');
|
|
130
166
|
return str.substring(begin, end);
|
|
131
167
|
}
|
|
132
168
|
/**
|
|
@@ -187,51 +223,65 @@ export function contains(source, str) {
|
|
|
187
223
|
*
|
|
188
224
|
* @param source - The string to search in
|
|
189
225
|
* @param str - The substring to search for
|
|
190
|
-
* @returns The 0-based index of the first occurrence, or
|
|
226
|
+
* @returns The 0-based index of the first occurrence, or na (NaN) if not found
|
|
191
227
|
*
|
|
192
228
|
* @remarks
|
|
193
229
|
* - Search is case-sensitive
|
|
194
230
|
* - Returns 0 for empty search string
|
|
195
|
-
* - Returns
|
|
231
|
+
* - Returns na (NaN) if substring is not found, as in PineScript
|
|
196
232
|
*
|
|
197
233
|
* @example
|
|
198
234
|
* ```typescript
|
|
199
235
|
* str.pos("hello world", "world") // Returns: 6
|
|
200
236
|
* str.pos("hello world", "o") // Returns: 4 (first occurrence)
|
|
201
|
-
* str.pos("hello", "xyz") // Returns:
|
|
237
|
+
* str.pos("hello", "xyz") // Returns: NaN (na)
|
|
202
238
|
* ```
|
|
203
239
|
*/
|
|
204
240
|
export function pos(source, str) {
|
|
205
|
-
|
|
241
|
+
const index = source.indexOf(str);
|
|
242
|
+
return index === -1 ? NaN : index;
|
|
206
243
|
}
|
|
207
244
|
/**
|
|
208
|
-
* Replaces
|
|
245
|
+
* Replaces the Nth occurrence of a substring (PineScript `str.replace`).
|
|
209
246
|
*
|
|
210
247
|
* @param source - The source string
|
|
211
248
|
* @param target - The substring to replace
|
|
212
249
|
* @param replacement - The string to replace with
|
|
213
|
-
* @param occurrence -
|
|
214
|
-
* @returns The string with
|
|
250
|
+
* @param occurrence - 0-based occurrence to replace (default 0, the first one)
|
|
251
|
+
* @returns The string with one occurrence replaced
|
|
215
252
|
*
|
|
216
253
|
* @remarks
|
|
217
|
-
*
|
|
218
|
-
* -
|
|
219
|
-
* -
|
|
254
|
+
* PineScript rules:
|
|
255
|
+
* - only the Nth occurrence is replaced; an na occurrence is 0 (`str.replace("aaa", "a", "-", na)` is "-aa")
|
|
256
|
+
* - occurrences overlap: "aa" occurs at 0 and 1 in "aaa" (`str.replace("aaa", "aa", "-", 1)` is "a-")
|
|
257
|
+
* - an empty target inserts the replacement at character N, at most at the end
|
|
258
|
+
* (`str.replace("abc", "", "-", 2)` is "ab-c")
|
|
259
|
+
* - fewer than N + 1 occurrences (or a negative N) leave the source unchanged
|
|
220
260
|
*
|
|
221
261
|
* @example
|
|
222
262
|
* ```typescript
|
|
223
|
-
* str.replace("hello world hello", "hello", "hi"
|
|
224
|
-
* str.replace("hello world hello", "hello", "hi") // Returns: "
|
|
263
|
+
* str.replace("hello world hello", "hello", "hi") // Returns: "hi world hello"
|
|
264
|
+
* str.replace("hello world hello", "hello", "hi", 1) // Returns: "hello world hi"
|
|
225
265
|
* str.replace("test", "xyz", "abc") // Returns: "test"
|
|
226
266
|
* ```
|
|
227
267
|
*/
|
|
228
|
-
export function replace(source, target, replacement, occurrence) {
|
|
229
|
-
|
|
230
|
-
|
|
268
|
+
export function replace(source, target, replacement, occurrence = 0) {
|
|
269
|
+
const n = occurrence === null || Number.isNaN(occurrence) ? 0 : Math.trunc(occurrence);
|
|
270
|
+
if (n < 0)
|
|
271
|
+
return source;
|
|
272
|
+
let index;
|
|
273
|
+
if (target === '') {
|
|
274
|
+
index = Math.min(n, source.length);
|
|
231
275
|
}
|
|
232
276
|
else {
|
|
233
|
-
|
|
277
|
+
index = -1;
|
|
278
|
+
for (let k = 0; k <= n; k++) {
|
|
279
|
+
index = source.indexOf(target, index + 1);
|
|
280
|
+
if (index === -1)
|
|
281
|
+
return source;
|
|
282
|
+
}
|
|
234
283
|
}
|
|
284
|
+
return source.slice(0, index) + replacement + source.slice(index + target.length);
|
|
235
285
|
}
|
|
236
286
|
/**
|
|
237
287
|
* Replaces all occurrences of a target string with a replacement string.
|
|
@@ -265,7 +315,7 @@ export function replace_all(source, target, replacement) {
|
|
|
265
315
|
* @returns Array of substrings
|
|
266
316
|
*
|
|
267
317
|
* @remarks
|
|
268
|
-
* - Empty separator splits into individual characters
|
|
318
|
+
* - Empty separator splits into individual characters; an empty string gives [""] (also with "")
|
|
269
319
|
* - If separator is not found, returns array with original string
|
|
270
320
|
* - Consecutive separators create empty strings in result
|
|
271
321
|
*
|
|
@@ -277,7 +327,8 @@ export function replace_all(source, target, replacement) {
|
|
|
277
327
|
* ```
|
|
278
328
|
*/
|
|
279
329
|
export function split(str, separator) {
|
|
280
|
-
|
|
330
|
+
// JavaScript gives [] for "".split(""); PineScript gives [""]
|
|
331
|
+
return str === '' ? [''] : str.split(separator);
|
|
281
332
|
}
|
|
282
333
|
/**
|
|
283
334
|
* Concatenates multiple strings into one.
|
|
@@ -305,7 +356,8 @@ export function concat(...strings) {
|
|
|
305
356
|
* @remarks
|
|
306
357
|
* As in PineScript: numbers in `{n}` use
|
|
307
358
|
* "#,##0.###" (1234.5678 gives "1,234.568"); number patterns round half to even on the exact
|
|
308
|
-
* value; `'...'` is literal text and `''` a quote;
|
|
359
|
+
* value (16 decimals at most from 1e-3 up); an array gives "[a, b]"; `'...'` is literal text and `''` a quote;
|
|
360
|
+
* a missing argument leaves `{n}` in the text.
|
|
309
361
|
* Dates are formatted in UTC here; PineScript uses the exchange time zone.
|
|
310
362
|
*
|
|
311
363
|
* @example
|
|
@@ -441,26 +493,25 @@ export function trimRight(str) {
|
|
|
441
493
|
return str.trimEnd();
|
|
442
494
|
}
|
|
443
495
|
/**
|
|
444
|
-
*
|
|
496
|
+
* Returns the first substring of `source` that matches the `regex` (PineScript `str.match`).
|
|
445
497
|
*
|
|
446
|
-
* @param source -
|
|
447
|
-
* @param regex -
|
|
448
|
-
* @returns
|
|
498
|
+
* @param source - Source string
|
|
499
|
+
* @param regex - Regular expression
|
|
500
|
+
* @returns The first match (searched anywhere in the string), or na (null) when nothing matches or the match is empty
|
|
449
501
|
*
|
|
450
502
|
* @remarks
|
|
503
|
+
* - As PineScript: "Hello World!" with "o" gives "o", with "[a-z]+" gives "ello"; no match gives na
|
|
451
504
|
* - Uses JavaScript regex syntax
|
|
452
|
-
* - Match is case-sensitive by default
|
|
453
|
-
* - Pattern is tested against entire string
|
|
454
505
|
*
|
|
455
506
|
* @example
|
|
456
507
|
* ```typescript
|
|
457
|
-
* str.match("
|
|
458
|
-
* str.match("
|
|
459
|
-
* str.match("abc", "[A-Z]+") // Returns: false
|
|
508
|
+
* str.match("abc123def", "[0-9]+") // Returns: "123"
|
|
509
|
+
* str.match("abc", "[0-9]+") // Returns: null (na)
|
|
460
510
|
* ```
|
|
461
511
|
*/
|
|
462
512
|
export function match(source, regex) {
|
|
463
|
-
|
|
513
|
+
const found = new RegExp(regex).exec(source);
|
|
514
|
+
return found && found[0] !== '' ? found[0] : null;
|
|
464
515
|
}
|
|
465
516
|
/**
|
|
466
517
|
* Formats a timestamp as a string according to the specified format.
|
|
@@ -502,23 +553,23 @@ export function match(source, regex) {
|
|
|
502
553
|
* Constructs a new string containing the source string repeated N times with an optional separator.
|
|
503
554
|
*
|
|
504
555
|
* @param source - The string to repeat
|
|
505
|
-
* @param count - Number of times to repeat
|
|
556
|
+
* @param count - Number of times to repeat
|
|
506
557
|
* @param separator - String to inject between repeated instances. Optional, defaults to empty string.
|
|
507
|
-
* @returns The repeated string, or null if source is
|
|
558
|
+
* @returns The repeated string, or null (na) if source is na or count is 0 / negative / na, as in PineScript
|
|
508
559
|
*
|
|
509
560
|
* @example
|
|
510
561
|
* ```typescript
|
|
511
562
|
* str.repeat("ab", 3) // Returns: "ababab"
|
|
512
563
|
* str.repeat("?", 3, ",") // Returns: "?,?,?"
|
|
513
|
-
* str.repeat("hello", 0) // Returns:
|
|
564
|
+
* str.repeat("hello", 0) // Returns: null (na)
|
|
514
565
|
* str.repeat("x", 1) // Returns: "x"
|
|
515
566
|
* ```
|
|
516
567
|
*/
|
|
517
568
|
export function repeat(source, count, separator = '') {
|
|
518
569
|
if (source == null)
|
|
519
570
|
return null;
|
|
520
|
-
if (count
|
|
521
|
-
return
|
|
571
|
+
if (!(count > 0))
|
|
572
|
+
return null; // 0, negative or na: na
|
|
522
573
|
return Array(count).fill(source).join(separator);
|
|
523
574
|
}
|
|
524
575
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/str/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/str/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGpD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,MAAM,CAAC,GAAkB;IACvC,OAAO,GAAG,CAAC,MAAM,CAAC;AACpB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAU,EAAE,MAAsB,EAAE,OAAe;IAC1E,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACpD,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;QAAE,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;I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AAC,OAAO,EAAE,CAAC;AACvB,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,KAAK,CAAC,MAAqB,EAAE,KAAoB;IAC/D,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC7C,OAAO,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACpD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,MAAM,CAAC,MAAqB,EAAE,KAAiB,EAAE,YAA2B,EAAE;IAC5F,IAAI,MAAM,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC;IAChC,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC,CAAC,wBAAwB;IACvD,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACnD,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW,CAAC,IAAgB,EAAE,SAAwB,wBAAwB,EAAE,WAA0B,SAAS;IACjI,OAAO,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `str.format` patterns as PineScript formats them (Java MessageFormat):
|
|
3
3
|
*
|
|
4
|
-
* - `{n}` inserts argument n; numbers use "#,##0.###" (1234.5678 gives "1,234.568")
|
|
4
|
+
* - `{n}` inserts argument n; numbers use "#,##0.###" (1234.5678 gives "1,234.568"); an array gives
|
|
5
|
+
* "[Hello, World!]"
|
|
5
6
|
* - `{n,number}`, `{n,number,integer}` ("#,##0"), `{n,number,percent}` ("#,##0%"),
|
|
6
7
|
* `{n,number,currency}` ("$1,234.57", "-$7.00"), `{n,number,<pattern>}`
|
|
7
8
|
* - `{n,date}`, `{n,time}`, `{n,date,<pattern>}`, `{n,time,<pattern>}` (styles short, medium, long, full)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageformat.d.ts","sourceRoot":"","sources":["../../../src/str/messageformat.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"messageformat.d.ts","sourceRoot":"","sources":["../../../src/str/messageformat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA+DH,6HAA6H;AAC7H,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,MAAM,CAsCzG"}
|