Giter Club home page Giter Club logo

ob-deno's Introduction

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" }

ob-deno's People

Contributors

taiju avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.