Skip to content
/ ob-deno Public

Babel Functions for Javascript/TypeScript with Deno.

License

Notifications You must be signed in to change notification settings

taiju/ob-deno

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 

Repository files navigation

ob-deno

https://melpa.org/packages/ob-deno-badge.svg

Babel Functions for Javascript/TypeScript with Deno.

ob-deno is based on ob-js. (However, there is no session support.)

Requirements

Installation

ob-deno can be installed from MELPA.

M-x package-install RET ob-deno

Setup

(require 'ob-deno)

(add-to-list 'org-babel-load-languages '(deno . t))
(org-babel-do-load-languages 'org-babel-load-languages org-babel-load-languages)

;; optional (required the typescript.el)
(add-to-list 'org-src-lang-modes '("deno" . typescript))

Customization

M-x customize-group RET ob-deno RET

  • Ob Deno Cmd
  • Ob Deno Variable Prefix

Usage

The results parameter is default value.

#+begin_src deno
const arr = [1, 2, 3];
return arr;
#+end_src

#+RESULTS:
| 1 | 2 | 3 |

The results parameter is output.

#+begin_src deno :results output
const arr = [1, 2, 3];
console.log(arr);
#+end_src

#+RESULTS:
: [ 1, 2, 3 ]

Specify variables.

#+begin_src deno :var foo="bar" baz='("qux")
return {foo, baz};
#+end_src

#+RESULTS:
: { foo: "bar", baz: [ "qux" ] }

Run with --allow-net. (equivalent to deno run --allow-net)

#+begin_src deno :allow net :results output
  const response = await fetch("https://httpbin.org/get?hello=world");
  const json = await response.json();

  console.log(json.args);
#+end_src

#+RESULTS:
: { hello: "world" }

More complex. (equivalent to deno run --allow-net=httpbin.org,example.com --allow-env)

#+begin_src deno :allow '((net . (httpbin.org example.com)) env) :results output
  const response = await fetch(`https://httpbin.org/get?user=${Deno.env.get("USER")}`);
  const json = await response.json();

  console.log(json.args);
#+end_src

#+RESULTS:
: { user: "taiju" }

About

Babel Functions for Javascript/TypeScript with Deno.

Resources

License

Stars

Watchers

Forks

Packages

No packages published