diff --git a/lib/internal/per_context/primordials.js b/lib/internal/per_context/primordials.js index 496383a76825ce..59c285cd16d165 100644 --- a/lib/internal/per_context/primordials.js +++ b/lib/internal/per_context/primordials.js @@ -307,9 +307,21 @@ const { WeakSet, } = primordials; -// Because these functions are used by `makeSafe`, which is exposed -// on the `primordials` object, it's important to use const references -// to the primordials that they use: + +/** + * Creates a class that can be safely iterated over. + * + * Because these functions are used by `makeSafe`, which is exposed on the + * `primordials` object, it's important to use const references to the + * primordials that they use. + * + * @template {Iterable} T + * @template {*} TReturn + * @template {*} TNext + * @param {(self: T) => IterableIterator} factory + * @param {(...args: [] | [TNext]) => IteratorResult} next + * @returns {Iterator} + */ const createSafeIterator = (factory, next) => { class SafeIterator { constructor(iterable) { @@ -617,6 +629,10 @@ class RegExpLikeForStringSplitting { } ObjectSetPrototypeOf(RegExpLikeForStringSplitting.prototype, null); +/** + * @param {RegExp} pattern + * @returns {RegExp} + */ primordials.hardenRegExp = function hardenRegExp(pattern) { ObjectDefineProperties(pattern, { [SymbolMatch]: { @@ -706,6 +722,11 @@ primordials.hardenRegExp = function hardenRegExp(pattern) { }; +/** + * @param {string} str + * @param {RegExp} regexp + * @returns {number} + */ primordials.SafeStringPrototypeSearch = (str, regexp) => { regexp.lastIndex = 0; const match = RegExpPrototypeExec(regexp, str); diff --git a/typings/primordials.d.ts b/typings/primordials.d.ts index 4dcbac3abc9425..e1aa6419031115 100644 --- a/typings/primordials.d.ts +++ b/typings/primordials.d.ts @@ -597,4 +597,7 @@ declare namespace primordials { export const PromisePrototypeThen: UncurryThis export const PromisePrototypeCatch: UncurryThis export const PromisePrototypeFinally: UncurryThis + export import Proxy = globalThis.Proxy + import _globalThis = globalThis + export { _globalThis as globalThis } }