benjamn / deno

A secure JavaScript and TypeScript runtime

Home Page:https://deno.land

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Deno

Discord Chat

the deno mascot dinosaur standing in the rain

Deno is a simple, modern and secure runtime for JavaScript and TypeScript that uses V8 and is built in Rust.

Purpose of this fork (benjamn/deno)

This repository is a friendly fork of Deno, enabling me to publish various experimental/custom builds of Deno for my own use and for demonstration purposes. In particular, I've done my best to wrap the standalone /usr/local/bin/deno binary (built on Linux) inside some relatively small Docker images that are tolerable to docker pull (162MB, down from 25GB originally).

Docker is not the only way to use this fork of Deno. You can, of course, build the project from source locally, and the deno-setup.sh and deno-build.sh scripts are good references for how to do that (at least on a UNIX system).

You can find the Docker-based commands for building these four tagged images in the docker-build-all.sh script:

  • benjamn/deno:unmodified-builder (heavyweight compilation, plain)
    • benjamn/deno:unmodified (derived from builder)
  • benjamn/deno:async-context-builder (heavyweight compilation, custom fork)
    • benjamn/deno:async-context (derived from builder)

If you have Docker installed and running, you can fire up the Deno REPL using these images by running either of the following commands:

docker run -it --rm benjamn/deno:unmodified repl
docker run -it --rm benjamn/deno:async-context repl

With both commands, the -it is necessary for an interactive persistent shell, and --rm helps clean up the images after each one exits. The logged in user is named deno, and does not have root or sudo access, but does have a /home/deno home directory. The default working directory is /deno, which can be overridden using the -v $(pwd):/deno flag, as in

docker run -it --rm -v $(pwd):/deno benjamn/deno:async-context test --allow-read some.tests.ts

where some.tests.ts is a file in whatever local directory docker run was executed in… on the host computer! This directory-mounting ability is remarkably powerful here, since it allows an Ubuntu-built deno binary to read/process/write files checked out on, say, Mac OS X, without me having to publish a bunch of binary builds for different platforms.

With the :async-context image, you'll find a prototype implementation of the AsyncContext proposal available globally, in case you want to play with that. I hope this system proves flexible enough to prototype other ECMAScript and TypeScript extensions as well as AsyncContext.

Features

  • Secure by default. No file, network, or environment access, unless explicitly enabled.
  • Supports TypeScript out of the box.
  • Ships only a single executable file.
  • Built-in utilities.
  • Set of reviewed standard modules that are guaranteed to work with Deno.

Install

Shell (Mac, Linux):

curl -fsSL https://deno.land/install.sh | sh

PowerShell (Windows):

irm https://deno.land/install.ps1 | iex

Homebrew (Mac):

brew install deno

Chocolatey (Windows):

choco install deno

Scoop (Windows):

scoop install deno

Build and install from source using Cargo:

cargo install deno --locked

See deno_install and releases for other options.

Getting Started

Try running a simple program:

deno run https://deno.land/std/examples/welcome.ts

Or a more complex one:

const listener = Deno.listen({ port: 8000 });
console.log("http://localhost:8000/");

for await (const conn of listener) {
  serve(conn);
}

async function serve(conn: Deno.Conn) {
  for await (const { respondWith } of Deno.serveHttp(conn)) {
    respondWith(new Response("Hello world"));
  }
}

You can find a deeper introduction, examples, and environment setup guides in the manual.

The complete API reference is available at the runtime documentation.

Contributing

We appreciate your help!

To contribute, please read our contributing instructions.

About

A secure JavaScript and TypeScript runtime

https://deno.land

License:MIT License


Languages

Language:Rust 62.0%Language:JavaScript 26.1%Language:TypeScript 11.7%Language:Shell 0.0%Language:Ruby 0.0%Language:Lua 0.0%Language:C 0.0%Language:Dockerfile 0.0%