mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
fix(ext/node): use primordials in ext/node/polyfills/internal/options.ts
(#29119)
Towards #24236. This PR replaces `Map` and `String` methods with their primordial versions.
This commit is contained in:
parent
9b633bfa85
commit
8786d39d4b
1 changed files with 12 additions and 6 deletions
|
@ -20,10 +20,13 @@
|
|||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||
// deno-lint-ignore-file prefer-primordials
|
||||
|
||||
import { getOptions } from "ext:deno_node/internal_binding/node_options.ts";
|
||||
import { primordials } from "ext:core/mod.js";
|
||||
const {
|
||||
MapPrototypeGet,
|
||||
StringPrototypeSlice,
|
||||
StringPrototypeStartsWith,
|
||||
} = primordials;
|
||||
|
||||
let optionsMap: Map<string, { value: string }>;
|
||||
|
||||
|
@ -38,11 +41,14 @@ function getOptionsFromBinding() {
|
|||
export function getOptionValue(optionName: string) {
|
||||
const options = getOptionsFromBinding();
|
||||
|
||||
if (optionName.startsWith("--no-")) {
|
||||
const option = options.get("--" + optionName.slice(5));
|
||||
if (StringPrototypeStartsWith(optionName, "--no-")) {
|
||||
const option = MapPrototypeGet(
|
||||
options,
|
||||
"--" + StringPrototypeSlice(optionName, 5),
|
||||
);
|
||||
|
||||
return option && !option.value;
|
||||
}
|
||||
|
||||
return options.get(optionName)?.value;
|
||||
return MapPrototypeGet(options, optionName)?.value;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue