ssjs-data 0.4.1 → 0.4.2
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/method-coverage-audit.json +8392 -0
- package/dist/sfmc-globals.d.ts +287 -0
- package/dist/site-index.json +62 -0
- package/package.json +1 -1
- package/src/index.js +144 -0
- package/src/urls.js +1 -0
package/dist/sfmc-globals.d.ts
CHANGED
|
@@ -1537,6 +1537,219 @@ interface DataExtensionInstance {
|
|
|
1537
1537
|
Rows: DataExtensionRows;
|
|
1538
1538
|
}
|
|
1539
1539
|
|
|
1540
|
+
// ── Core Library sub-namespace instance interfaces ───────────────────────────
|
|
1541
|
+
interface ListSubscribersTrackingInstance {
|
|
1542
|
+
/**
|
|
1543
|
+
* Returns an array of tracking data for subscribers matching the filter.
|
|
1544
|
+
*
|
|
1545
|
+
* [ssjs.guide reference](https://ssjs.guide/core-library/list-subscribers/)
|
|
1546
|
+
*
|
|
1547
|
+
* @remarks Requires `Platform.Load("Core", "1")` before use.
|
|
1548
|
+
* @param filter - PascalCase WSProxy-style filter object identifying the subscribers.
|
|
1549
|
+
* @returns List of tracking records matching the filter.
|
|
1550
|
+
* @example
|
|
1551
|
+
* Platform.Load("core", "1.1.5");
|
|
1552
|
+
* var myList = List.Init("MyList");
|
|
1553
|
+
* var results = myList.Subscribers.Tracking.Retrieve({ Property: "SubscriberKey", SimpleOperator: "equals", Value: "MyKey" });
|
|
1554
|
+
*/
|
|
1555
|
+
Retrieve(filter: object): object[];
|
|
1556
|
+
}
|
|
1557
|
+
interface ListSubscribersInstance {
|
|
1558
|
+
/**
|
|
1559
|
+
* Adds a subscriber to the previously initialized list.
|
|
1560
|
+
*
|
|
1561
|
+
* [ssjs.guide reference](https://ssjs.guide/core-library/list-subscribers/)
|
|
1562
|
+
*
|
|
1563
|
+
* @remarks Requires `Platform.Load("Core", "1")` before use.
|
|
1564
|
+
* @param properties - Object containing subscriber properties (EmailAddress, SubscriberKey, optionally list status).
|
|
1565
|
+
* @returns Returns "OK" on success or throws on failure.
|
|
1566
|
+
* @example
|
|
1567
|
+
* Platform.Load("core", "1");
|
|
1568
|
+
* var list = List.Init("MY_LIST_KEY");
|
|
1569
|
+
* var result = list.Subscribers.Add({
|
|
1570
|
+
* EmailAddress: "test@example.com",
|
|
1571
|
+
* SubscriberKey: "test@example.com"
|
|
1572
|
+
* });
|
|
1573
|
+
* Write(Stringify(result));
|
|
1574
|
+
*/
|
|
1575
|
+
Add(properties: object): string;
|
|
1576
|
+
/**
|
|
1577
|
+
* Returns the subscribers belonging to the previously initialized list. Pass an optional filter to narrow the results; omit it to return all subscribers on the list.
|
|
1578
|
+
*
|
|
1579
|
+
* [ssjs.guide reference](https://ssjs.guide/core-library/list-subscribers/)
|
|
1580
|
+
*
|
|
1581
|
+
* @remarks Requires `Platform.Load("Core", "1")` before use.
|
|
1582
|
+
* @param filter - Optional WSProxy-style filter object to narrow the results.
|
|
1583
|
+
* @returns List of subscriber objects on the list (filtered when a filter is supplied).
|
|
1584
|
+
* @example
|
|
1585
|
+
* Platform.Load("core", "1");
|
|
1586
|
+
* var list = List.Init("MY_LIST_KEY");
|
|
1587
|
+
* var subscribers = list.Subscribers.Retrieve();
|
|
1588
|
+
*/
|
|
1589
|
+
Retrieve(filter?: object): object[];
|
|
1590
|
+
/**
|
|
1591
|
+
* Removes the specified subscriber from the previously initialized list.
|
|
1592
|
+
*
|
|
1593
|
+
* [ssjs.guide reference](https://ssjs.guide/core-library/list-subscribers/)
|
|
1594
|
+
*
|
|
1595
|
+
* @remarks Requires `Platform.Load("Core", "1")` before use.
|
|
1596
|
+
* @param emailAddress - Email address of the subscriber, or a `{EmailAddress, SubscriberKey}` object identifying the subscriber.
|
|
1597
|
+
* @returns Returns "OK" on success or throws on failure.
|
|
1598
|
+
* @example
|
|
1599
|
+
* Platform.Load("core", "1.1.5");
|
|
1600
|
+
* var myList = List.Init("myList");
|
|
1601
|
+
* var status = myList.Subscribers.Unsubscribe("aruiz@example.com");
|
|
1602
|
+
*/
|
|
1603
|
+
Unsubscribe(emailAddress: string): string;
|
|
1604
|
+
/**
|
|
1605
|
+
* Updates the status of the specified subscriber on the previously initialized list.
|
|
1606
|
+
*
|
|
1607
|
+
* [ssjs.guide reference](https://ssjs.guide/core-library/list-subscribers/)
|
|
1608
|
+
*
|
|
1609
|
+
* @remarks Requires `Platform.Load("Core", "1")` before use.
|
|
1610
|
+
* @param emailAddress - Email address of the subscriber, or a `{EmailAddress, SubscriberKey}` object identifying the subscriber.
|
|
1611
|
+
* @param status - New status of the subscriber on the list.
|
|
1612
|
+
* @returns Returns "OK" on success or throws on failure.
|
|
1613
|
+
* @example
|
|
1614
|
+
* Platform.Load("core", "1.1.5");
|
|
1615
|
+
* var myList = List.Init("myList");
|
|
1616
|
+
* var status = myList.Subscribers.Update("aruiz@example.com", "Active");
|
|
1617
|
+
*/
|
|
1618
|
+
Update(emailAddress: string, status: string): string;
|
|
1619
|
+
/**
|
|
1620
|
+
* Adds the subscriber if not on the list, otherwise updates the supplied attributes. If `attributes.Status` is supplied, the subscriber's list status is updated.
|
|
1621
|
+
*
|
|
1622
|
+
* [ssjs.guide reference](https://ssjs.guide/core-library/list-subscribers/)
|
|
1623
|
+
*
|
|
1624
|
+
* @remarks Requires `Platform.Load("Core", "1")` before use.
|
|
1625
|
+
* @param emailAddress - Email address of the subscriber, or a `{EmailAddress, SubscriberKey}` object identifying the subscriber.
|
|
1626
|
+
* @param attributes - Additional subscriber attributes to set or update.
|
|
1627
|
+
* @returns Returns "OK" on success or throws on failure.
|
|
1628
|
+
* @example
|
|
1629
|
+
* Platform.Load("core", "1.1.5");
|
|
1630
|
+
* var myList = List.Init("myList");
|
|
1631
|
+
* var status = myList.Subscribers.Upsert("aruiz@example.com", { ZipCode: "46202" });
|
|
1632
|
+
*/
|
|
1633
|
+
Upsert(emailAddress: string, attributes: object): string;
|
|
1634
|
+
readonly Tracking: ListSubscribersTrackingInstance;
|
|
1635
|
+
}
|
|
1636
|
+
interface SubscriberAttributesInstance {
|
|
1637
|
+
/**
|
|
1638
|
+
* Returns an array of attributes associated with the previously initialized subscriber.
|
|
1639
|
+
*
|
|
1640
|
+
* [ssjs.guide reference](https://ssjs.guide/core-library/subscriber/)
|
|
1641
|
+
*
|
|
1642
|
+
* @remarks Requires `Platform.Load("Core", "1")` before use.
|
|
1643
|
+
* @returns List of attribute objects for the subscriber.
|
|
1644
|
+
* @example
|
|
1645
|
+
* Platform.Load("core", "1.1.5");
|
|
1646
|
+
* var subObj = Subscriber.Init("SubKey");
|
|
1647
|
+
* var attributes = subObj.Attributes.Retrieve();
|
|
1648
|
+
*/
|
|
1649
|
+
Retrieve(): object[];
|
|
1650
|
+
}
|
|
1651
|
+
interface SubscriberListsInstance {
|
|
1652
|
+
/**
|
|
1653
|
+
* Returns the lists the previously initialized subscriber is a member of.
|
|
1654
|
+
*
|
|
1655
|
+
* [ssjs.guide reference](https://ssjs.guide/core-library/subscriber/)
|
|
1656
|
+
*
|
|
1657
|
+
* @remarks Requires `Platform.Load("Core", "1")` before use.
|
|
1658
|
+
* @returns List of list objects the subscriber belongs to.
|
|
1659
|
+
* @example
|
|
1660
|
+
* Platform.Load("core", "1.1.5");
|
|
1661
|
+
* var subObj = Subscriber.Init("SubKey");
|
|
1662
|
+
* var listArray = subObj.Lists.Retrieve();
|
|
1663
|
+
*/
|
|
1664
|
+
Retrieve(): object[];
|
|
1665
|
+
}
|
|
1666
|
+
interface SendTrackingInstance {
|
|
1667
|
+
/**
|
|
1668
|
+
* Returns click tracking data for the previously initialized send.
|
|
1669
|
+
*
|
|
1670
|
+
* [ssjs.guide reference](https://ssjs.guide/core-library/send/)
|
|
1671
|
+
*
|
|
1672
|
+
* @remarks Requires `Platform.Load("Core", "1")` before use.
|
|
1673
|
+
* @param filter - WSProxy-style filter restricting results.
|
|
1674
|
+
* @returns List of click tracking records matching the filter.
|
|
1675
|
+
* @example
|
|
1676
|
+
* Platform.Load("core", "1.1.5");
|
|
1677
|
+
* var singleSend = Send.Init(12345);
|
|
1678
|
+
* var results = singleSend.Tracking.ClickRetrieve({ Property: "ID", SimpleOperator: "equals", Value: 12345 });
|
|
1679
|
+
*/
|
|
1680
|
+
ClickRetrieve(filter: object): object[];
|
|
1681
|
+
/**
|
|
1682
|
+
* Returns aggregated tracking data for the previously initialized send. Aggregates by `type` over the date range, grouped by `groupBy`.
|
|
1683
|
+
*
|
|
1684
|
+
* [ssjs.guide reference](https://ssjs.guide/core-library/send/)
|
|
1685
|
+
*
|
|
1686
|
+
* @remarks Requires `Platform.Load("Core", "1")` before use.
|
|
1687
|
+
* @param type - Type of data to aggregate.
|
|
1688
|
+
* @param startDate - Start date of the data period (MM-DD-YYYY).
|
|
1689
|
+
* @param endDate - End date of the data period (MM-DD-YYYY).
|
|
1690
|
+
* @param groupBy - Interval used to aggregate data.
|
|
1691
|
+
* @returns List of aggregated tracking records.
|
|
1692
|
+
* @example
|
|
1693
|
+
* Platform.Load("core", "1.1.5");
|
|
1694
|
+
* var singleSend = Send.Init(12345);
|
|
1695
|
+
* var results = singleSend.Tracking.TotalByIntervalRetrieve("Click", "07-01-2010", "07-31-2010", "day");
|
|
1696
|
+
*/
|
|
1697
|
+
TotalByIntervalRetrieve(type: string, startDate: string, endDate: string, groupBy: string): object[];
|
|
1698
|
+
}
|
|
1699
|
+
interface TriggeredSendTrackingClicksInstance {
|
|
1700
|
+
/**
|
|
1701
|
+
* Returns click tracking information for the previously initialized triggered send definition.
|
|
1702
|
+
*
|
|
1703
|
+
* [ssjs.guide reference](https://ssjs.guide/core-library/triggeredsend/)
|
|
1704
|
+
*
|
|
1705
|
+
* @remarks Requires `Platform.Load("Core", "1")` before use.
|
|
1706
|
+
* @param filter - WSProxy-style filter restricting click results.
|
|
1707
|
+
* @returns List of click tracking records matching the filter.
|
|
1708
|
+
* @example
|
|
1709
|
+
* Platform.Load("core", "1.1.5");
|
|
1710
|
+
* var tsd = TriggeredSend.Init("MyTSDKey");
|
|
1711
|
+
* var results = tsd.Tracking.Clicks.Retrieve({ Property: "SendUrlID", SimpleOperator: "equals", Value: 12345 });
|
|
1712
|
+
*/
|
|
1713
|
+
Retrieve(filter: object): object[];
|
|
1714
|
+
}
|
|
1715
|
+
interface TriggeredSendTrackingTotalByIntervalInstance {
|
|
1716
|
+
/**
|
|
1717
|
+
* Returns aggregated tracking data for the previously initialized triggered send. Aggregates by `type` over the date range, grouped by `groupBy`.
|
|
1718
|
+
*
|
|
1719
|
+
* [ssjs.guide reference](https://ssjs.guide/core-library/triggeredsend/)
|
|
1720
|
+
*
|
|
1721
|
+
* @remarks Requires `Platform.Load("Core", "1")` before use.
|
|
1722
|
+
* @param type - Type of data to aggregate.
|
|
1723
|
+
* @param startDate - Start date of the data period (MM-DD-YYYY).
|
|
1724
|
+
* @param endDate - End date of the data period (MM-DD-YYYY).
|
|
1725
|
+
* @param groupBy - Interval used to aggregate data.
|
|
1726
|
+
* @returns List of aggregated tracking records.
|
|
1727
|
+
* @example
|
|
1728
|
+
* Platform.Load("core", "1.1.5");
|
|
1729
|
+
* var tsd = TriggeredSend.Init("MyTSDKey");
|
|
1730
|
+
* var results = tsd.Tracking.TotalByInterval.Retrieve("Click", "07-01-2010", "07-31-2010", "day");
|
|
1731
|
+
*/
|
|
1732
|
+
Retrieve(type: string, startDate: string, endDate: string, groupBy: string): object[];
|
|
1733
|
+
}
|
|
1734
|
+
interface TriggeredSendTrackingInstance {
|
|
1735
|
+
/**
|
|
1736
|
+
* Returns tracking data for the previously initialized triggered send definition.
|
|
1737
|
+
*
|
|
1738
|
+
* [ssjs.guide reference](https://ssjs.guide/core-library/triggeredsend/)
|
|
1739
|
+
*
|
|
1740
|
+
* @remarks Requires `Platform.Load("Core", "1")` before use.
|
|
1741
|
+
* @param filter - Optional WSProxy-style filter object.
|
|
1742
|
+
* @returns List of tracking records.
|
|
1743
|
+
* @example
|
|
1744
|
+
* Platform.Load("core", "1.1.5");
|
|
1745
|
+
* var tsd = TriggeredSend.Init("MyTSDKey");
|
|
1746
|
+
* var tsdTracking = tsd.Tracking.Retrieve();
|
|
1747
|
+
*/
|
|
1748
|
+
Retrieve(filter?: object): object[];
|
|
1749
|
+
readonly Clicks: TriggeredSendTrackingClicksInstance;
|
|
1750
|
+
readonly TotalByInterval: TriggeredSendTrackingTotalByIntervalInstance;
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1540
1753
|
// ── Core Library namespaces ──────────────────────────────────────────────────
|
|
1541
1754
|
declare namespace Account {
|
|
1542
1755
|
/**
|
|
@@ -2456,6 +2669,7 @@ interface ListInstance {
|
|
|
2456
2669
|
* var status = myList.Remove();
|
|
2457
2670
|
*/
|
|
2458
2671
|
Remove(): string;
|
|
2672
|
+
readonly Subscribers: ListSubscribersInstance;
|
|
2459
2673
|
}
|
|
2460
2674
|
declare namespace Subscriber {
|
|
2461
2675
|
/**
|
|
@@ -2579,6 +2793,8 @@ interface SubscriberInstance {
|
|
|
2579
2793
|
* var status = subObj.Unsubscribe();
|
|
2580
2794
|
*/
|
|
2581
2795
|
Unsubscribe(): string;
|
|
2796
|
+
readonly Attributes: SubscriberAttributesInstance;
|
|
2797
|
+
readonly Lists: SubscriberListsInstance;
|
|
2582
2798
|
}
|
|
2583
2799
|
declare namespace Email {
|
|
2584
2800
|
/**
|
|
@@ -2774,6 +2990,7 @@ interface SendInstance {
|
|
|
2774
2990
|
* var status = mySend.CancelSend();
|
|
2775
2991
|
*/
|
|
2776
2992
|
CancelSend(): string;
|
|
2993
|
+
readonly Tracking: SendTrackingInstance;
|
|
2777
2994
|
}
|
|
2778
2995
|
declare namespace Send.Tracking {
|
|
2779
2996
|
/**
|
|
@@ -2990,6 +3207,7 @@ interface TriggeredSendInstance {
|
|
|
2990
3207
|
* if (status != "OK") { var message = ts.LastMessage; }
|
|
2991
3208
|
*/
|
|
2992
3209
|
Send(emailAddress: string, sendTimeAttributes?: object): string;
|
|
3210
|
+
readonly Tracking: TriggeredSendTrackingInstance;
|
|
2993
3211
|
}
|
|
2994
3212
|
declare namespace DataExtension {
|
|
2995
3213
|
/**
|
|
@@ -3901,8 +4119,77 @@ declare namespace Math {
|
|
|
3901
4119
|
const SQRT1_2: number;
|
|
3902
4120
|
}
|
|
3903
4121
|
|
|
4122
|
+
interface RegExp {
|
|
4123
|
+
/**
|
|
4124
|
+
* Tests whether the string matches the pattern. Returns true if the pattern is found, false otherwise. When the g flag is set, successive calls advance lastIndex.
|
|
4125
|
+
*
|
|
4126
|
+
* @param string - The string to test against the regular expression
|
|
4127
|
+
* @example
|
|
4128
|
+
* var emailRe = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
4129
|
+
* if (emailRe.test(subscriberEmail)) {
|
|
4130
|
+
* Write("Valid email");
|
|
4131
|
+
* }
|
|
4132
|
+
*/
|
|
4133
|
+
test(string: string): boolean;
|
|
4134
|
+
/**
|
|
4135
|
+
* Executes a search for a match in the string. Returns an array with the full match at index 0 and any capture groups at subsequent indices, or null if no match is found. The array also has index and input properties. When the g flag is set, successive calls advance lastIndex.
|
|
4136
|
+
*
|
|
4137
|
+
* @param string - The string to search
|
|
4138
|
+
* @example
|
|
4139
|
+
* var re = /(\d{4})-(\d{2})-(\d{2})/;
|
|
4140
|
+
* var result = re.exec("Order placed on 2026-01-15");
|
|
4141
|
+
* if (result) {
|
|
4142
|
+
* Write("Year: " + result[1]); // "2026"
|
|
4143
|
+
* Write("Month: " + result[2]); // "01"
|
|
4144
|
+
* }
|
|
4145
|
+
*/
|
|
4146
|
+
exec(string: string): any[];
|
|
4147
|
+
/**
|
|
4148
|
+
* The text of the pattern, excluding the enclosing slashes and any flags.
|
|
4149
|
+
*
|
|
4150
|
+
* @example
|
|
4151
|
+
* var re = /hello/gi;
|
|
4152
|
+
* Write(re.source); // "hello"
|
|
4153
|
+
*/
|
|
4154
|
+
readonly source: string;
|
|
4155
|
+
/**
|
|
4156
|
+
* True if the g (global) flag was specified when creating the regular expression.
|
|
4157
|
+
*
|
|
4158
|
+
* @example
|
|
4159
|
+
* var re = /hello/g;
|
|
4160
|
+
* Write(re.global); // true
|
|
4161
|
+
*/
|
|
4162
|
+
readonly global: boolean;
|
|
4163
|
+
/**
|
|
4164
|
+
* True if the i (case-insensitive) flag was specified.
|
|
4165
|
+
*
|
|
4166
|
+
* @example
|
|
4167
|
+
* var re = /hello/i;
|
|
4168
|
+
* Write(re.ignoreCase); // true
|
|
4169
|
+
*/
|
|
4170
|
+
readonly ignoreCase: boolean;
|
|
4171
|
+
/**
|
|
4172
|
+
* True if the m (multiline) flag was specified.
|
|
4173
|
+
*
|
|
4174
|
+
* @example
|
|
4175
|
+
* var re = /^hello/m;
|
|
4176
|
+
* Write(re.multiline); // true
|
|
4177
|
+
*/
|
|
4178
|
+
readonly multiline: boolean;
|
|
4179
|
+
/**
|
|
4180
|
+
* The index at which to start the next match. Only relevant when the g or y flag is set. Automatically updated by exec() and test().
|
|
4181
|
+
*
|
|
4182
|
+
* @example
|
|
4183
|
+
* var re = /\d+/g;
|
|
4184
|
+
* re.exec("abc 123 def 456");
|
|
4185
|
+
* Write(re.lastIndex); // 7 (after first match)
|
|
4186
|
+
*/
|
|
4187
|
+
readonly lastIndex: number;
|
|
4188
|
+
}
|
|
4189
|
+
|
|
3904
4190
|
// Global ECMAScript functions
|
|
3905
4191
|
declare function parseInt(string?: string, radix?: number): number;
|
|
3906
4192
|
declare function parseFloat(string?: string): number;
|
|
3907
4193
|
declare function isNaN(value?: any): boolean;
|
|
3908
4194
|
declare function isFinite(value?: any): boolean;
|
|
4195
|
+
declare function RegExp(pattern: string, flags?: string): RegExp;
|
package/dist/site-index.json
CHANGED
|
@@ -3505,6 +3505,68 @@
|
|
|
3505
3505
|
],
|
|
3506
3506
|
"returnType": "boolean"
|
|
3507
3507
|
},
|
|
3508
|
+
{
|
|
3509
|
+
"name": "RegExp.test",
|
|
3510
|
+
"url": "/language/regular-expressions/",
|
|
3511
|
+
"section": "ECMAScript Builtins",
|
|
3512
|
+
"type": "method",
|
|
3513
|
+
"description": "Tests whether the string matches the pattern.",
|
|
3514
|
+
"params": [
|
|
3515
|
+
"string"
|
|
3516
|
+
],
|
|
3517
|
+
"returnType": "boolean"
|
|
3518
|
+
},
|
|
3519
|
+
{
|
|
3520
|
+
"name": "RegExp.exec",
|
|
3521
|
+
"url": "/language/regular-expressions/",
|
|
3522
|
+
"section": "ECMAScript Builtins",
|
|
3523
|
+
"type": "method",
|
|
3524
|
+
"description": "Executes a search for a match in the string.",
|
|
3525
|
+
"params": [
|
|
3526
|
+
"string"
|
|
3527
|
+
],
|
|
3528
|
+
"returnType": "array"
|
|
3529
|
+
},
|
|
3530
|
+
{
|
|
3531
|
+
"name": "RegExp.source",
|
|
3532
|
+
"url": "/language/regular-expressions/",
|
|
3533
|
+
"section": "ECMAScript Builtins",
|
|
3534
|
+
"type": "property",
|
|
3535
|
+
"description": "The text of the pattern, excluding the enclosing slashes and any flags.",
|
|
3536
|
+
"returnType": "string"
|
|
3537
|
+
},
|
|
3538
|
+
{
|
|
3539
|
+
"name": "RegExp.global",
|
|
3540
|
+
"url": "/language/regular-expressions/",
|
|
3541
|
+
"section": "ECMAScript Builtins",
|
|
3542
|
+
"type": "property",
|
|
3543
|
+
"description": "True if the g (global) flag was specified when creating the regular expression.",
|
|
3544
|
+
"returnType": "boolean"
|
|
3545
|
+
},
|
|
3546
|
+
{
|
|
3547
|
+
"name": "RegExp.ignoreCase",
|
|
3548
|
+
"url": "/language/regular-expressions/",
|
|
3549
|
+
"section": "ECMAScript Builtins",
|
|
3550
|
+
"type": "property",
|
|
3551
|
+
"description": "True if the i (case-insensitive) flag was specified.",
|
|
3552
|
+
"returnType": "boolean"
|
|
3553
|
+
},
|
|
3554
|
+
{
|
|
3555
|
+
"name": "RegExp.multiline",
|
|
3556
|
+
"url": "/language/regular-expressions/",
|
|
3557
|
+
"section": "ECMAScript Builtins",
|
|
3558
|
+
"type": "property",
|
|
3559
|
+
"description": "True if the m (multiline) flag was specified.",
|
|
3560
|
+
"returnType": "boolean"
|
|
3561
|
+
},
|
|
3562
|
+
{
|
|
3563
|
+
"name": "RegExp.lastIndex",
|
|
3564
|
+
"url": "/language/regular-expressions/",
|
|
3565
|
+
"section": "ECMAScript Builtins",
|
|
3566
|
+
"type": "property",
|
|
3567
|
+
"description": "The index at which to start the next match.",
|
|
3568
|
+
"returnType": "number"
|
|
3569
|
+
},
|
|
3508
3570
|
{
|
|
3509
3571
|
"name": "String",
|
|
3510
3572
|
"url": "/global-functions/string/",
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -7263,6 +7263,150 @@ export const ECMASCRIPT_BUILTINS = [
|
|
|
7263
7263
|
'Write(isFinite(1 / 0)); // false (Infinity)\n' +
|
|
7264
7264
|
'Write(isFinite(NaN)); // false',
|
|
7265
7265
|
},
|
|
7266
|
+
// ── RegExp constructor ────────────────────────────────────────────────────
|
|
7267
|
+
// Emitted as `declare function RegExp(...)` so that `new RegExp(...)` and
|
|
7268
|
+
// `RegExp(...)` both pass TypeScript validation in .ssjs files.
|
|
7269
|
+
{
|
|
7270
|
+
name: 'RegExp',
|
|
7271
|
+
owner: 'Global',
|
|
7272
|
+
description:
|
|
7273
|
+
'Creates a regular expression object for pattern matching. ' +
|
|
7274
|
+
'Prefer the literal syntax (/pattern/flags) when the pattern is known at write time. ' +
|
|
7275
|
+
'Use the constructor when the pattern must be built dynamically at runtime.',
|
|
7276
|
+
params: [
|
|
7277
|
+
{
|
|
7278
|
+
name: 'pattern',
|
|
7279
|
+
description: 'Regular expression pattern string',
|
|
7280
|
+
type: 'string',
|
|
7281
|
+
},
|
|
7282
|
+
{
|
|
7283
|
+
name: 'flags',
|
|
7284
|
+
description: 'Optional flags: g (global), i (case-insensitive), m (multiline)',
|
|
7285
|
+
type: 'string',
|
|
7286
|
+
optional: true,
|
|
7287
|
+
},
|
|
7288
|
+
],
|
|
7289
|
+
returnType: 'RegExp',
|
|
7290
|
+
syntax: 'new RegExp(pattern[, flags])',
|
|
7291
|
+
minArgs: 1,
|
|
7292
|
+
maxArgs: 2,
|
|
7293
|
+
example:
|
|
7294
|
+
'var fieldName = "email";\n' +
|
|
7295
|
+
'var re = new RegExp(fieldName + "=([^&]+)", "i");\n' +
|
|
7296
|
+
'var match = queryString.match(re);\n' +
|
|
7297
|
+
'if (match) { Write(match[1]); }',
|
|
7298
|
+
},
|
|
7299
|
+
// ── RegExp.prototype methods ──────────────────────────────────────────────
|
|
7300
|
+
{
|
|
7301
|
+
name: 'test',
|
|
7302
|
+
owner: 'RegExp',
|
|
7303
|
+
description:
|
|
7304
|
+
'Tests whether the string matches the pattern. ' +
|
|
7305
|
+
'Returns true if the pattern is found, false otherwise. ' +
|
|
7306
|
+
'When the g flag is set, successive calls advance lastIndex.',
|
|
7307
|
+
params: [
|
|
7308
|
+
{
|
|
7309
|
+
name: 'string',
|
|
7310
|
+
description: 'The string to test against the regular expression',
|
|
7311
|
+
type: 'string',
|
|
7312
|
+
},
|
|
7313
|
+
],
|
|
7314
|
+
returnType: 'boolean',
|
|
7315
|
+
syntax: 'RegExp.test(string)',
|
|
7316
|
+
minArgs: 1,
|
|
7317
|
+
maxArgs: 1,
|
|
7318
|
+
example:
|
|
7319
|
+
'var emailRe = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n' +
|
|
7320
|
+
'if (emailRe.test(subscriberEmail)) {\n' +
|
|
7321
|
+
' Write("Valid email");\n' +
|
|
7322
|
+
'}',
|
|
7323
|
+
},
|
|
7324
|
+
{
|
|
7325
|
+
name: 'exec',
|
|
7326
|
+
owner: 'RegExp',
|
|
7327
|
+
description:
|
|
7328
|
+
'Executes a search for a match in the string. ' +
|
|
7329
|
+
'Returns an array with the full match at index 0 and any capture groups at subsequent indices, ' +
|
|
7330
|
+
'or null if no match is found. ' +
|
|
7331
|
+
'The array also has index and input properties. ' +
|
|
7332
|
+
'When the g flag is set, successive calls advance lastIndex.',
|
|
7333
|
+
params: [
|
|
7334
|
+
{
|
|
7335
|
+
name: 'string',
|
|
7336
|
+
description: 'The string to search',
|
|
7337
|
+
type: 'string',
|
|
7338
|
+
},
|
|
7339
|
+
],
|
|
7340
|
+
returnType: 'array',
|
|
7341
|
+
syntax: 'RegExp.exec(string)',
|
|
7342
|
+
minArgs: 1,
|
|
7343
|
+
maxArgs: 1,
|
|
7344
|
+
example:
|
|
7345
|
+
'var re = /(\\d{4})-(\\d{2})-(\\d{2})/;\n' +
|
|
7346
|
+
'var result = re.exec("Order placed on 2026-01-15");\n' +
|
|
7347
|
+
'if (result) {\n' +
|
|
7348
|
+
' Write("Year: " + result[1]); // "2026"\n' +
|
|
7349
|
+
' Write("Month: " + result[2]); // "01"\n' +
|
|
7350
|
+
'}',
|
|
7351
|
+
},
|
|
7352
|
+
// ── RegExp.prototype properties ───────────────────────────────────────────
|
|
7353
|
+
{
|
|
7354
|
+
name: 'source',
|
|
7355
|
+
owner: 'RegExp',
|
|
7356
|
+
isProperty: true,
|
|
7357
|
+
description: 'The text of the pattern, excluding the enclosing slashes and any flags.',
|
|
7358
|
+
params: [],
|
|
7359
|
+
returnType: 'string',
|
|
7360
|
+
syntax: 'RegExp.source',
|
|
7361
|
+
example: 'var re = /hello/gi;\nWrite(re.source); // "hello"',
|
|
7362
|
+
},
|
|
7363
|
+
{
|
|
7364
|
+
name: 'global',
|
|
7365
|
+
owner: 'RegExp',
|
|
7366
|
+
isProperty: true,
|
|
7367
|
+
description:
|
|
7368
|
+
'True if the g (global) flag was specified when creating the regular expression.',
|
|
7369
|
+
params: [],
|
|
7370
|
+
returnType: 'boolean',
|
|
7371
|
+
syntax: 'RegExp.global',
|
|
7372
|
+
example: 'var re = /hello/g;\nWrite(re.global); // true',
|
|
7373
|
+
},
|
|
7374
|
+
{
|
|
7375
|
+
name: 'ignoreCase',
|
|
7376
|
+
owner: 'RegExp',
|
|
7377
|
+
isProperty: true,
|
|
7378
|
+
description: 'True if the i (case-insensitive) flag was specified.',
|
|
7379
|
+
params: [],
|
|
7380
|
+
returnType: 'boolean',
|
|
7381
|
+
syntax: 'RegExp.ignoreCase',
|
|
7382
|
+
example: 'var re = /hello/i;\nWrite(re.ignoreCase); // true',
|
|
7383
|
+
},
|
|
7384
|
+
{
|
|
7385
|
+
name: 'multiline',
|
|
7386
|
+
owner: 'RegExp',
|
|
7387
|
+
isProperty: true,
|
|
7388
|
+
description: 'True if the m (multiline) flag was specified.',
|
|
7389
|
+
params: [],
|
|
7390
|
+
returnType: 'boolean',
|
|
7391
|
+
syntax: 'RegExp.multiline',
|
|
7392
|
+
example: 'var re = /^hello/m;\nWrite(re.multiline); // true',
|
|
7393
|
+
},
|
|
7394
|
+
{
|
|
7395
|
+
name: 'lastIndex',
|
|
7396
|
+
owner: 'RegExp',
|
|
7397
|
+
isProperty: true,
|
|
7398
|
+
description:
|
|
7399
|
+
'The index at which to start the next match. ' +
|
|
7400
|
+
'Only relevant when the g or y flag is set. ' +
|
|
7401
|
+
'Automatically updated by exec() and test().',
|
|
7402
|
+
params: [],
|
|
7403
|
+
returnType: 'number',
|
|
7404
|
+
syntax: 'RegExp.lastIndex',
|
|
7405
|
+
example:
|
|
7406
|
+
'var re = /\\d+/g;\n' +
|
|
7407
|
+
're.exec("abc 123 def 456");\n' +
|
|
7408
|
+
'Write(re.lastIndex); // 7 (after first match)',
|
|
7409
|
+
},
|
|
7266
7410
|
];
|
|
7267
7411
|
|
|
7268
7412
|
// ── Unsupported ES6+ syntax ──────────────────────────────────────────────────
|
package/src/urls.js
CHANGED
|
@@ -132,6 +132,7 @@ export const ECMASCRIPT_URLS = {
|
|
|
132
132
|
Math: '/ecmascript-builtins/math/',
|
|
133
133
|
'Number.prototype': '/ecmascript-builtins/number-methods/',
|
|
134
134
|
'Object.prototype': '/ecmascript-builtins/object-methods/',
|
|
135
|
+
RegExp: '/language/regular-expressions/',
|
|
135
136
|
};
|
|
136
137
|
|
|
137
138
|
/**
|