Skip to main content
Module

x/deno/tools/release/deps.ts>dax.build$

A modern runtime for JavaScript and TypeScript.
Latest
function dax.build$
import { dax } from "https://deno.land/x/deno@v1.41.0/tools/release/deps.ts";
const { build$ } = dax;

Builds a new $ which will use the state of the provided builders as the default.

This can be useful if you want different default settings.

Example:

import { build$ } from "https://deno.land/x/dax/mod.ts";

const commandBuilder = new CommandBuilder()
  .cwd("./subDir")
  .env("HTTPS_PROXY", "some_value");
const requestBuilder = new RequestBuilder()
  .header("SOME_VALUE", "value");

const $ = build$({
  commandBuilder,
  requestBuilder,
  // optional additional functions to add to `$`
  extras: {
    add(a: number, b: number) {
      return a + b;
    },
  },
});

// this command will use the env described above, but the main
// process and default `$` won't have its environment changed
await $`deno run my_script.ts`;

// similarly, this will have the headers that were set in the request builder
const data = await $.request("https://plugins.dprint.dev/info.json").json();

// use the extra function we defined
console.log($.add(1, 2));

Type Parameters

optional
TExtras extends ExtrasObject = { }

Parameters

optional
options: Create$Options<TExtras> = [UNSUPPORTED]