oakscriptjs 0.10.0 → 0.10.1
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/index.d.ts +3 -2
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/runtime/index.d.ts +2 -1
- package/dist/cjs/runtime/index.d.ts.map +1 -1
- package/dist/cjs/runtime/index.js +2 -0
- package/dist/cjs/runtime/index.js.map +2 -2
- package/dist/cjs/runtime/input-active.d.ts +27 -0
- package/dist/cjs/runtime/input-active.d.ts.map +1 -0
- package/dist/cjs/runtime/input-active.js +44 -0
- package/dist/cjs/runtime/input-active.js.map +7 -0
- package/dist/cjs/runtime/types.d.ts +29 -2
- package/dist/cjs/runtime/types.d.ts.map +1 -1
- package/dist/cjs/runtime/types.js.map +1 -1
- package/dist/cjs/script/index.d.ts +24 -5
- package/dist/cjs/script/index.d.ts.map +1 -1
- package/dist/cjs/script/index.js +22 -2
- package/dist/cjs/script/index.js.map +2 -2
- package/dist/cjs/str/index.d.ts +9 -3
- package/dist/cjs/str/index.d.ts.map +1 -1
- package/dist/cjs/str/index.js +11 -6
- package/dist/cjs/str/index.js.map +2 -2
- package/dist/cjs/str/numberformat.d.ts +6 -0
- package/dist/cjs/str/numberformat.d.ts.map +1 -1
- package/dist/cjs/str/numberformat.js +9 -1
- package/dist/cjs/str/numberformat.js.map +2 -2
- package/dist/esm/index.d.ts +3 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/runtime/index.d.ts +2 -1
- package/dist/esm/runtime/index.d.ts.map +1 -1
- package/dist/esm/runtime/index.js +1 -0
- package/dist/esm/runtime/index.js.map +1 -1
- package/dist/esm/runtime/input-active.d.ts +27 -0
- package/dist/esm/runtime/input-active.d.ts.map +1 -0
- package/dist/esm/runtime/input-active.js +54 -0
- package/dist/esm/runtime/input-active.js.map +1 -0
- package/dist/esm/runtime/types.d.ts +29 -2
- package/dist/esm/runtime/types.d.ts.map +1 -1
- package/dist/esm/script/index.d.ts +24 -5
- package/dist/esm/script/index.d.ts.map +1 -1
- package/dist/esm/script/index.js +27 -3
- package/dist/esm/script/index.js.map +1 -1
- package/dist/esm/str/index.d.ts +9 -3
- package/dist/esm/str/index.d.ts.map +1 -1
- package/dist/esm/str/index.js +25 -10
- package/dist/esm/str/index.js.map +1 -1
- package/dist/esm/str/numberformat.d.ts +6 -0
- package/dist/esm/str/numberformat.d.ts.map +1 -1
- package/dist/esm/str/numberformat.js +12 -0
- package/dist/esm/str/numberformat.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +3 -1
- package/src/runtime/index.ts +3 -0
- package/src/runtime/input-active.ts +50 -0
- package/src/runtime/types.ts +25 -2
- package/src/script/index.ts +47 -6
- package/src/str/index.ts +23 -10
- package/src/str/numberformat.ts +13 -0
package/dist/cjs/str/index.d.ts
CHANGED
|
@@ -31,6 +31,8 @@ export declare function length(str: simple_string): int;
|
|
|
31
31
|
* `format.price` / `format.inherit`
|
|
32
32
|
* @param mintick - Tick size for `format.mintick` (PineScript `syminfo.mintick`, implicit there). Not part of the
|
|
33
33
|
* PineScript signature: the core function cannot see the chart, so pass it, as for `math.round_to_mintick`
|
|
34
|
+
* @param pricescale - Price scale of the symbol for `format.mintick` (PineScript `syminfo.pricescale`), needed for a
|
|
35
|
+
* symbol priced in fractions (32 for a 1/32 tick). Default: 10^(decimals of `mintick`)
|
|
34
36
|
* @returns String representation of the value
|
|
35
37
|
*
|
|
36
38
|
* @remarks
|
|
@@ -44,8 +46,12 @@ export declare function length(str: simple_string): int;
|
|
|
44
46
|
* - `format.percent` shows 2 decimals and "%" without multiplying; `format.volume` uses K, M, B, T
|
|
45
47
|
* - `format.price` and `format.inherit` give "price1" / "inherit1" in PineScript: they are patterns
|
|
46
48
|
* without digit characters, and oakscriptjs does the same
|
|
47
|
-
* - `format.mintick`
|
|
48
|
-
*
|
|
49
|
+
* - `format.mintick` shows floor(log10(pricescale)) decimals, zeros included ("1.00", "0.40" for tick 0.01), and
|
|
50
|
+
* rounds in two steps, with mintick = minmove / pricescale: the double quotient `|x| / (1 / pricescale)` half away
|
|
51
|
+
* from zero (140.355 / 0.01 = 14035.499999999998 gives "140.35", where `math.round_to_mintick` gives 140.36),
|
|
52
|
+
* then `floor(units / minmove + 0.5)` ticks (tick 0.02: 0.005 gives "0.02", -0.01 gives "0.00"). With a
|
|
53
|
+
* pricescale that is no power of 10 the tick value is then rounded half even to those decimals (1/32: 25.25 gives
|
|
54
|
+
* "25.2", -0.02 gives "-0.0"). It throws without `mintick`
|
|
49
55
|
* - na gives "NaN" ("NaN%" with `format.percent`); an infinity gives "NaN" too ("NaN%" for `format.percent`,
|
|
50
56
|
* "NaNT" for `format.volume`), except `format.mintick`, which gives "Infinity" / "-Infinity"
|
|
51
57
|
*
|
|
@@ -57,7 +63,7 @@ export declare function length(str: simple_string): int;
|
|
|
57
63
|
* str.tostring(12345.678, format.volume) // "12.346K"
|
|
58
64
|
* ```
|
|
59
65
|
*/
|
|
60
|
-
export declare function tostring(value: any, format?: simple_string, mintick?: float): string;
|
|
66
|
+
export declare function tostring(value: any, format?: simple_string, mintick?: float, pricescale?: float): string;
|
|
61
67
|
/**
|
|
62
68
|
* Converts a string to a number (float).
|
|
63
69
|
*
|
|
@@ -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;AAKH,OAAO,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAErF;;;;;;;;;;;GAWG;AACH,wBAAgB,MAA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AM,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/cjs/str/index.js
CHANGED
|
@@ -45,11 +45,10 @@ module.exports = __toCommonJS(str_exports);
|
|
|
45
45
|
var import_numberformat = require("./numberformat.js");
|
|
46
46
|
var import_messageformat = require("./messageformat.js");
|
|
47
47
|
var import_dateformat = require("./dateformat.js");
|
|
48
|
-
var import_math = require("../math/index.js");
|
|
49
48
|
function length(str) {
|
|
50
49
|
return str.length;
|
|
51
50
|
}
|
|
52
|
-
function tostring(value, format2, mintick) {
|
|
51
|
+
function tostring(value, format2, mintick, pricescale) {
|
|
53
52
|
if (typeof value !== "number") return String(value);
|
|
54
53
|
if (Number.isNaN(value)) return format2 === "percent" ? "NaN%" : "NaN";
|
|
55
54
|
if (!Number.isFinite(value)) {
|
|
@@ -76,10 +75,16 @@ function tostring(value, format2, mintick) {
|
|
|
76
75
|
if (mintick === void 0) {
|
|
77
76
|
throw new Error("str.tostring(x, format.mintick) needs the tick size: pass it as str.tostring(x, format.mintick, syminfo.mintick)");
|
|
78
77
|
}
|
|
79
|
-
const
|
|
80
|
-
const decimals =
|
|
81
|
-
const mask = decimals ? "
|
|
82
|
-
return (0, import_numberformat.formatNumber)(
|
|
78
|
+
const [minmove, scale] = (0, import_numberformat.tickScale)(mintick, pricescale);
|
|
79
|
+
const decimals = Math.floor(Math.log10(scale) + 1e-9);
|
|
80
|
+
const mask = decimals > 0 ? "0." + "0".repeat(decimals) : "0";
|
|
81
|
+
if (!(minmove >= 1)) return (0, import_numberformat.formatNumber)(value, mask, "halfUpShortest");
|
|
82
|
+
const scaled = Math.abs(value) / (1 / scale);
|
|
83
|
+
let units = Math.trunc(scaled);
|
|
84
|
+
if (scaled - units >= 0.5) units++;
|
|
85
|
+
const ticks = Math.floor((value < 0 ? -units : units) / minmove + 0.5);
|
|
86
|
+
const text = (0, import_numberformat.formatNumber)(Math.abs(ticks) * minmove / scale, mask, "halfEvenExact");
|
|
87
|
+
return ticks < 0 ? "-" + text : text;
|
|
83
88
|
}
|
|
84
89
|
default:
|
|
85
90
|
return (0, import_numberformat.formatNumber)(value, format2, "halfUpShortest");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/str/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * String namespace\n * Mirrors PineScript's str.* functions for string manipulation and analysis.\n *\n * @remarks\n * All string functions in this namespace follow PineScript v6 API specifications.\n * String operations are case-sensitive unless otherwise specified.\n *\n * @version 6\n */\n\nimport { formatNumber } from './numberformat.js';\nimport { formatMessage } from './messageformat.js';\nimport { formatDate } from './dateformat.js';\nimport { round_to_mintick } from '../math/index.js';\nimport type { int, bool, float, simple_int, simple_string } from '../types/index.js';\n\n/**\n * Returns the length of a string.\n *\n * @param str - The string to measure\n * @returns The number of characters in the string\n *\n * @example\n * ```typescript\n * str.length(\"Hello\") // Returns: 5\n * str.length(\"\") // Returns: 0\n * ```\n */\nexport function length(str: simple_string): int {\n return str.length;\n}\n\n/**\n * Converts a value to its string representation (PineScript `str.tostring`).\n *\n * @param value - The value to convert (number, boolean, string, etc.)\n * @param format - Optional number format: a pattern (\"#.##\", \"#,###.00\", \"0.00%\", \"0.00E0\", \"#.##;(#.##)\") or\n * `format.percent` (\"percent\"), `format.volume` (\"volume\"), `format.mintick` (\"mintick\"),\n * `format.price` / `format.inherit`\n * @param mintick - Tick size for `format.mintick` (PineScript `syminfo.mintick`, implicit there). Not part of the\n * PineScript signature: the core function cannot see the chart, so pass it, as for `math.round_to_mintick`\n * @returns String representation of the value\n *\n * @remarks\n * As in PineScript:\n * - without format, numbers show up to 10 decimals (\"0.3333333333\"); 1e21 and more use \"1E21\"\n * - patterns round half away from zero on the shortest decimal form: 1.005 with \"#.##\" gives \"1.01\";\n * at most 16 decimals from 1e-3 up (0.0012345678901234567 with 20 '#' decimals gives \"0.0012345678901235\")\n * - \"pos;neg\" patterns: a negative number takes the text of the negative subpattern (\"#.##;(#.##)\": \"(3.5)\")\n * - \"#\" is an optional digit (\"1.5\" with \"#.##\"), \"0\" a required digit (\"1.50\" with \"0.00\"),\n * \",\" groups thousands, \"%\" multiplies by 100, 'text' is literal text\n * - `format.percent` shows 2 decimals and \"%\" without multiplying; `format.volume` uses K, M, B, T\n * - `format.price` and `format.inherit` give \"price1\" / \"inherit1\" in PineScript: they are patterns\n * without digit characters, and oakscriptjs does the same\n * - `format.mintick` rounds to the tick (`math.round_to_mintick`) and shows the tick's decimals (\"#.##\" for 0.01);\n * it throws without `mintick`\n * - na gives \"NaN\" (\"NaN%\" with `format.percent`); an infinity gives \"NaN\" too (\"NaN%\" for `format.percent`,\n * \"NaNT\" for `format.volume`), except `format.mintick`, which gives \"Infinity\" / \"-Infinity\"\n *\n * @example\n * ```typescript\n * str.tostring(123) // \"123\"\n * str.tostring(1.5, \"#.##\") // \"1.5\"\n * str.tostring(0.5, \"#.00\") // \".50\"\n * str.tostring(12345.678, format.volume) // \"12.346K\"\n * ```\n */\nexport function tostring(value: any, format?: simple_string, mintick?: float): string {\n if (typeof value !== 'number') return String(value);\n if (Number.isNaN(value)) return format === 'percent' ? 'NaN%' : 'NaN';\n if (!Number.isFinite(value)) {\n // the chart formatter has no infinity: NaN with the format's suffix\n if (format === 'mintick') return String(value);\n return format === 'percent' ? 'NaN%' : format === 'volume' ? 'NaNT' : 'NaN';\n }\n if (format === undefined || format === '') {\n if (Math.abs(value) >= 1e21 && Number.isFinite(value)) {\n return String(value).replace('e+', 'E').replace(/\\.0+E/, 'E');\n }\n return formatNumber(value, '#.##########', 'halfUpShortest');\n }\n switch (format) {\n case 'percent':\n return formatNumber(value, '0.00', 'halfUpShortest') + '%';\n case 'volume': {\n const abs = Math.abs(value);\n for (const [size, unit] of [[1e12, 'T'], [1e9, 'B'], [1e6, 'M'], [1e3, 'K']] as const) {\n if (abs >= size) return formatNumber(value / size, '#.###', 'halfUpShortest') + unit;\n }\n return formatNumber(value, '#', 'halfUpShortest');\n }\n case 'mintick': {\n if (mintick === undefined) {\n throw new Error('str.tostring(x, format.mintick) needs the tick size: pass it as str.tostring(x, format.mintick, syminfo.mintick)');\n }\n // mask: one '#' per decimal of the tick (\"#.##\" for 0.01, \"#\" for 1)\n const m = /^\\d+(?:\\.(\\d+))?(?:e-(\\d+))?$/.exec(String(mintick));\n const decimals = m ? (m[1]?.length ?? 0) + Number(m[2] ?? 0) : 0;\n const mask = decimals ? '#.' + '#'.repeat(decimals) : '#';\n return formatNumber(round_to_mintick(value, mintick), mask, 'halfUpShortest');\n }\n default:\n return formatNumber(value, format, 'halfUpShortest');\n }\n}\n\n/**\n * Converts a string to a number (float).\n *\n * @param str - The string to convert\n * @returns The numeric value, or null (na) if conversion fails\n *\n * @remarks\n * As in PineScript:\n * - The whole text must be a number: a sign, digits and one optional \".\" (\"0.5\", \".5\", \"5.\", \"-12\"); \"12abc\" is na\n * - Scientific notation (\"1e3\"), \"Infinity\", \"NaN\", hexadecimal, \"1,000\" give na\n * - The characters U+0000 to U+0020 (space, tab, line feed...) around the number are ignored; other spaces\n * (no-break space U+00A0, U+3000) give na\n *\n * @example\n * ```typescript\n * str.tonumber(\"123\") // Returns: 123\n * str.tonumber(\"45.67\") // Returns: 45.67\n * str.tonumber(\"abc\") // Returns: null\n * str.tonumber(\"12abc\") // Returns: null\n * str.tonumber(\"1e3\") // Returns: null\n * ```\n */\nexport function tonumber(str: simple_string): float | null {\n // remove the characters U+0000..U+0020 at both ends\n let start = 0;\n let end = str.length;\n while (start < end && str.charCodeAt(start) <= 0x20) start++;\n while (end > start && str.charCodeAt(end - 1) <= 0x20) end--;\n const text = str.slice(start, end);\n if (!/^[+-]?(?:\\d+\\.?\\d*|\\.\\d+)$/.test(text)) return null;\n return parseFloat(text);\n}\n\n/**\n * Extracts a substring from a string.\n *\n * @param str - The source string\n * @param begin - Starting index (0-based, inclusive)\n * @param end - Ending index (0-based, exclusive). If omitted, extracts to end of string\n * @returns The extracted substring\n *\n * @remarks\n * - An na `end` (NaN / null) is a runtime error in PineScript: it throws\n * - If begin > end, indices are swapped (JavaScript behavior)\n * - Negative indices are treated as 0\n * - Indices beyond string length return empty string\n *\n * @example\n * ```typescript\n * str.substring(\"hello world\", 0, 5) // Returns: \"hello\"\n * str.substring(\"hello world\", 6) // Returns: \"world\"\n * str.substring(\"test\", 1, 3) // Returns: \"es\"\n * ```\n */\nexport function substring(str: simple_string, begin: simple_int, end?: simple_int): string {\n if (end === null || Number.isNaN(end)) throw new Error('str.substring: the end position is na');\n return str.substring(begin, end);\n}\n\n/**\n * Converts all characters in a string to uppercase.\n *\n * @param str - The string to convert\n * @returns The uppercase string\n *\n * @example\n * ```typescript\n * str.upper(\"hello\") // Returns: \"HELLO\"\n * str.upper(\"Hello World\") // Returns: \"HELLO WORLD\"\n * str.upper(\"test123\") // Returns: \"TEST123\"\n * ```\n */\nexport function upper(str: simple_string): string {\n return str.toUpperCase();\n}\n\n/**\n * Converts all characters in a string to lowercase.\n *\n * @param str - The string to convert\n * @returns The lowercase string\n *\n * @example\n * ```typescript\n * str.lower(\"HELLO\") // Returns: \"hello\"\n * str.lower(\"Hello World\") // Returns: \"hello world\"\n * str.lower(\"TEST123\") // Returns: \"test123\"\n * ```\n */\nexport function lower(str: simple_string): string {\n return str.toLowerCase();\n}\n\n/**\n * Checks if a string contains a substring.\n *\n * @param source - The string to search in\n * @param str - The substring to search for\n * @returns True if source contains str, false otherwise\n *\n * @remarks\n * - Search is case-sensitive\n * - Empty string is contained in any string\n *\n * @example\n * ```typescript\n * str.contains(\"hello world\", \"world\") // Returns: true\n * str.contains(\"hello world\", \"World\") // Returns: false (case-sensitive)\n * str.contains(\"test\", \"xyz\") // Returns: false\n * ```\n */\nexport function contains(source: simple_string, str: simple_string): bool {\n return source.includes(str);\n}\n\n/**\n * Returns the position of the first occurrence of a substring.\n *\n * @param source - The string to search in\n * @param str - The substring to search for\n * @returns The 0-based index of the first occurrence, or na (NaN) if not found\n *\n * @remarks\n * - Search is case-sensitive\n * - Returns 0 for empty search string\n * - Returns na (NaN) if substring is not found, as in PineScript\n *\n * @example\n * ```typescript\n * str.pos(\"hello world\", \"world\") // Returns: 6\n * str.pos(\"hello world\", \"o\") // Returns: 4 (first occurrence)\n * str.pos(\"hello\", \"xyz\") // Returns: NaN (na)\n * ```\n */\nexport function pos(source: simple_string, str: simple_string): int {\n const index = source.indexOf(str);\n return index === -1 ? NaN : index;\n}\n\n/**\n * Replaces the Nth occurrence of a substring (PineScript `str.replace`).\n *\n * @param source - The source string\n * @param target - The substring to replace\n * @param replacement - The string to replace with\n * @param occurrence - 0-based occurrence to replace (default 0, the first one)\n * @returns The string with one occurrence replaced\n *\n * @remarks\n * PineScript rules:\n * - only the Nth occurrence is replaced; an na occurrence is 0 (`str.replace(\"aaa\", \"a\", \"-\", na)` is \"-aa\")\n * - occurrences overlap: \"aa\" occurs at 0 and 1 in \"aaa\" (`str.replace(\"aaa\", \"aa\", \"-\", 1)` is \"a-\")\n * - an empty target inserts the replacement at character N, at most at the end\n * (`str.replace(\"abc\", \"\", \"-\", 2)` is \"ab-c\")\n * - fewer than N + 1 occurrences (or a negative N) leave the source unchanged\n *\n * @example\n * ```typescript\n * str.replace(\"hello world hello\", \"hello\", \"hi\") // Returns: \"hi world hello\"\n * str.replace(\"hello world hello\", \"hello\", \"hi\", 1) // Returns: \"hello world hi\"\n * str.replace(\"test\", \"xyz\", \"abc\") // Returns: \"test\"\n * ```\n */\nexport function replace(source: simple_string, target: simple_string, replacement: simple_string, occurrence: simple_int = 0): string {\n const n = occurrence === null || Number.isNaN(occurrence) ? 0 : Math.trunc(occurrence);\n if (n < 0) return source;\n let index: number;\n if (target === '') {\n index = Math.min(n, source.length);\n } else {\n index = -1;\n for (let k = 0; k <= n; k++) {\n index = source.indexOf(target, index + 1);\n if (index === -1) return source;\n }\n }\n return source.slice(0, index) + replacement + source.slice(index + target.length);\n}\n\n/**\n * Replaces all occurrences of a target string with a replacement string.\n *\n * @param source - The source string\n * @param target - The substring to find\n * @param replacement - The replacement string\n * @returns String with all occurrences replaced\n *\n * @remarks\n * - Replaces all occurrences of the target string\n * - Case sensitive\n * - If target is empty string, returns original string\n * - This matches PineScript's `str.replace_all()` behavior\n *\n * @example\n * ```typescript\n * str.replace_all(\"hello world hello\", \"hello\", \"hi\") // Returns: \"hi world hi\"\n * str.replace_all(\"a-b-c\", \"-\", \"_\") // Returns: \"a_b_c\"\n * str.replace_all(\"test\", \"x\", \"y\") // Returns: \"test\" (no match)\n * ```\n */\nexport function replace_all(source: simple_string, target: simple_string, replacement: simple_string): string {\n return source.replaceAll(target, replacement);\n}\n\n/**\n * Splits a string into an array of substrings using a separator.\n *\n * @param str - The string to split\n * @param separator - The separator string\n * @returns Array of substrings\n *\n * @remarks\n * - Empty separator splits into individual characters; an empty string gives [\"\"] (also with \"\")\n * - If separator is not found, returns array with original string\n * - Consecutive separators create empty strings in result\n *\n * @example\n * ```typescript\n * str.split(\"a,b,c\", \",\") // Returns: [\"a\", \"b\", \"c\"]\n * str.split(\"hello\", \"\") // Returns: [\"h\", \"e\", \"l\", \"l\", \"o\"]\n * str.split(\"a,,b\", \",\") // Returns: [\"a\", \"\", \"b\"]\n * ```\n */\nexport function split(str: simple_string, separator: simple_string): string[] {\n // JavaScript gives [] for \"\".split(\"\"); PineScript gives [\"\"]\n return str === '' ? [''] : str.split(separator);\n}\n\n/**\n * Concatenates multiple strings into one.\n *\n * @param strings - Variable number of strings to concatenate\n * @returns The concatenated string\n *\n * @example\n * ```typescript\n * str.concat(\"hello\", \" \", \"world\") // Returns: \"hello world\"\n * str.concat(\"a\", \"b\", \"c\") // Returns: \"abc\"\n * str.concat(\"test\") // Returns: \"test\"\n * ```\n */\nexport function concat(...strings: simple_string[]): string {\n return strings.join('');\n}\n\n/**\n * Formats a string with placeholders (PineScript `str.format`, Java MessageFormat syntax).\n *\n * @param formatStr - Pattern with `{0}`, `{1,number,#.##}`, `{0,number,percent}`, `{0,date,yyyy-MM-dd}`...\n * @param args - Values for the placeholders\n * @returns Formatted string\n *\n * @remarks\n * As in PineScript: numbers in `{n}` use\n * \"#,##0.###\" (1234.5678 gives \"1,234.568\"); number patterns round half to even on the exact\n * value (16 decimals at most from 1e-3 up); an array gives \"[a, b]\"; `'...'` is literal text and `''` a quote;\n * a missing argument leaves `{n}` in the text.\n * Dates are formatted in UTC here; PineScript uses the exchange time zone.\n *\n * @example\n * ```typescript\n * str.format('Close: {0,number,#.##}', 101.456) // \"Close: 101.46\"\n * str.format('{0} and {1}', 'a', 2) // \"a and 2\"\n * ```\n */\nexport function format(formatStr: simple_string, ...args: any[]): string {\n return formatMessage(formatStr, args, 'Etc/UTC');\n}\n\n/**\n * Checks if a string starts with a specific prefix.\n *\n * @param source - The string to check\n * @param str - The prefix to look for\n * @returns True if source starts with str, false otherwise\n *\n * @remarks\n * - Search is case-sensitive\n * - Empty string prefix always returns true\n *\n * @example\n * ```typescript\n * str.startswith(\"hello world\", \"hello\") // Returns: true\n * str.startswith(\"hello world\", \"Hello\") // Returns: false (case-sensitive)\n * str.startswith(\"test\", \"testing\") // Returns: false\n * ```\n */\nexport function startswith(source: simple_string, str: simple_string): bool {\n return source.startsWith(str);\n}\n\n/**\n * Checks if a string ends with a specific suffix.\n *\n * @param source - The string to check\n * @param str - The suffix to look for\n * @returns True if source ends with str, false otherwise\n *\n * @remarks\n * - Search is case-sensitive\n * - Empty string suffix always returns true\n *\n * @example\n * ```typescript\n * str.endswith(\"hello world\", \"world\") // Returns: true\n * str.endswith(\"hello world\", \"World\") // Returns: false (case-sensitive)\n * str.endswith(\"testing\", \"test\") // Returns: false\n * ```\n */\nexport function endswith(source: simple_string, str: simple_string): bool {\n return source.endsWith(str);\n}\n\n/**\n * Returns the character at a specific position in a string.\n *\n * @param str - The source string\n * @param pos - The 0-based position\n * @returns The character at the position, or empty string if out of bounds\n *\n * @remarks\n * - Returns empty string for negative or out-of-bounds positions\n * - Unicode characters may span multiple code units\n *\n * @example\n * ```typescript\n * str.charAt(\"hello\", 0) // Returns: \"h\"\n * str.charAt(\"hello\", 4) // Returns: \"o\"\n * str.charAt(\"hello\", 10) // Returns: \"\"\n * ```\n */\nexport function charAt(str: simple_string, pos: simple_int): string {\n return str.charAt(pos);\n}\n\n/**\n * Removes whitespace from both ends of a string.\n *\n * @param str - The string to trim\n * @returns The trimmed string\n *\n * @remarks\n * - Removes spaces, tabs, newlines, and other whitespace characters\n * - Preserves internal whitespace\n *\n * @example\n * ```typescript\n * str.trim(\" hello \") // Returns: \"hello\"\n * str.trim(\" hello world \") // Returns: \"hello world\"\n * str.trim(\"\\thello\\n\") // Returns: \"hello\"\n * ```\n */\nexport function trim(str: simple_string): string {\n return str.trim();\n}\n\n/**\n * Removes whitespace from the left (start) of a string.\n *\n * @param str - The string to trim\n * @returns The trimmed string\n *\n * @remarks\n * - Only removes leading whitespace\n * - Preserves trailing and internal whitespace\n *\n * @example\n * ```typescript\n * str.trimLeft(\" hello \") // Returns: \"hello \"\n * str.trimLeft(\" hello\") // Returns: \"hello\"\n * str.trimLeft(\"\\thello\") // Returns: \"hello\"\n * ```\n */\nexport function trimLeft(str: simple_string): string {\n return str.trimStart();\n}\n\n/**\n * Removes whitespace from the right (end) of a string.\n *\n * @param str - The string to trim\n * @returns The trimmed string\n *\n * @remarks\n * - Only removes trailing whitespace\n * - Preserves leading and internal whitespace\n *\n * @example\n * ```typescript\n * str.trimRight(\" hello \") // Returns: \" hello\"\n * str.trimRight(\"hello \") // Returns: \"hello\"\n * str.trimRight(\"hello\\t\") // Returns: \"hello\"\n * ```\n */\nexport function trimRight(str: simple_string): string {\n return str.trimEnd();\n}\n\n/**\n * Returns the first substring of `source` that matches the `regex` (PineScript `str.match`).\n *\n * @param source - Source string\n * @param regex - Regular expression\n * @returns The first match (searched anywhere in the string), or na (null) when nothing matches or the match is empty\n *\n * @remarks\n * - As PineScript: \"Hello World!\" with \"o\" gives \"o\", with \"[a-z]+\" gives \"ello\"; no match gives na\n * - Uses JavaScript regex syntax\n *\n * @example\n * ```typescript\n * str.match(\"abc123def\", \"[0-9]+\") // Returns: \"123\"\n * str.match(\"abc\", \"[0-9]+\") // Returns: null (na)\n * ```\n */\nexport function match(source: simple_string, regex: simple_string): simple_string | null {\n const found = new RegExp(regex).exec(source);\n return found && found[0] !== '' ? found[0] : null;\n}\n\n/**\n * Formats a timestamp as a string according to the specified format.\n *\n * @param time - Unix timestamp in milliseconds\n * @param format - Format string using PineScript format specifiers\n * @returns Formatted date/time string\n *\n * @remarks\n * Supported format specifiers (case-sensitive):\n * - `yyyy` - 4-digit year (e.g., \"2024\")\n * - `yy` - 2-digit year (e.g., \"24\")\n * - `MMMM` - Full month name (e.g., \"January\")\n * - `MMM` - Abbreviated month name (e.g., \"Jan\")\n * - `MM` - 2-digit month (01-12)\n * - `M` - Month (1-12)\n * - `dd` - 2-digit day (01-31)\n * - `d` - Day (1-31)\n * - `HH` - 2-digit hour (00-23)\n * - `H` - Hour (0-23)\n * - `hh` - 2-digit hour (01-12)\n * - `h` - Hour (1-12)\n * - `mm` - 2-digit minute (00-59)\n * - `m` - Minute (0-59)\n * - `ss` - 2-digit second (00-59)\n * - `s` - Second (0-59)\n * - `a` - AM/PM\n *\n * @example\n * ```typescript\n * const timestamp = 1609459200000; // Jan 1, 2021 00:00:00 UTC\n * str.format_time(timestamp, \"dd MMM yyyy\") // Returns: \"01 Jan 2021\"\n * str.format_time(timestamp, \"yyyy-MM-dd HH:mm:ss\") // Returns: \"2021-01-01 00:00:00\"\n * str.format_time(timestamp, \"MMM d, yyyy\") // Returns: \"Jan 1, 2021\"\n * str.format_time(timestamp, \"hh:mm a\") // Returns: \"12:00 AM\"\n * ```\n */\n/**\n * Constructs a new string containing the source string repeated N times with an optional separator.\n *\n * @param source - The string to repeat\n * @param count - Number of times to repeat\n * @param separator - String to inject between repeated instances. Optional, defaults to empty string.\n * @returns The repeated string, or null (na) if source is na or count is 0 / negative / na, as in PineScript\n *\n * @example\n * ```typescript\n * str.repeat(\"ab\", 3) // Returns: \"ababab\"\n * str.repeat(\"?\", 3, \",\") // Returns: \"?,?,?\"\n * str.repeat(\"hello\", 0) // Returns: null (na)\n * str.repeat(\"x\", 1) // Returns: \"x\"\n * ```\n */\nexport function repeat(source: simple_string, count: simple_int, separator: simple_string = ''): string | null {\n if (source == null) return null;\n if (!(count > 0)) return null; // 0, negative or na: na\n return Array(count).fill(source).join(separator);\n}\n\n/**\n * Formats a UNIX time (ms) with a date pattern (PineScript `str.format_time`).\n *\n * @param time - UNIX time in milliseconds\n * @param format - Java SimpleDateFormat pattern, e.g. \"yyyy-MM-dd HH:mm:ss\", \"dd MMM yyyy\", \"hh:mm a\"\n * @param timezone - UTC/GMT offset (\"UTC-5\") or IANA name (\"America/New_York\"). PineScript's default is\n * the exchange time zone, which is not known here: the default is UTC\n * @returns Formatted date string\n *\n * @remarks\n * Letters: y, M, d, E, u, D, w,\n * H, k, K, h, a, m, s, S, Z, z; 'text' is literal text.\n */\nexport function format_time(time: simple_int, format: simple_string = \"yyyy-MM-dd'T'HH:mm:ssZ\", timezone: simple_string = 'Etc/UTC'): string {\n return formatDate(time, format, timezone);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,
|
|
4
|
+
"sourcesContent": ["/**\n * String namespace\n * Mirrors PineScript's str.* functions for string manipulation and analysis.\n *\n * @remarks\n * All string functions in this namespace follow PineScript v6 API specifications.\n * String operations are case-sensitive unless otherwise specified.\n *\n * @version 6\n */\n\nimport { formatNumber, tickScale } from './numberformat.js';\nimport { formatMessage } from './messageformat.js';\nimport { formatDate } from './dateformat.js';\nimport type { int, bool, float, simple_int, simple_string } from '../types/index.js';\n\n/**\n * Returns the length of a string.\n *\n * @param str - The string to measure\n * @returns The number of characters in the string\n *\n * @example\n * ```typescript\n * str.length(\"Hello\") // Returns: 5\n * str.length(\"\") // Returns: 0\n * ```\n */\nexport function length(str: simple_string): int {\n return str.length;\n}\n\n/**\n * Converts a value to its string representation (PineScript `str.tostring`).\n *\n * @param value - The value to convert (number, boolean, string, etc.)\n * @param format - Optional number format: a pattern (\"#.##\", \"#,###.00\", \"0.00%\", \"0.00E0\", \"#.##;(#.##)\") or\n * `format.percent` (\"percent\"), `format.volume` (\"volume\"), `format.mintick` (\"mintick\"),\n * `format.price` / `format.inherit`\n * @param mintick - Tick size for `format.mintick` (PineScript `syminfo.mintick`, implicit there). Not part of the\n * PineScript signature: the core function cannot see the chart, so pass it, as for `math.round_to_mintick`\n * @param pricescale - Price scale of the symbol for `format.mintick` (PineScript `syminfo.pricescale`), needed for a\n * symbol priced in fractions (32 for a 1/32 tick). Default: 10^(decimals of `mintick`)\n * @returns String representation of the value\n *\n * @remarks\n * As in PineScript:\n * - without format, numbers show up to 10 decimals (\"0.3333333333\"); 1e21 and more use \"1E21\"\n * - patterns round half away from zero on the shortest decimal form: 1.005 with \"#.##\" gives \"1.01\";\n * at most 16 decimals from 1e-3 up (0.0012345678901234567 with 20 '#' decimals gives \"0.0012345678901235\")\n * - \"pos;neg\" patterns: a negative number takes the text of the negative subpattern (\"#.##;(#.##)\": \"(3.5)\")\n * - \"#\" is an optional digit (\"1.5\" with \"#.##\"), \"0\" a required digit (\"1.50\" with \"0.00\"),\n * \",\" groups thousands, \"%\" multiplies by 100, 'text' is literal text\n * - `format.percent` shows 2 decimals and \"%\" without multiplying; `format.volume` uses K, M, B, T\n * - `format.price` and `format.inherit` give \"price1\" / \"inherit1\" in PineScript: they are patterns\n * without digit characters, and oakscriptjs does the same\n * - `format.mintick` shows floor(log10(pricescale)) decimals, zeros included (\"1.00\", \"0.40\" for tick 0.01), and\n * rounds in two steps, with mintick = minmove / pricescale: the double quotient `|x| / (1 / pricescale)` half away\n * from zero (140.355 / 0.01 = 14035.499999999998 gives \"140.35\", where `math.round_to_mintick` gives 140.36),\n * then `floor(units / minmove + 0.5)` ticks (tick 0.02: 0.005 gives \"0.02\", -0.01 gives \"0.00\"). With a\n * pricescale that is no power of 10 the tick value is then rounded half even to those decimals (1/32: 25.25 gives\n * \"25.2\", -0.02 gives \"-0.0\"). It throws without `mintick`\n * - na gives \"NaN\" (\"NaN%\" with `format.percent`); an infinity gives \"NaN\" too (\"NaN%\" for `format.percent`,\n * \"NaNT\" for `format.volume`), except `format.mintick`, which gives \"Infinity\" / \"-Infinity\"\n *\n * @example\n * ```typescript\n * str.tostring(123) // \"123\"\n * str.tostring(1.5, \"#.##\") // \"1.5\"\n * str.tostring(0.5, \"#.00\") // \".50\"\n * str.tostring(12345.678, format.volume) // \"12.346K\"\n * ```\n */\nexport function tostring(value: any, format?: simple_string, mintick?: float, pricescale?: float): string {\n if (typeof value !== 'number') return String(value);\n if (Number.isNaN(value)) return format === 'percent' ? 'NaN%' : 'NaN';\n if (!Number.isFinite(value)) {\n // the chart formatter has no infinity: NaN with the format's suffix\n if (format === 'mintick') return String(value);\n return format === 'percent' ? 'NaN%' : format === 'volume' ? 'NaNT' : 'NaN';\n }\n if (format === undefined || format === '') {\n if (Math.abs(value) >= 1e21 && Number.isFinite(value)) {\n return String(value).replace('e+', 'E').replace(/\\.0+E/, 'E');\n }\n return formatNumber(value, '#.##########', 'halfUpShortest');\n }\n switch (format) {\n case 'percent':\n return formatNumber(value, '0.00', 'halfUpShortest') + '%';\n case 'volume': {\n const abs = Math.abs(value);\n for (const [size, unit] of [[1e12, 'T'], [1e9, 'B'], [1e6, 'M'], [1e3, 'K']] as const) {\n if (abs >= size) return formatNumber(value / size, '#.###', 'halfUpShortest') + unit;\n }\n return formatNumber(value, '#', 'halfUpShortest');\n }\n case 'mintick': {\n if (mintick === undefined) {\n throw new Error('str.tostring(x, format.mintick) needs the tick size: pass it as str.tostring(x, format.mintick, syminfo.mintick)');\n }\n const [minmove, scale] = tickScale(mintick, pricescale);\n const decimals = Math.floor(Math.log10(scale) + 1e-9);\n const mask = decimals > 0 ? '0.' + '0'.repeat(decimals) : '0';\n if (!(minmove >= 1)) return formatNumber(value, mask, 'halfUpShortest');\n // 1. the double quotient |x| / (1 / pricescale), half away from zero (not math.round_to_mintick's exact decimal)\n const scaled = Math.abs(value) / (1 / scale);\n let units = Math.trunc(scaled);\n if (scaled - units >= 0.5) units++;\n // 2. to the tick, a half going up (minmove 2: -0.01 gives \"0.00\", 0.01 gives \"0.02\")\n const ticks = Math.floor((value < 0 ? -units : units) / minmove + 0.5);\n // 3. the tick value at the scale's decimals; a negative one keeps its sign when it prints as zero (\"-0.0\")\n const text = formatNumber((Math.abs(ticks) * minmove) / scale, mask, 'halfEvenExact');\n return ticks < 0 ? '-' + text : text;\n }\n default:\n return formatNumber(value, format, 'halfUpShortest');\n }\n}\n\n/**\n * Converts a string to a number (float).\n *\n * @param str - The string to convert\n * @returns The numeric value, or null (na) if conversion fails\n *\n * @remarks\n * As in PineScript:\n * - The whole text must be a number: a sign, digits and one optional \".\" (\"0.5\", \".5\", \"5.\", \"-12\"); \"12abc\" is na\n * - Scientific notation (\"1e3\"), \"Infinity\", \"NaN\", hexadecimal, \"1,000\" give na\n * - The characters U+0000 to U+0020 (space, tab, line feed...) around the number are ignored; other spaces\n * (no-break space U+00A0, U+3000) give na\n *\n * @example\n * ```typescript\n * str.tonumber(\"123\") // Returns: 123\n * str.tonumber(\"45.67\") // Returns: 45.67\n * str.tonumber(\"abc\") // Returns: null\n * str.tonumber(\"12abc\") // Returns: null\n * str.tonumber(\"1e3\") // Returns: null\n * ```\n */\nexport function tonumber(str: simple_string): float | null {\n // remove the characters U+0000..U+0020 at both ends\n let start = 0;\n let end = str.length;\n while (start < end && str.charCodeAt(start) <= 0x20) start++;\n while (end > start && str.charCodeAt(end - 1) <= 0x20) end--;\n const text = str.slice(start, end);\n if (!/^[+-]?(?:\\d+\\.?\\d*|\\.\\d+)$/.test(text)) return null;\n return parseFloat(text);\n}\n\n/**\n * Extracts a substring from a string.\n *\n * @param str - The source string\n * @param begin - Starting index (0-based, inclusive)\n * @param end - Ending index (0-based, exclusive). If omitted, extracts to end of string\n * @returns The extracted substring\n *\n * @remarks\n * - An na `end` (NaN / null) is a runtime error in PineScript: it throws\n * - If begin > end, indices are swapped (JavaScript behavior)\n * - Negative indices are treated as 0\n * - Indices beyond string length return empty string\n *\n * @example\n * ```typescript\n * str.substring(\"hello world\", 0, 5) // Returns: \"hello\"\n * str.substring(\"hello world\", 6) // Returns: \"world\"\n * str.substring(\"test\", 1, 3) // Returns: \"es\"\n * ```\n */\nexport function substring(str: simple_string, begin: simple_int, end?: simple_int): string {\n if (end === null || Number.isNaN(end)) throw new Error('str.substring: the end position is na');\n return str.substring(begin, end);\n}\n\n/**\n * Converts all characters in a string to uppercase.\n *\n * @param str - The string to convert\n * @returns The uppercase string\n *\n * @example\n * ```typescript\n * str.upper(\"hello\") // Returns: \"HELLO\"\n * str.upper(\"Hello World\") // Returns: \"HELLO WORLD\"\n * str.upper(\"test123\") // Returns: \"TEST123\"\n * ```\n */\nexport function upper(str: simple_string): string {\n return str.toUpperCase();\n}\n\n/**\n * Converts all characters in a string to lowercase.\n *\n * @param str - The string to convert\n * @returns The lowercase string\n *\n * @example\n * ```typescript\n * str.lower(\"HELLO\") // Returns: \"hello\"\n * str.lower(\"Hello World\") // Returns: \"hello world\"\n * str.lower(\"TEST123\") // Returns: \"test123\"\n * ```\n */\nexport function lower(str: simple_string): string {\n return str.toLowerCase();\n}\n\n/**\n * Checks if a string contains a substring.\n *\n * @param source - The string to search in\n * @param str - The substring to search for\n * @returns True if source contains str, false otherwise\n *\n * @remarks\n * - Search is case-sensitive\n * - Empty string is contained in any string\n *\n * @example\n * ```typescript\n * str.contains(\"hello world\", \"world\") // Returns: true\n * str.contains(\"hello world\", \"World\") // Returns: false (case-sensitive)\n * str.contains(\"test\", \"xyz\") // Returns: false\n * ```\n */\nexport function contains(source: simple_string, str: simple_string): bool {\n return source.includes(str);\n}\n\n/**\n * Returns the position of the first occurrence of a substring.\n *\n * @param source - The string to search in\n * @param str - The substring to search for\n * @returns The 0-based index of the first occurrence, or na (NaN) if not found\n *\n * @remarks\n * - Search is case-sensitive\n * - Returns 0 for empty search string\n * - Returns na (NaN) if substring is not found, as in PineScript\n *\n * @example\n * ```typescript\n * str.pos(\"hello world\", \"world\") // Returns: 6\n * str.pos(\"hello world\", \"o\") // Returns: 4 (first occurrence)\n * str.pos(\"hello\", \"xyz\") // Returns: NaN (na)\n * ```\n */\nexport function pos(source: simple_string, str: simple_string): int {\n const index = source.indexOf(str);\n return index === -1 ? NaN : index;\n}\n\n/**\n * Replaces the Nth occurrence of a substring (PineScript `str.replace`).\n *\n * @param source - The source string\n * @param target - The substring to replace\n * @param replacement - The string to replace with\n * @param occurrence - 0-based occurrence to replace (default 0, the first one)\n * @returns The string with one occurrence replaced\n *\n * @remarks\n * PineScript rules:\n * - only the Nth occurrence is replaced; an na occurrence is 0 (`str.replace(\"aaa\", \"a\", \"-\", na)` is \"-aa\")\n * - occurrences overlap: \"aa\" occurs at 0 and 1 in \"aaa\" (`str.replace(\"aaa\", \"aa\", \"-\", 1)` is \"a-\")\n * - an empty target inserts the replacement at character N, at most at the end\n * (`str.replace(\"abc\", \"\", \"-\", 2)` is \"ab-c\")\n * - fewer than N + 1 occurrences (or a negative N) leave the source unchanged\n *\n * @example\n * ```typescript\n * str.replace(\"hello world hello\", \"hello\", \"hi\") // Returns: \"hi world hello\"\n * str.replace(\"hello world hello\", \"hello\", \"hi\", 1) // Returns: \"hello world hi\"\n * str.replace(\"test\", \"xyz\", \"abc\") // Returns: \"test\"\n * ```\n */\nexport function replace(source: simple_string, target: simple_string, replacement: simple_string, occurrence: simple_int = 0): string {\n const n = occurrence === null || Number.isNaN(occurrence) ? 0 : Math.trunc(occurrence);\n if (n < 0) return source;\n let index: number;\n if (target === '') {\n index = Math.min(n, source.length);\n } else {\n index = -1;\n for (let k = 0; k <= n; k++) {\n index = source.indexOf(target, index + 1);\n if (index === -1) return source;\n }\n }\n return source.slice(0, index) + replacement + source.slice(index + target.length);\n}\n\n/**\n * Replaces all occurrences of a target string with a replacement string.\n *\n * @param source - The source string\n * @param target - The substring to find\n * @param replacement - The replacement string\n * @returns String with all occurrences replaced\n *\n * @remarks\n * - Replaces all occurrences of the target string\n * - Case sensitive\n * - If target is empty string, returns original string\n * - This matches PineScript's `str.replace_all()` behavior\n *\n * @example\n * ```typescript\n * str.replace_all(\"hello world hello\", \"hello\", \"hi\") // Returns: \"hi world hi\"\n * str.replace_all(\"a-b-c\", \"-\", \"_\") // Returns: \"a_b_c\"\n * str.replace_all(\"test\", \"x\", \"y\") // Returns: \"test\" (no match)\n * ```\n */\nexport function replace_all(source: simple_string, target: simple_string, replacement: simple_string): string {\n return source.replaceAll(target, replacement);\n}\n\n/**\n * Splits a string into an array of substrings using a separator.\n *\n * @param str - The string to split\n * @param separator - The separator string\n * @returns Array of substrings\n *\n * @remarks\n * - Empty separator splits into individual characters; an empty string gives [\"\"] (also with \"\")\n * - If separator is not found, returns array with original string\n * - Consecutive separators create empty strings in result\n *\n * @example\n * ```typescript\n * str.split(\"a,b,c\", \",\") // Returns: [\"a\", \"b\", \"c\"]\n * str.split(\"hello\", \"\") // Returns: [\"h\", \"e\", \"l\", \"l\", \"o\"]\n * str.split(\"a,,b\", \",\") // Returns: [\"a\", \"\", \"b\"]\n * ```\n */\nexport function split(str: simple_string, separator: simple_string): string[] {\n // JavaScript gives [] for \"\".split(\"\"); PineScript gives [\"\"]\n return str === '' ? [''] : str.split(separator);\n}\n\n/**\n * Concatenates multiple strings into one.\n *\n * @param strings - Variable number of strings to concatenate\n * @returns The concatenated string\n *\n * @example\n * ```typescript\n * str.concat(\"hello\", \" \", \"world\") // Returns: \"hello world\"\n * str.concat(\"a\", \"b\", \"c\") // Returns: \"abc\"\n * str.concat(\"test\") // Returns: \"test\"\n * ```\n */\nexport function concat(...strings: simple_string[]): string {\n return strings.join('');\n}\n\n/**\n * Formats a string with placeholders (PineScript `str.format`, Java MessageFormat syntax).\n *\n * @param formatStr - Pattern with `{0}`, `{1,number,#.##}`, `{0,number,percent}`, `{0,date,yyyy-MM-dd}`...\n * @param args - Values for the placeholders\n * @returns Formatted string\n *\n * @remarks\n * As in PineScript: numbers in `{n}` use\n * \"#,##0.###\" (1234.5678 gives \"1,234.568\"); number patterns round half to even on the exact\n * value (16 decimals at most from 1e-3 up); an array gives \"[a, b]\"; `'...'` is literal text and `''` a quote;\n * a missing argument leaves `{n}` in the text.\n * Dates are formatted in UTC here; PineScript uses the exchange time zone.\n *\n * @example\n * ```typescript\n * str.format('Close: {0,number,#.##}', 101.456) // \"Close: 101.46\"\n * str.format('{0} and {1}', 'a', 2) // \"a and 2\"\n * ```\n */\nexport function format(formatStr: simple_string, ...args: any[]): string {\n return formatMessage(formatStr, args, 'Etc/UTC');\n}\n\n/**\n * Checks if a string starts with a specific prefix.\n *\n * @param source - The string to check\n * @param str - The prefix to look for\n * @returns True if source starts with str, false otherwise\n *\n * @remarks\n * - Search is case-sensitive\n * - Empty string prefix always returns true\n *\n * @example\n * ```typescript\n * str.startswith(\"hello world\", \"hello\") // Returns: true\n * str.startswith(\"hello world\", \"Hello\") // Returns: false (case-sensitive)\n * str.startswith(\"test\", \"testing\") // Returns: false\n * ```\n */\nexport function startswith(source: simple_string, str: simple_string): bool {\n return source.startsWith(str);\n}\n\n/**\n * Checks if a string ends with a specific suffix.\n *\n * @param source - The string to check\n * @param str - The suffix to look for\n * @returns True if source ends with str, false otherwise\n *\n * @remarks\n * - Search is case-sensitive\n * - Empty string suffix always returns true\n *\n * @example\n * ```typescript\n * str.endswith(\"hello world\", \"world\") // Returns: true\n * str.endswith(\"hello world\", \"World\") // Returns: false (case-sensitive)\n * str.endswith(\"testing\", \"test\") // Returns: false\n * ```\n */\nexport function endswith(source: simple_string, str: simple_string): bool {\n return source.endsWith(str);\n}\n\n/**\n * Returns the character at a specific position in a string.\n *\n * @param str - The source string\n * @param pos - The 0-based position\n * @returns The character at the position, or empty string if out of bounds\n *\n * @remarks\n * - Returns empty string for negative or out-of-bounds positions\n * - Unicode characters may span multiple code units\n *\n * @example\n * ```typescript\n * str.charAt(\"hello\", 0) // Returns: \"h\"\n * str.charAt(\"hello\", 4) // Returns: \"o\"\n * str.charAt(\"hello\", 10) // Returns: \"\"\n * ```\n */\nexport function charAt(str: simple_string, pos: simple_int): string {\n return str.charAt(pos);\n}\n\n/**\n * Removes whitespace from both ends of a string.\n *\n * @param str - The string to trim\n * @returns The trimmed string\n *\n * @remarks\n * - Removes spaces, tabs, newlines, and other whitespace characters\n * - Preserves internal whitespace\n *\n * @example\n * ```typescript\n * str.trim(\" hello \") // Returns: \"hello\"\n * str.trim(\" hello world \") // Returns: \"hello world\"\n * str.trim(\"\\thello\\n\") // Returns: \"hello\"\n * ```\n */\nexport function trim(str: simple_string): string {\n return str.trim();\n}\n\n/**\n * Removes whitespace from the left (start) of a string.\n *\n * @param str - The string to trim\n * @returns The trimmed string\n *\n * @remarks\n * - Only removes leading whitespace\n * - Preserves trailing and internal whitespace\n *\n * @example\n * ```typescript\n * str.trimLeft(\" hello \") // Returns: \"hello \"\n * str.trimLeft(\" hello\") // Returns: \"hello\"\n * str.trimLeft(\"\\thello\") // Returns: \"hello\"\n * ```\n */\nexport function trimLeft(str: simple_string): string {\n return str.trimStart();\n}\n\n/**\n * Removes whitespace from the right (end) of a string.\n *\n * @param str - The string to trim\n * @returns The trimmed string\n *\n * @remarks\n * - Only removes trailing whitespace\n * - Preserves leading and internal whitespace\n *\n * @example\n * ```typescript\n * str.trimRight(\" hello \") // Returns: \" hello\"\n * str.trimRight(\"hello \") // Returns: \"hello\"\n * str.trimRight(\"hello\\t\") // Returns: \"hello\"\n * ```\n */\nexport function trimRight(str: simple_string): string {\n return str.trimEnd();\n}\n\n/**\n * Returns the first substring of `source` that matches the `regex` (PineScript `str.match`).\n *\n * @param source - Source string\n * @param regex - Regular expression\n * @returns The first match (searched anywhere in the string), or na (null) when nothing matches or the match is empty\n *\n * @remarks\n * - As PineScript: \"Hello World!\" with \"o\" gives \"o\", with \"[a-z]+\" gives \"ello\"; no match gives na\n * - Uses JavaScript regex syntax\n *\n * @example\n * ```typescript\n * str.match(\"abc123def\", \"[0-9]+\") // Returns: \"123\"\n * str.match(\"abc\", \"[0-9]+\") // Returns: null (na)\n * ```\n */\nexport function match(source: simple_string, regex: simple_string): simple_string | null {\n const found = new RegExp(regex).exec(source);\n return found && found[0] !== '' ? found[0] : null;\n}\n\n/**\n * Formats a timestamp as a string according to the specified format.\n *\n * @param time - Unix timestamp in milliseconds\n * @param format - Format string using PineScript format specifiers\n * @returns Formatted date/time string\n *\n * @remarks\n * Supported format specifiers (case-sensitive):\n * - `yyyy` - 4-digit year (e.g., \"2024\")\n * - `yy` - 2-digit year (e.g., \"24\")\n * - `MMMM` - Full month name (e.g., \"January\")\n * - `MMM` - Abbreviated month name (e.g., \"Jan\")\n * - `MM` - 2-digit month (01-12)\n * - `M` - Month (1-12)\n * - `dd` - 2-digit day (01-31)\n * - `d` - Day (1-31)\n * - `HH` - 2-digit hour (00-23)\n * - `H` - Hour (0-23)\n * - `hh` - 2-digit hour (01-12)\n * - `h` - Hour (1-12)\n * - `mm` - 2-digit minute (00-59)\n * - `m` - Minute (0-59)\n * - `ss` - 2-digit second (00-59)\n * - `s` - Second (0-59)\n * - `a` - AM/PM\n *\n * @example\n * ```typescript\n * const timestamp = 1609459200000; // Jan 1, 2021 00:00:00 UTC\n * str.format_time(timestamp, \"dd MMM yyyy\") // Returns: \"01 Jan 2021\"\n * str.format_time(timestamp, \"yyyy-MM-dd HH:mm:ss\") // Returns: \"2021-01-01 00:00:00\"\n * str.format_time(timestamp, \"MMM d, yyyy\") // Returns: \"Jan 1, 2021\"\n * str.format_time(timestamp, \"hh:mm a\") // Returns: \"12:00 AM\"\n * ```\n */\n/**\n * Constructs a new string containing the source string repeated N times with an optional separator.\n *\n * @param source - The string to repeat\n * @param count - Number of times to repeat\n * @param separator - String to inject between repeated instances. Optional, defaults to empty string.\n * @returns The repeated string, or null (na) if source is na or count is 0 / negative / na, as in PineScript\n *\n * @example\n * ```typescript\n * str.repeat(\"ab\", 3) // Returns: \"ababab\"\n * str.repeat(\"?\", 3, \",\") // Returns: \"?,?,?\"\n * str.repeat(\"hello\", 0) // Returns: null (na)\n * str.repeat(\"x\", 1) // Returns: \"x\"\n * ```\n */\nexport function repeat(source: simple_string, count: simple_int, separator: simple_string = ''): string | null {\n if (source == null) return null;\n if (!(count > 0)) return null; // 0, negative or na: na\n return Array(count).fill(source).join(separator);\n}\n\n/**\n * Formats a UNIX time (ms) with a date pattern (PineScript `str.format_time`).\n *\n * @param time - UNIX time in milliseconds\n * @param format - Java SimpleDateFormat pattern, e.g. \"yyyy-MM-dd HH:mm:ss\", \"dd MMM yyyy\", \"hh:mm a\"\n * @param timezone - UTC/GMT offset (\"UTC-5\") or IANA name (\"America/New_York\"). PineScript's default is\n * the exchange time zone, which is not known here: the default is UTC\n * @returns Formatted date string\n *\n * @remarks\n * Letters: y, M, d, E, u, D, w,\n * H, k, K, h, a, m, s, S, Z, z; 'text' is literal text.\n */\nexport function format_time(time: simple_int, format: simple_string = \"yyyy-MM-dd'T'HH:mm:ssZ\", timezone: simple_string = 'Etc/UTC'): string {\n return formatDate(time, format, timezone);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,0BAAwC;AACxC,2BAA8B;AAC9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KAA4B;AACpD,SAAO,IAAI,QAAQ;AACrB;AAmBO,SAAS,MAAM,QAAuB,OAA4C;AACvF,QAAM,QAAQ,IAAI,OAAO,KAAK,EAAE,KAAK,MAAM;AAC3C,SAAO,SAAS,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI;AAC/C;AAsDO,SAAS,OAAO,QAAuB,OAAmB,YAA2B,IAAmB;AAC7G,MAAI,UAAU,KAAM,QAAO;AAC3B,MAAI,EAAE,QAAQ,GAAI,QAAO;AACzB,SAAO,MAAM,KAAK,EAAE,KAAK,MAAM,EAAE,KAAK,SAAS;AACjD;AAeO,SAAS,YAAY,MAAkBD,UAAwB,0BAA0B,WAA0B,WAAmB;AAC3I,aAAO,8BAAW,MAAMA,SAAQ,QAAQ;AAC1C;",
|
|
6
6
|
"names": ["format", "pos"]
|
|
7
7
|
}
|
|
@@ -20,4 +20,10 @@
|
|
|
20
20
|
export type Rounding = 'halfUpShortest' | 'halfEvenExact';
|
|
21
21
|
/** Formats a number with a DecimalFormat pattern. */
|
|
22
22
|
export declare function formatNumber(value: number, pattern: string, mode: Rounding): string;
|
|
23
|
+
/**
|
|
24
|
+
* `[minmove, pricescale]` of a tick (PineScript `syminfo.mintick = syminfo.minmove / syminfo.pricescale`).
|
|
25
|
+
* Without `pricescale` it is 10^(decimals of the tick): 0.02 is 2 / 100, 0.25 is 25 / 100. A symbol priced in
|
|
26
|
+
* fractions needs its own (1/32 is 1 / 32).
|
|
27
|
+
*/
|
|
28
|
+
export declare function tickScale(mintick: number, pricescale?: number): [number, number];
|
|
23
29
|
//# sourceMappingURL=numberformat.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numberformat.d.ts","sourceRoot":"","sources":["../../../src/str/numberformat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,MAAM,QAAQ,GAAG,gBAAgB,GAAG,eAAe,CAAC;AA8K1D,qDAAqD;AACrD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,CA6BnF"}
|
|
1
|
+
{"version":3,"file":"numberformat.d.ts","sourceRoot":"","sources":["../../../src/str/numberformat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,MAAM,QAAQ,GAAG,gBAAgB,GAAG,eAAe,CAAC;AA8K1D,qDAAqD;AACrD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,CA6BnF;AASD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAMhF"}
|
|
@@ -18,7 +18,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var numberformat_exports = {};
|
|
20
20
|
__export(numberformat_exports, {
|
|
21
|
-
formatNumber: () => formatNumber
|
|
21
|
+
formatNumber: () => formatNumber,
|
|
22
|
+
tickScale: () => tickScale
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(numberformat_exports);
|
|
24
25
|
const patterns = /* @__PURE__ */ new Map();
|
|
@@ -189,4 +190,11 @@ function affixes(p, negative, body) {
|
|
|
189
190
|
if (p.negPrefix === null) return "-" + p.prefix + body + p.suffix;
|
|
190
191
|
return p.negPrefix + body + p.negSuffix;
|
|
191
192
|
}
|
|
193
|
+
function tickScale(mintick, pricescale) {
|
|
194
|
+
if (pricescale === void 0) {
|
|
195
|
+
const m = /^\d+(?:\.(\d+))?(?:e-(\d+))?$/.exec(String(mintick));
|
|
196
|
+
pricescale = Number(`1e${m ? (m[1]?.length ?? 0) + Number(m[2] ?? 0) : 0}`);
|
|
197
|
+
}
|
|
198
|
+
return [Math.round(mintick * pricescale), pricescale];
|
|
199
|
+
}
|
|
192
200
|
//# sourceMappingURL=numberformat.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/str/numberformat.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Number patterns (\"#.##\", \"#,##0.00\", \"0.00E0\", \"#.##%\", \"'#'#.##\") as PineScript formats them.\n *\n * The pattern syntax is Java's DecimalFormat: `0` required digit, `#` optional digit, `,` grouping,\n * `.` decimal point, `E0` exponent, `%` multiplies by 100, `'...'` quoted literal text.\n * PineScript rules:\n * - `str.tostring` rounds half away from zero on the shortest decimal form of the number\n * (`1.005` with \"#.##\" gives \"1.01\", `2.5` with \"#\" gives \"3\")\n * - `str.format` rounds half to even on the exact binary value (`0.25` with \"#.#\" gives \"0.2\")\n * - a negative number that rounds to zero loses its sign; \"#.00\" writes `.50` (no leading zero),\n * but \"#.##\" writes `0.5` (a pattern without any '0' shows one integer digit)\n * - with an exponent, the value is first rounded to the fraction digits (\"0.00E0\": 0.125 gives \"1.30E-1\")\n * - a pattern without digit characters (`format.price` is \"price\") formats like \"#\" after its text,\n * and keeps the sign: -0.004 gives \"-price0\"\n * - \"pos;neg\": a negative number uses the text around the digits of the negative subpattern instead of \"-\"\n * (\"#.##;(#.##)\" gives \"(3.5)\" for -3.5); the digits follow the positive subpattern, as in Java\n * - at most 16 decimals when |x| >= 1e-3 (the shortest digits of a double never have more there):\n * 0.1 with 20 '#' decimals gives \"0.1\" in both rounding modes\n */\n\nexport type Rounding = 'halfUpShortest' | 'halfEvenExact';\n\ninterface Pattern {\n prefix: string;\n suffix: string;\n /** Text around the digits of the negative subpattern (\"pos;neg\"), or null without one */\n negPrefix: string | null;\n negSuffix: string | null;\n minInt: number;\n minFrac: number;\n maxFrac: number;\n /** Digits per group, 0 without grouping */\n grouping: number;\n percent: boolean;\n /** Minimum exponent digits, or null without exponent */\n exponent: number | null;\n hasDigits: boolean;\n}\n\nconst patterns = new Map<string, Pattern>();\n\n/** Index of the first ';' outside quotes, or -1. */\nfunction subpatternSplit(pattern: string): number {\n let quoted = false;\n for (let i = 0; i < pattern.length; i++) {\n if (pattern[i] === \"'\") quoted = !quoted;\n else if (pattern[i] === ';' && !quoted) return i;\n }\n return -1;\n}\n\nfunction parsePattern(pattern: string): Pattern {\n const cached = patterns.get(pattern);\n if (cached) return cached;\n const semi = subpatternSplit(pattern);\n if (semi !== -1) {\n // only the text around the digits of the negative subpattern is used\n const neg = parsePattern(pattern.slice(semi + 1));\n const parsed = { ...parsePattern(pattern.slice(0, semi)), negPrefix: neg.prefix, negSuffix: neg.suffix };\n patterns.set(pattern, parsed);\n return parsed;\n }\n\n let prefix = '';\n let suffix = '';\n let number = '';\n let percent = false;\n let phase: 'prefix' | 'number' | 'suffix' = 'prefix';\n for (let i = 0; i < pattern.length; i++) {\n const ch = pattern[i]!;\n let literal: string;\n if (ch === \"'\") {\n const end = pattern.indexOf(\"'\", i + 1);\n if (end === i + 1) {\n literal = \"'\";\n i = end;\n } else {\n literal = pattern.slice(i + 1, end === -1 ? undefined : end);\n i = end === -1 ? pattern.length : end;\n }\n } else if (phase !== 'suffix' && ('#0,.'.includes(ch) || (phase === 'number' && ch === 'E'))) {\n phase = 'number';\n number += ch;\n continue;\n } else {\n if (ch === '%') percent = true;\n literal = ch;\n }\n if (phase === 'number') phase = 'suffix';\n if (phase === 'prefix') prefix += literal;\n else suffix += literal;\n }\n\n const [mantissa = '', exp] = number.split('E');\n const [intPart = '', fracPart = ''] = mantissa.split('.');\n const lastComma = intPart.lastIndexOf(',');\n const parsed: Pattern = {\n prefix,\n suffix,\n negPrefix: null,\n negSuffix: null,\n // as in Java, a pattern with a decimal point and no '0' at all (\"#.##\") shows one integer digit\n minInt: !mantissa.includes('0') && mantissa.includes('.') ? 1 : [...intPart].filter((c) => c === '0').length,\n minFrac: [...fracPart].filter((c) => c === '0').length,\n maxFrac: [...fracPart].filter((c) => c === '0' || c === '#').length,\n grouping: lastComma === -1 ? 0 : intPart.length - lastComma - 1,\n percent,\n exponent: exp === undefined ? null : exp.length,\n hasDigits: /[0#]/.test(mantissa),\n };\n patterns.set(pattern, parsed);\n return parsed;\n}\n\n/** Decimal digits of |x|: value = 0.d1d2d3... \u00D7 10^intLen (no leading zero digit; \"\" for 0). */\ninterface Digits {\n digits: string;\n intLen: number;\n}\n\nfunction shortestDigits(x: number): Digits {\n const m = /^(\\d+)(?:\\.(\\d+))?(?:e([+-]\\d+))?$/.exec(String(Math.abs(x)))!;\n const all = m[1]! + (m[2] ?? '');\n let intLen = m[1]!.length + Number(m[3] ?? 0);\n const lead = all.length - all.replace(/^0+/, '').length;\n intLen -= lead;\n const digits = all.slice(lead).replace(/0+$/, '');\n return { digits, intLen: digits ? intLen : 0 };\n}\n\n/** Exact decimal expansion of the double |x|. */\nfunction exactDigits(x: number): Digits {\n const abs = Math.abs(x);\n if (abs === 0) return { digits: '', intLen: 0 };\n const view = new DataView(new ArrayBuffer(8));\n view.setFloat64(0, abs);\n const bits = view.getBigUint64(0);\n const expBits = Number((bits >> 52n) & 0x7ffn);\n let mant = bits & 0xfffffffffffffn;\n const e2 = expBits === 0 ? -1074 : expBits - 1075;\n if (expBits !== 0) mant |= 1n << 52n;\n let str: string;\n let fracDigits: number;\n if (e2 >= 0) {\n str = (mant << BigInt(e2)).toString();\n fracDigits = 0;\n } else {\n str = (mant * 5n ** BigInt(-e2)).toString();\n fracDigits = -e2;\n }\n const intLen = str.length - fracDigits;\n const lead = str.length - str.replace(/^0+/, '').length;\n const digits = str.slice(lead).replace(/0+$/, '');\n return { digits, intLen: intLen - lead };\n}\n\n/** Rounds to `frac` digits after the point. */\nfunction roundDigits(d: Digits, frac: number, mode: Rounding): Digits {\n const keep = d.intLen + frac;\n if (keep >= d.digits.length) return d;\n if (keep < 0) return { digits: '', intLen: 0 };\n const first = d.digits.charCodeAt(keep) - 48;\n let up: boolean;\n if (mode === 'halfUpShortest') up = first >= 5;\n else if (first !== 5) up = first > 5;\n else if (d.digits.length > keep + 1) up = true;\n else up = keep > 0 && (d.digits.charCodeAt(keep - 1) - 48) % 2 === 1;\n let kept = d.digits.slice(0, keep);\n let intLen = d.intLen;\n if (up) {\n const n = (BigInt(kept || '0') + 1n).toString();\n if (n.length > kept.length) intLen += 1;\n kept = n;\n }\n kept = kept.replace(/0+$/, '');\n return { digits: kept, intLen: kept ? intLen : 0 };\n}\n\nfunction group(int: string, size: number): string {\n if (!size || int.length <= size) return int;\n const parts: string[] = [];\n for (let end = int.length; end > 0; end -= size) parts.unshift(int.slice(Math.max(0, end - size), end));\n return parts.join(',');\n}\n\nfunction layout(d: Digits, p: Pattern): string {\n let int = d.intLen > 0 ? d.digits.slice(0, d.intLen).padEnd(d.intLen, '0') : '';\n int = int.replace(/^0+/, '').padStart(p.minInt, '0');\n let frac = d.intLen < 0 ? '0'.repeat(-d.intLen) + d.digits : d.digits.slice(Math.max(0, d.intLen));\n frac = frac.slice(0, p.maxFrac).replace(/0+$/, '').padEnd(p.minFrac, '0');\n if (!int && !frac) int = '0';\n return group(int, p.grouping) + (frac ? '.' + frac : '');\n}\n\n/** Formats a number with a DecimalFormat pattern. */\nexport function formatNumber(value: number, pattern: string, mode: Rounding): string {\n if (Number.isNaN(value)) return 'NaN';\n const p = parsePattern(pattern);\n if (!Number.isFinite(value)) return affixes(p, value < 0, '\u221E');\n const x = p.percent ? value * 100 : value;\n const toDigits = mode === 'halfUpShortest' ? shortestDigits : exactDigits;\n\n let body: string;\n let isZero: boolean;\n if (p.exponent !== null) {\n const rounded = roundDigits(toDigits(x), p.maxFrac, mode);\n const intDigits = Math.max(p.minInt, 1);\n isZero = rounded.digits === '';\n let exponent = isZero ? 0 : rounded.intLen - intDigits;\n let mant = roundDigits({ digits: rounded.digits, intLen: isZero ? 0 : intDigits }, p.maxFrac, mode);\n if (mant.intLen > intDigits) {\n exponent += 1;\n mant = { digits: mant.digits, intLen: intDigits };\n }\n const e = String(Math.abs(exponent)).padStart(p.exponent, '0');\n body = layout(mant, p) + 'E' + (exponent < 0 ? '-' : '') + e;\n } else {\n // 16 decimals at most from 1e-3 up (the shortest digits of a double have no more there)\n const frac = !p.hasDigits ? 0 : Math.abs(x) >= 1e-3 ? Math.min(p.maxFrac, 16) : p.maxFrac;\n const rounded = roundDigits(toDigits(x), frac, mode);\n isZero = rounded.digits === '';\n body = p.hasDigits ? layout(rounded, p) : layout(rounded, { ...p, minInt: 0, maxFrac: 0, minFrac: 0 });\n }\n return affixes(p, x < 0 && (!isZero || !p.hasDigits), body);\n}\n\n/** `body` with the text of the positive pattern, or of the negative one (\"-\" + prefix without \"pos;neg\"). */\nfunction affixes(p: Pattern, negative: boolean, body: string): string {\n if (!negative) return p.prefix + body + p.suffix;\n if (p.negPrefix === null) return '-' + p.prefix + body + p.suffix;\n return p.negPrefix + body + p.negSuffix!;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAuCA,MAAM,WAAW,oBAAI,IAAqB;AAG1C,SAAS,gBAAgB,SAAyB;AAChD,MAAI,SAAS;AACb,WAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;AACvC,QAAI,QAAQ,CAAC,MAAM,IAAK,UAAS,CAAC;AAAA,aACzB,QAAQ,CAAC,MAAM,OAAO,CAAC,OAAQ,QAAO;AAAA,EACjD;AACA,SAAO;AACT;AAEA,SAAS,aAAa,SAA0B;AAC9C,QAAM,SAAS,SAAS,IAAI,OAAO;AACnC,MAAI,OAAQ,QAAO;AACnB,QAAM,OAAO,gBAAgB,OAAO;AACpC,MAAI,SAAS,IAAI;AAEf,UAAM,MAAM,aAAa,QAAQ,MAAM,OAAO,CAAC,CAAC;AAChD,UAAMA,UAAS,EAAE,GAAG,aAAa,QAAQ,MAAM,GAAG,IAAI,CAAC,GAAG,WAAW,IAAI,QAAQ,WAAW,IAAI,OAAO;AACvG,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AAE,SAAS,IAAI;AAClG,QAAI,KAAK,SAAS,WAAW;AAC3B,kBAAY;AACZ,aAAO,EAAE,QAAQ,KAAK,QAAQ,QAAQ,UAAU;AAAA,IAClD;AACA,UAAM,IAAI,OAAO,KAAK,IAAI,QAAQ,CAAC,EAAE,SAAS,EAAE,UAAU,GAAG;AAC7D,WAAO,OAAO,MAAM,CAAC,IAAI,OAAO,WAAW,IAAI,MAAM,MAAM;AAAA,EAC7D,OAAO;AAEL,UAAM,OAAO,CAAC,EAAE,YAAY,IAAI,KAAK,IAAI,CAAC,KAAK,OAAO,KAAK,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE;AAClF,UAAM,UAAU,YAAY,SAAS,CAAC,GAAG,MAAM,IAAI;AACnD,aAAS,QAAQ,WAAW;AAC5B,WAAO,EAAE,YAAY,OAAO,SAAS,CAAC,IAAI,OAAO,SAAS,EAAE,GAAG,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,EAAE,CAAC;AAAA,EACvG;AACA,SAAO,QAAQ,GAAG,IAAI,MAAM,CAAC,UAAU,CAAC,EAAE,YAAY,IAAI;AAC5D;AAGA,SAAS,QAAQ,GAAY,UAAmB,MAAsB;AACpE,MAAI,CAAC,SAAU,QAAO,EAAE,SAAS,OAAO,EAAE;AAC1C,MAAI,EAAE,cAAc,KAAM,QAAO,MAAM,EAAE,SAAS,OAAO,EAAE;AAC3D,SAAO,EAAE,YAAY,OAAO,EAAE;AAChC;",
|
|
4
|
+
"sourcesContent": ["/**\n * Number patterns (\"#.##\", \"#,##0.00\", \"0.00E0\", \"#.##%\", \"'#'#.##\") as PineScript formats them.\n *\n * The pattern syntax is Java's DecimalFormat: `0` required digit, `#` optional digit, `,` grouping,\n * `.` decimal point, `E0` exponent, `%` multiplies by 100, `'...'` quoted literal text.\n * PineScript rules:\n * - `str.tostring` rounds half away from zero on the shortest decimal form of the number\n * (`1.005` with \"#.##\" gives \"1.01\", `2.5` with \"#\" gives \"3\")\n * - `str.format` rounds half to even on the exact binary value (`0.25` with \"#.#\" gives \"0.2\")\n * - a negative number that rounds to zero loses its sign; \"#.00\" writes `.50` (no leading zero),\n * but \"#.##\" writes `0.5` (a pattern without any '0' shows one integer digit)\n * - with an exponent, the value is first rounded to the fraction digits (\"0.00E0\": 0.125 gives \"1.30E-1\")\n * - a pattern without digit characters (`format.price` is \"price\") formats like \"#\" after its text,\n * and keeps the sign: -0.004 gives \"-price0\"\n * - \"pos;neg\": a negative number uses the text around the digits of the negative subpattern instead of \"-\"\n * (\"#.##;(#.##)\" gives \"(3.5)\" for -3.5); the digits follow the positive subpattern, as in Java\n * - at most 16 decimals when |x| >= 1e-3 (the shortest digits of a double never have more there):\n * 0.1 with 20 '#' decimals gives \"0.1\" in both rounding modes\n */\n\nexport type Rounding = 'halfUpShortest' | 'halfEvenExact';\n\ninterface Pattern {\n prefix: string;\n suffix: string;\n /** Text around the digits of the negative subpattern (\"pos;neg\"), or null without one */\n negPrefix: string | null;\n negSuffix: string | null;\n minInt: number;\n minFrac: number;\n maxFrac: number;\n /** Digits per group, 0 without grouping */\n grouping: number;\n percent: boolean;\n /** Minimum exponent digits, or null without exponent */\n exponent: number | null;\n hasDigits: boolean;\n}\n\nconst patterns = new Map<string, Pattern>();\n\n/** Index of the first ';' outside quotes, or -1. */\nfunction subpatternSplit(pattern: string): number {\n let quoted = false;\n for (let i = 0; i < pattern.length; i++) {\n if (pattern[i] === \"'\") quoted = !quoted;\n else if (pattern[i] === ';' && !quoted) return i;\n }\n return -1;\n}\n\nfunction parsePattern(pattern: string): Pattern {\n const cached = patterns.get(pattern);\n if (cached) return cached;\n const semi = subpatternSplit(pattern);\n if (semi !== -1) {\n // only the text around the digits of the negative subpattern is used\n const neg = parsePattern(pattern.slice(semi + 1));\n const parsed = { ...parsePattern(pattern.slice(0, semi)), negPrefix: neg.prefix, negSuffix: neg.suffix };\n patterns.set(pattern, parsed);\n return parsed;\n }\n\n let prefix = '';\n let suffix = '';\n let number = '';\n let percent = false;\n let phase: 'prefix' | 'number' | 'suffix' = 'prefix';\n for (let i = 0; i < pattern.length; i++) {\n const ch = pattern[i]!;\n let literal: string;\n if (ch === \"'\") {\n const end = pattern.indexOf(\"'\", i + 1);\n if (end === i + 1) {\n literal = \"'\";\n i = end;\n } else {\n literal = pattern.slice(i + 1, end === -1 ? undefined : end);\n i = end === -1 ? pattern.length : end;\n }\n } else if (phase !== 'suffix' && ('#0,.'.includes(ch) || (phase === 'number' && ch === 'E'))) {\n phase = 'number';\n number += ch;\n continue;\n } else {\n if (ch === '%') percent = true;\n literal = ch;\n }\n if (phase === 'number') phase = 'suffix';\n if (phase === 'prefix') prefix += literal;\n else suffix += literal;\n }\n\n const [mantissa = '', exp] = number.split('E');\n const [intPart = '', fracPart = ''] = mantissa.split('.');\n const lastComma = intPart.lastIndexOf(',');\n const parsed: Pattern = {\n prefix,\n suffix,\n negPrefix: null,\n negSuffix: null,\n // as in Java, a pattern with a decimal point and no '0' at all (\"#.##\") shows one integer digit\n minInt: !mantissa.includes('0') && mantissa.includes('.') ? 1 : [...intPart].filter((c) => c === '0').length,\n minFrac: [...fracPart].filter((c) => c === '0').length,\n maxFrac: [...fracPart].filter((c) => c === '0' || c === '#').length,\n grouping: lastComma === -1 ? 0 : intPart.length - lastComma - 1,\n percent,\n exponent: exp === undefined ? null : exp.length,\n hasDigits: /[0#]/.test(mantissa),\n };\n patterns.set(pattern, parsed);\n return parsed;\n}\n\n/** Decimal digits of |x|: value = 0.d1d2d3... \u00D7 10^intLen (no leading zero digit; \"\" for 0). */\ninterface Digits {\n digits: string;\n intLen: number;\n}\n\nfunction shortestDigits(x: number): Digits {\n const m = /^(\\d+)(?:\\.(\\d+))?(?:e([+-]\\d+))?$/.exec(String(Math.abs(x)))!;\n const all = m[1]! + (m[2] ?? '');\n let intLen = m[1]!.length + Number(m[3] ?? 0);\n const lead = all.length - all.replace(/^0+/, '').length;\n intLen -= lead;\n const digits = all.slice(lead).replace(/0+$/, '');\n return { digits, intLen: digits ? intLen : 0 };\n}\n\n/** Exact decimal expansion of the double |x|. */\nfunction exactDigits(x: number): Digits {\n const abs = Math.abs(x);\n if (abs === 0) return { digits: '', intLen: 0 };\n const view = new DataView(new ArrayBuffer(8));\n view.setFloat64(0, abs);\n const bits = view.getBigUint64(0);\n const expBits = Number((bits >> 52n) & 0x7ffn);\n let mant = bits & 0xfffffffffffffn;\n const e2 = expBits === 0 ? -1074 : expBits - 1075;\n if (expBits !== 0) mant |= 1n << 52n;\n let str: string;\n let fracDigits: number;\n if (e2 >= 0) {\n str = (mant << BigInt(e2)).toString();\n fracDigits = 0;\n } else {\n str = (mant * 5n ** BigInt(-e2)).toString();\n fracDigits = -e2;\n }\n const intLen = str.length - fracDigits;\n const lead = str.length - str.replace(/^0+/, '').length;\n const digits = str.slice(lead).replace(/0+$/, '');\n return { digits, intLen: intLen - lead };\n}\n\n/** Rounds to `frac` digits after the point. */\nfunction roundDigits(d: Digits, frac: number, mode: Rounding): Digits {\n const keep = d.intLen + frac;\n if (keep >= d.digits.length) return d;\n if (keep < 0) return { digits: '', intLen: 0 };\n const first = d.digits.charCodeAt(keep) - 48;\n let up: boolean;\n if (mode === 'halfUpShortest') up = first >= 5;\n else if (first !== 5) up = first > 5;\n else if (d.digits.length > keep + 1) up = true;\n else up = keep > 0 && (d.digits.charCodeAt(keep - 1) - 48) % 2 === 1;\n let kept = d.digits.slice(0, keep);\n let intLen = d.intLen;\n if (up) {\n const n = (BigInt(kept || '0') + 1n).toString();\n if (n.length > kept.length) intLen += 1;\n kept = n;\n }\n kept = kept.replace(/0+$/, '');\n return { digits: kept, intLen: kept ? intLen : 0 };\n}\n\nfunction group(int: string, size: number): string {\n if (!size || int.length <= size) return int;\n const parts: string[] = [];\n for (let end = int.length; end > 0; end -= size) parts.unshift(int.slice(Math.max(0, end - size), end));\n return parts.join(',');\n}\n\nfunction layout(d: Digits, p: Pattern): string {\n let int = d.intLen > 0 ? d.digits.slice(0, d.intLen).padEnd(d.intLen, '0') : '';\n int = int.replace(/^0+/, '').padStart(p.minInt, '0');\n let frac = d.intLen < 0 ? '0'.repeat(-d.intLen) + d.digits : d.digits.slice(Math.max(0, d.intLen));\n frac = frac.slice(0, p.maxFrac).replace(/0+$/, '').padEnd(p.minFrac, '0');\n if (!int && !frac) int = '0';\n return group(int, p.grouping) + (frac ? '.' + frac : '');\n}\n\n/** Formats a number with a DecimalFormat pattern. */\nexport function formatNumber(value: number, pattern: string, mode: Rounding): string {\n if (Number.isNaN(value)) return 'NaN';\n const p = parsePattern(pattern);\n if (!Number.isFinite(value)) return affixes(p, value < 0, '\u221E');\n const x = p.percent ? value * 100 : value;\n const toDigits = mode === 'halfUpShortest' ? shortestDigits : exactDigits;\n\n let body: string;\n let isZero: boolean;\n if (p.exponent !== null) {\n const rounded = roundDigits(toDigits(x), p.maxFrac, mode);\n const intDigits = Math.max(p.minInt, 1);\n isZero = rounded.digits === '';\n let exponent = isZero ? 0 : rounded.intLen - intDigits;\n let mant = roundDigits({ digits: rounded.digits, intLen: isZero ? 0 : intDigits }, p.maxFrac, mode);\n if (mant.intLen > intDigits) {\n exponent += 1;\n mant = { digits: mant.digits, intLen: intDigits };\n }\n const e = String(Math.abs(exponent)).padStart(p.exponent, '0');\n body = layout(mant, p) + 'E' + (exponent < 0 ? '-' : '') + e;\n } else {\n // 16 decimals at most from 1e-3 up (the shortest digits of a double have no more there)\n const frac = !p.hasDigits ? 0 : Math.abs(x) >= 1e-3 ? Math.min(p.maxFrac, 16) : p.maxFrac;\n const rounded = roundDigits(toDigits(x), frac, mode);\n isZero = rounded.digits === '';\n body = p.hasDigits ? layout(rounded, p) : layout(rounded, { ...p, minInt: 0, maxFrac: 0, minFrac: 0 });\n }\n return affixes(p, x < 0 && (!isZero || !p.hasDigits), body);\n}\n\n/** `body` with the text of the positive pattern, or of the negative one (\"-\" + prefix without \"pos;neg\"). */\nfunction affixes(p: Pattern, negative: boolean, body: string): string {\n if (!negative) return p.prefix + body + p.suffix;\n if (p.negPrefix === null) return '-' + p.prefix + body + p.suffix;\n return p.negPrefix + body + p.negSuffix!;\n}\n\n/**\n * `[minmove, pricescale]` of a tick (PineScript `syminfo.mintick = syminfo.minmove / syminfo.pricescale`).\n * Without `pricescale` it is 10^(decimals of the tick): 0.02 is 2 / 100, 0.25 is 25 / 100. A symbol priced in\n * fractions needs its own (1/32 is 1 / 32).\n */\nexport function tickScale(mintick: number, pricescale?: number): [number, number] {\n if (pricescale === undefined) {\n const m = /^\\d+(?:\\.(\\d+))?(?:e-(\\d+))?$/.exec(String(mintick));\n pricescale = Number(`1e${m ? (m[1]?.length ?? 0) + Number(m[2] ?? 0) : 0}`);\n }\n return [Math.round(mintick * pricescale), pricescale];\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuCA,MAAM,WAAW,oBAAI,IAAqB;AAG1C,SAAS,gBAAgB,SAAyB;AAChD,MAAI,SAAS;AACb,WAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;AACvC,QAAI,QAAQ,CAAC,MAAM,IAAK,UAAS,CAAC;AAAA,aACzB,QAAQ,CAAC,MAAM,OAAO,CAAC,OAAQ,QAAO;AAAA,EACjD;AACA,SAAO;AACT;AAEA,SAAS,aAAa,SAA0B;AAC9C,QAAM,SAAS,SAAS,IAAI,OAAO;AACnC,MAAI,OAAQ,QAAO;AACnB,QAAM,OAAO,gBAAgB,OAAO;AACpC,MAAI,SAAS,IAAI;AAEf,UAAM,MAAM,aAAa,QAAQ,MAAM,OAAO,CAAC,CAAC;AAChD,UAAMA,UAAS,EAAE,GAAG,aAAa,QAAQ,MAAM,GAAG,IAAI,CAAC,GAAG,WAAW,IAAI,QAAQ,WAAW,IAAI,OAAO;AACvG,aAAS,IAAI,SAASA,OAAM;AAC5B,WAAOA;AAAA,EACT;AAEA,MAAI,SAAS;AACb,MAAI,SAAS;AACb,MAAI,SAAS;AACb,MAAI,UAAU;AACd,MAAI,QAAwC;AAC5C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OAAO,KAAK,IAAI,QAAQ,CAAC,EAAE,SAAS,EAAE,UAAU,GAAG;AAC7D,WAAO,OAAO,MAAM,CAAC,IAAI,OAAO,WAAW,IAAI,MAAM,MAAM;AAAA,EAC7D,OAAO;AAEL,UAAM,OAAO,CAAC,EAAE,YAAY,IAAI,KAAK,IAAI,CAAC,KAAK,OAAO,KAAK,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE;AAClF,UAAM,UAAU,YAAY,SAAS,CAAC,GAAG,MAAM,IAAI;AACnD,aAAS,QAAQ,WAAW;AAC5B,WAAO,EAAE,YAAY,OAAO,SAAS,CAAC,IAAI,OAAO,SAAS,EAAE,GAAG,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,EAAE,CAAC;AAAA,EACvG;AACA,SAAO,QAAQ,GAAG,IAAI,MAAM,CAAC,UAAU,CAAC,EAAE,YAAY,IAAI;AAC5D;AAGA,SAAS,QAAQ,GAAY,UAAmB,MAAsB;AACpE,MAAI,CAAC,SAAU,QAAO,EAAE,SAAS,OAAO,EAAE;AAC1C,MAAI,EAAE,cAAc,KAAM,QAAO,MAAM,EAAE,SAAS,OAAO,EAAE;AAC3D,SAAO,EAAE,YAAY,OAAO,EAAE;AAChC;AAOO,SAAS,UAAU,SAAiB,YAAuC;AAChF,MAAI,eAAe,QAAW;AAC5B,UAAM,IAAI,gCAAgC,KAAK,OAAO,OAAO,CAAC;AAC9D,iBAAa,OAAO,KAAK,KAAK,EAAE,CAAC,GAAG,UAAU,KAAK,OAAO,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;AAAA,EAC5E;AACA,SAAO,CAAC,KAAK,MAAM,UAAU,UAAU,GAAG,UAAU;AACtD;",
|
|
6
6
|
"names": ["parsed"]
|
|
7
7
|
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -51,13 +51,14 @@ export { input, type InputValue, type IntInputOptions, type FloatInputOptions, t
|
|
|
51
51
|
export { plot as plotHelper, createPlot, type Time, type TimeValuePair, type PlotOptions as PlotHelperOptions, type PlotResult, } from './plot.js';
|
|
52
52
|
export { setContext, clearContext, getContext, registerCalculate, recalculate, plot, hline, clearPlots, } from './runtime/runtime.js';
|
|
53
53
|
export { input_int, input_float, input_bool, input_string, input_source, input_timeframe, input_session, input_time, } from './runtime/inputs.js';
|
|
54
|
-
export
|
|
54
|
+
export { isInputActive } from './runtime/input-active.js';
|
|
55
|
+
export type { OakScriptContext, ChartAdapter, InputAdapter, SeriesHandle, SeriesOptions, InputConfig, InputCondition, InputOptions, OhlcvData, PlotConfig, HLineConfig, FillConfig, ArrowConfig, CandleConfig, } from './runtime/types.js';
|
|
55
56
|
export { STRATEGY_CONSTANTS, STRATEGY_DEFAULTS, STRATEGY_NUMBER_VARIABLES, STRATEGY_TEXT_VARIABLES, } from './strategy/index.js';
|
|
56
57
|
export type * from './strategy/index.js';
|
|
57
58
|
export { LightweightChartsAdapter } from './runtime/adapters/LightweightChartsAdapter.js';
|
|
58
59
|
export type { LightweightSeriesDefinitions } from './runtime/adapters/LightweightChartsAdapter.js';
|
|
59
60
|
export { SimpleInputAdapter } from './runtime/adapters/SimpleInputAdapter.js';
|
|
60
|
-
export declare const VERSION = "0.10.
|
|
61
|
+
export declare const VERSION = "0.10.1";
|
|
61
62
|
/**
|
|
62
63
|
* Library information
|
|
63
64
|
*/
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AAGpC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,GAAG,MAAM,gB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iBAAiB,EACjB,WAAW,EACX,IAAI,EACJ,KAAK,EACL,UAAU,GACX,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,SAAS,EACT,WAAW,EACX,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,aAAa,EACb,UAAU,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,YAAY,EACV,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,WAAW,EACX,cAAc,EACd,YAAY,EACZ,SAAS,EACT,UAAU,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,YAAY,GACb,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAC7B,mBAAmB,qBAAqB,CAAC;AAEzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gDAAgD,CAAC;AAC1F,YAAY,EAAE,4BAA4B,EAAE,MAAM,gDAAgD,CAAC;AACnG,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAG9E,eAAO,MAAM,OAAO,WAAW,CAAC;AAEhC;;GAEG;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;CAiBhB,CAAC;AAKF;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAE5F"}
|
package/dist/esm/index.js
CHANGED
|
@@ -60,12 +60,13 @@ export { plot as plotHelper, createPlot, } from './plot.js';
|
|
|
60
60
|
// Runtime exports - global context runtime (setContext, plot, hline) drawing through a ChartAdapter
|
|
61
61
|
export { setContext, clearContext, getContext, registerCalculate, recalculate, plot, hline, clearPlots, } from './runtime/runtime.js';
|
|
62
62
|
export { input_int, input_float, input_bool, input_string, input_source, input_timeframe, input_session, input_time, } from './runtime/inputs.js';
|
|
63
|
+
export { isInputActive } from './runtime/input-active.js';
|
|
63
64
|
// Strategy types and constants (the script API forwards strategy.* calls to a host engine)
|
|
64
65
|
export { STRATEGY_CONSTANTS, STRATEGY_DEFAULTS, STRATEGY_NUMBER_VARIABLES, STRATEGY_TEXT_VARIABLES, } from './strategy/index.js';
|
|
65
66
|
export { LightweightChartsAdapter } from './runtime/adapters/LightweightChartsAdapter.js';
|
|
66
67
|
export { SimpleInputAdapter } from './runtime/adapters/SimpleInputAdapter.js';
|
|
67
68
|
// Version
|
|
68
|
-
export const VERSION = '0.10.
|
|
69
|
+
export const VERSION = '0.10.1';
|
|
69
70
|
/**
|
|
70
71
|
* Library information
|
|
71
72
|
*/
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,mBAAmB;AACnB,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AAEpC,iDAAiD;AACjD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,kB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M,UAAU,cAAc,CAAC,UAAmB,EAAE,MAAe,EAAE,QAAiB;IACpF,8DAA8D;AAChE,CAAC"}
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { setContext, clearContext, getContext, registerCalculate, recalculate, plot, hline, clearPlots, getActivePlots, } from './runtime.js';
|
|
8
8
|
export { input_int, input_float, input_bool, input_string, input_source, input_timeframe, input_session, input_time, enableAutoRecalculate, disableAutoRecalculate, resetInputs, } from './inputs.js';
|
|
9
|
-
export type { OakScriptContext, ChartAdapter, InputAdapter, SeriesHandle, SeriesOptions, InputConfig, InputOptions, OhlcvData, PlotConfig, } from './types.js';
|
|
9
|
+
export type { OakScriptContext, ChartAdapter, InputAdapter, SeriesHandle, SeriesOptions, InputConfig, InputCondition, InputOptions, OhlcvData, PlotConfig, } from './types.js';
|
|
10
|
+
export { isInputActive } from './input-active.js';
|
|
10
11
|
export { LightweightChartsAdapter } from './adapters/LightweightChartsAdapter.js';
|
|
11
12
|
export type { LightweightSeriesDefinitions } from './adapters/LightweightChartsAdapter.js';
|
|
12
13
|
export { SimpleInputAdapter } from './adapters/SimpleInputAdapter.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,UAAU,EACV,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,IAAI,EACJ,KAAK,EACL,UAAU,EACV,cAAc,GACf,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,SAAS,EACT,WAAW,EACX,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,aAAa,EACb,UAAU,EACV,qBAAqB,EACrB,sBAAsB,EACtB,WAAW,GACZ,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,WAAW,EACX,YAAY,EACZ,SAAS,EACP,UAAU,GACb,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,UAAU,EACV,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,IAAI,EACJ,KAAK,EACL,UAAU,EACV,cAAc,GACf,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,SAAS,EACT,WAAW,EACX,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,aAAa,EACb,UAAU,EACV,qBAAqB,EACrB,sBAAsB,EACtB,WAAW,GACZ,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,WAAW,EACX,cAAc,EACd,YAAY,EACZ,SAAS,EACP,UAAU,GACb,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAClF,YAAY,EAAE,4BAA4B,EAAE,MAAM,wCAAwC,CAAC;AAC3F,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
export { setContext, clearContext, getContext, registerCalculate, recalculate, plot, hline, clearPlots, getActivePlots, } from './runtime.js';
|
|
9
9
|
// Input function exports
|
|
10
10
|
export { input_int, input_float, input_bool, input_string, input_source, input_timeframe, input_session, input_time, enableAutoRecalculate, disableAutoRecalculate, resetInputs, } from './inputs.js';
|
|
11
|
+
export { isInputActive } from './input-active.js';
|
|
11
12
|
// Adapter exports
|
|
12
13
|
export { LightweightChartsAdapter } from './adapters/LightweightChartsAdapter.js';
|
|
13
14
|
export { SimpleInputAdapter } from './adapters/SimpleInputAdapter.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,uBAAuB;AACvB,OAAO,EACL,UAAU,EACV,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,IAAI,EACJ,KAAK,EACL,UAAU,EACV,cAAc,GACf,MAAM,cAAc,CAAC;AAEtB,yBAAyB;AACzB,OAAO,EACL,SAAS,EACT,WAAW,EACX,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,aAAa,EACb,UAAU,EACV,qBAAqB,EACrB,sBAAsB,EACtB,WAAW,GACZ,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,uBAAuB;AACvB,OAAO,EACL,UAAU,EACV,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,IAAI,EACJ,KAAK,EACL,UAAU,EACV,cAAc,GACf,MAAM,cAAc,CAAC;AAEtB,yBAAyB;AACzB,OAAO,EACL,SAAS,EACT,WAAW,EACX,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,aAAa,EACb,UAAU,EACV,qBAAqB,EACrB,sBAAsB,EACtB,WAAW,GACZ,MAAM,aAAa,CAAC;AAgBrB,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,kBAAkB;AAClB,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAElF,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview PineScript `active` of an input: whether the settings dialog lets the user edit it
|
|
3
|
+
* @module runtime/input-active
|
|
4
|
+
*/
|
|
5
|
+
import type { InputConfig } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Whether an input is active (PineScript `active`): an inactive input is shown greyed out in the settings and
|
|
8
|
+
* cannot be edited. It still gives its value to the script.
|
|
9
|
+
*
|
|
10
|
+
* @param config - The input
|
|
11
|
+
* @param inputs - Current input values by id
|
|
12
|
+
* @param configs - All the inputs of the indicator: gives the default of an input that has no value in `inputs`
|
|
13
|
+
* @returns true when `config.active` is not set, is true, or is a condition that holds
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const configs: InputConfig[] = [
|
|
18
|
+
* { id: 'showMa1', type: 'bool', defval: true, title: 'MA #1' },
|
|
19
|
+
* { id: 'ma1Length', type: 'int', defval: 20, active: 'showMa1' },
|
|
20
|
+
* { id: 'bbMult', type: 'float', defval: 2, active: { input: 'maType', eq: 'SMA + Bollinger Bands' } },
|
|
21
|
+
* ];
|
|
22
|
+
* isInputActive(configs[1], { showMa1: false }) // false
|
|
23
|
+
* isInputActive(configs[1], {}, configs) // true: the default of showMa1
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function isInputActive(config: InputConfig, inputs?: Record<string, unknown>, configs?: readonly InputConfig[]): boolean;
|
|
27
|
+
//# sourceMappingURL=input-active.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-active.d.ts","sourceRoot":"","sources":["../../../src/runtime/input-active.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,YAAY,CAAC;AAmB9D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EAAE,OAAO,CAAC,EAAE,SAAS,WAAW,EAAE,GAAG,OAAO,CAKlI"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview PineScript `active` of an input: whether the settings dialog lets the user edit it
|
|
3
|
+
* @module runtime/input-active
|
|
4
|
+
*/
|
|
5
|
+
/** Current value of an input: the host value, else the default of its config. */
|
|
6
|
+
function inputValue(id, inputs, configs) {
|
|
7
|
+
const value = inputs[id];
|
|
8
|
+
if (value !== undefined)
|
|
9
|
+
return value;
|
|
10
|
+
return configs?.find((c) => c.id === id)?.defval;
|
|
11
|
+
}
|
|
12
|
+
function holds(condition, inputs, configs) {
|
|
13
|
+
if (typeof condition === 'string')
|
|
14
|
+
return inputValue(condition, inputs, configs) === true;
|
|
15
|
+
if ('not' in condition)
|
|
16
|
+
return !holds(condition.not, inputs, configs);
|
|
17
|
+
if ('any' in condition)
|
|
18
|
+
return condition.any.some((c) => holds(c, inputs, configs));
|
|
19
|
+
if ('all' in condition)
|
|
20
|
+
return condition.all.every((c) => holds(c, inputs, configs));
|
|
21
|
+
const value = inputValue(condition.input, inputs, configs);
|
|
22
|
+
if (!('eq' in condition) && !('ne' in condition))
|
|
23
|
+
return value === true;
|
|
24
|
+
return (!('eq' in condition) || value === condition.eq) && (!('ne' in condition) || value !== condition.ne);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Whether an input is active (PineScript `active`): an inactive input is shown greyed out in the settings and
|
|
28
|
+
* cannot be edited. It still gives its value to the script.
|
|
29
|
+
*
|
|
30
|
+
* @param config - The input
|
|
31
|
+
* @param inputs - Current input values by id
|
|
32
|
+
* @param configs - All the inputs of the indicator: gives the default of an input that has no value in `inputs`
|
|
33
|
+
* @returns true when `config.active` is not set, is true, or is a condition that holds
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const configs: InputConfig[] = [
|
|
38
|
+
* { id: 'showMa1', type: 'bool', defval: true, title: 'MA #1' },
|
|
39
|
+
* { id: 'ma1Length', type: 'int', defval: 20, active: 'showMa1' },
|
|
40
|
+
* { id: 'bbMult', type: 'float', defval: 2, active: { input: 'maType', eq: 'SMA + Bollinger Bands' } },
|
|
41
|
+
* ];
|
|
42
|
+
* isInputActive(configs[1], { showMa1: false }) // false
|
|
43
|
+
* isInputActive(configs[1], {}, configs) // true: the default of showMa1
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export function isInputActive(config, inputs = {}, configs) {
|
|
47
|
+
const { active } = config;
|
|
48
|
+
if (active === undefined)
|
|
49
|
+
return true;
|
|
50
|
+
if (typeof active === 'boolean')
|
|
51
|
+
return active;
|
|
52
|
+
return holds(active, inputs, configs);
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=input-active.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-active.js","sourceRoot":"","sources":["../../../src/runtime/input-active.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,iFAAiF;AACjF,SAAS,UAAU,CAAC,EAAU,EAAE,MAA+B,EAAE,OAAgC;IAC/F,MAAM,KAAK,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;IACzB,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACtC,OAAO,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,CAAC;AACnD,CAAC;AAED,SAAS,KAAK,CAAC,SAAyB,EAAE,MAA+B,EAAE,OAAgC;IACzG,IAAI,OAAO,SAAS,KAAK,QAAQ;QAAE,OAAO,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IAC1F,IAAI,KAAK,IAAI,SAAS;QAAE,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACtE,IAAI,KAAK,IAAI,SAAS;QAAE,OAAO,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACpF,IA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