Skip to content

Commit 78b79c0

Browse files
aduh95danielleadams
authored andcommitted
typings: improve primordials typings
PR-URL: #46970 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent 43b94b0 commit 78b79c0

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

‎lib/internal/per_context/primordials.js‎

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,21 @@ const {
307307
WeakSet,
308308
}=primordials;
309309

310-
// Because these functions are used by `makeSafe`, which is exposed
311-
// on the `primordials` object, it's important to use const references
312-
// to the primordials that they use:
310+
311+
/**
312+
* Creates a class that can be safely iterated over.
313+
*
314+
* Because these functions are used by `makeSafe`, which is exposed on the
315+
* `primordials` object, it's important to use const references to the
316+
* primordials that they use.
317+
*
318+
* @template {Iterable} T
319+
* @template {*} TReturn
320+
* @template {*} TNext
321+
* @param {(self: T) => IterableIterator<T>} factory
322+
* @param {(...args: [] | [TNext]) => IteratorResult<T, TReturn>} next
323+
* @returns {Iterator<T, TReturn, TNext>}
324+
*/
313325
constcreateSafeIterator=(factory,next)=>{
314326
classSafeIterator{
315327
constructor(iterable){
@@ -617,6 +629,10 @@ class RegExpLikeForStringSplitting {
617629
}
618630
ObjectSetPrototypeOf(RegExpLikeForStringSplitting.prototype,null);
619631

632+
/**
633+
* @param {RegExp} pattern
634+
* @returns {RegExp}
635+
*/
620636
primordials.hardenRegExp=functionhardenRegExp(pattern){
621637
ObjectDefineProperties(pattern,{
622638
[SymbolMatch]: {
@@ -706,6 +722,11 @@ primordials.hardenRegExp = function hardenRegExp(pattern) {
706722
};
707723

708724

725+
/**
726+
* @param {string} str
727+
* @param {RegExp} regexp
728+
* @returns {number}
729+
*/
709730
primordials.SafeStringPrototypeSearch=(str,regexp)=>{
710731
regexp.lastIndex=0;
711732
constmatch=RegExpPrototypeExec(regexp,str);

‎typings/primordials.d.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,4 +597,7 @@ declare namespace primordials {
597597
exportconstPromisePrototypeThen: UncurryThis<typeofPromise.prototype.then>
598598
exportconstPromisePrototypeCatch: UncurryThis<typeofPromise.prototype.catch>
599599
exportconstPromisePrototypeFinally: UncurryThis<typeofPromise.prototype.finally>
600+
exportimportProxy=globalThis.Proxy
601+
import_globalThis=globalThis
602+
export{_globalThisasglobalThis}
600603
}

0 commit comments

Comments
 (0)