profile
viewpoint

denoland/deno 67489

A secure JavaScript and TypeScript runtime

ry/tensorflow-resnet 1553

ResNet model in TensorFlow

ry/tensorflow-vgg16 649

conversation of caffe vgg16 model to tensorflow

ry/deno 385

ry/deno_typescript 31

To generate snapshots of TypeScript files during build.rs

ry/awesome-deno 16

🎉A curated list of awesome things related to Deno

ry/eecs151 12

http://inst.eecs.berkeley.edu/~eecs151/fa19/

ry/go 10

The Go programming language

Pull request review commentdenoland/deno

fix: clearing timers race condition

 itest!(deno_test_only {   output: "deno_test_only.ts.out", }); +#[test]+fn timeout_clear() {+  // https://github.com/denoland/deno/issues/7599++  use std::time::Duration;+  use std::time::Instant;++  let mut p = util::deno_cmd()+    .current_dir(util::tests_path())+    .arg("run")+    .arg("--reload")+    .arg("set_timeout_clear.ts")+    .spawn()+    .unwrap();

Would be cool the read the source code from stdin, so you didn't have to create a separate file set_timeout_clear.ts

bartlomieju

comment created time in 25 minutes

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentdenoland/deno

fix: clearing timers race condition

 impl GlobalTimer {     let rx = rx       .map_err(|err| panic!("Unexpected error in receiving channel {:?}", err)); -    futures::future::select(delay, rx).then(|_| futures::future::ok(()))+    let fut = futures::future::select(delay, rx)+      .then(|_| futures::future::ok(()))+      .boxed_local();+    self.future = Some(fut);   } }  pub fn init(rt: &mut deno_core::JsRuntime) {   super::reg_json_sync(rt, "op_global_timer_stop", op_global_timer_stop);+  super::reg_json_sync(rt, "op_global_timer_start", op_global_timer_start);   super::reg_json_async(rt, "op_global_timer", op_global_timer);

It's not clear to me what these three ops do. Can you give a description? (maybe put it in a comment?)

bartlomieju

comment created time in 26 minutes

Pull request review commentdenoland/deno

fix: clearing timers race condition

+const handle = setTimeout(() => {+  console.log("timeout finish");+}, 10000);+clearTimeout(handle);+console.log("finish");

Surely this is currently working?

bartlomieju

comment created time in 27 minutes

PullRequestReviewEvent

pull request commentdenoland/deno

[WIP] refactor: new module graph used for no check

Does this mean there will be two module graphs? This patch is a rather large net addition of code, so it needs to be carefully considered before landing.

kitsonk

comment created time in 31 minutes

PullRequestReviewEvent

Pull request review commentdenoland/deno

feat(std/node/util): implement `getSystemErrorName()`

 Deno.test({     assert(util.types.isDate(new Date()));   }, });++Deno.test({+  name: "[util] getSystemErrorName()",+  fn() {+    type FnTestInvalidArg = (code?: unknown) => void;++    assertThrows(+      () => (util.getSystemErrorName as FnTestInvalidArg)(),+      TypeError,+    );+    assertThrows(+      () => (util.getSystemErrorName as FnTestInvalidArg)(1),+      RangeError,+    );++    assertStrictEquals(util.getSystemErrorName(-424242), undefined);++    switch (Deno.build.os) {+      case "windows":+        assertStrictEquals(util.getSystemErrorName(-4091), "EADDRINUSE");+        break;++      case "darwin":+        assertStrictEquals(util.getSystemErrorName(-48), "EADDRINUSE");+        break;++      case "linux":+        assertStrictEquals(util.getSystemErrorName(-98), "EADDRINUSE");+        break;+    }+  },

Nice test

schwarzkopfb

comment created time in 35 minutes

PullRequestReviewEvent

Pull request review commentdenoland/deno

feat(std/node/util): implement `getSystemErrorName()`

 var cache = [   "      ",   "       ",   "        ",-  "         "+  "         ",

unrelated change - please undo

schwarzkopfb

comment created time in 36 minutes

PullRequestReviewEvent

Pull request review commentdenoland/deno

feat(std/node/util): implement `getSystemErrorName()`

+// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.++import { unreachable } from "../../../testing/asserts.ts";++// In Node these values are coming from libuv:+// Ref: https://github.com/libuv/libuv/blob/v1.x/include/uv/errno.h+// Ref: https://github.com/nodejs/node/blob/524123fbf064ff64bb6fcd83485cfc27db932f68/lib/internal/errors.js#L383+// Since there is no easy way to port code from libuv and these maps are+// changing very rarely, we simply extract them from Node and store here.++// Note+// Run the following to get the map:+// $ node -e "console.log(process.binding('uv').getErrorMap())"+// This setup automatically exports maps from both "win", "linux" & darwin:+// https://github.com/schwarzkopfb/node_errno_map++const { os } = Deno.build;+const map = new Map<number, [string, string]>(+  JSON.parse(+    os === "windows"+      ? '[[-4093,["E2BIG","argument list too long"]],[-4092,["EACCES","permission denied"]],[-4091,["EADDRINUSE","address already in use"]],[-4090,["EADDRNOTAVAIL","address not available"]],[-4089,["EAFNOSUPPORT","address family not supported"]],[-4088,["EAGAIN","resource temporarily unavailable"]],[-3000,["EAI_ADDRFAMILY","address family not supported"]],[-3001,["EAI_AGAIN","temporary failure"]],[-3002,["EAI_BADFLAGS","bad ai_flags value"]],[-3013,["EAI_BADHINTS","invalid value for hints"]],[-3003,["EAI_CANCELED","request canceled"]],[-3004,["EAI_FAIL","permanent failure"]],[-3005,["EAI_FAMILY","ai_family not supported"]],[-3006,["EAI_MEMORY","out of memory"]],[-3007,["EAI_NODATA","no address"]],[-3008,["EAI_NONAME","unknown node or service"]],[-3009,["EAI_OVERFLOW","argument buffer overflow"]],[-3014,["EAI_PROTOCOL","resolved protocol is unknown"]],[-3010,["EAI_SERVICE","service not available for socket type"]],[-3011,["EAI_SOCKTYPE","socket type not supported"]],[-4084,["EALREADY","connection already in progress"]],[-4083,["EBADF","bad file descriptor"]],[-4082,["EBUSY","resource busy or locked"]],[-4081,["ECANCELED","operation canceled"]],[-4080,["ECHARSET","invalid Unicode character"]],[-4079,["ECONNABORTED","software caused connection abort"]],[-4078,["ECONNREFUSED","connection refused"]],[-4077,["ECONNRESET","connection reset by peer"]],[-4076,["EDESTADDRREQ","destination address required"]],[-4075,["EEXIST","file already exists"]],[-4074,["EFAULT","bad address in system call argument"]],[-4036,["EFBIG","file too large"]],[-4073,["EHOSTUNREACH","host is unreachable"]],[-4072,["EINTR","interrupted system call"]],[-4071,["EINVAL","invalid argument"]],[-4070,["EIO","i/o error"]],[-4069,["EISCONN","socket is already connected"]],[-4068,["EISDIR","illegal operation on a directory"]],[-4067,["ELOOP","too many symbolic links encountered"]],[-4066,["EMFILE","too many open files"]],[-4065,["EMSGSIZE","message too long"]],[-4064,["ENAMETOOLONG","name too long"]],[-4063,["ENETDOWN","network is down"]],[-4062,["ENETUNREACH","network is unreachable"]],[-4061,["ENFILE","file table overflow"]],[-4060,["ENOBUFS","no buffer space available"]],[-4059,["ENODEV","no such device"]],[-4058,["ENOENT","no such file or directory"]],[-4057,["ENOMEM","not enough memory"]],[-4056,["ENONET","machine is not on the network"]],[-4035,["ENOPROTOOPT","protocol not available"]],[-4055,["ENOSPC","no space left on device"]],[-4054,["ENOSYS","function not implemented"]],[-4053,["ENOTCONN","socket is not connected"]],[-4052,["ENOTDIR","not a directory"]],[-4051,["ENOTEMPTY","directory not empty"]],[-4050,["ENOTSOCK","socket operation on non-socket"]],[-4049,["ENOTSUP","operation not supported on socket"]],[-4048,["EPERM","operation not permitted"]],[-4047,["EPIPE","broken pipe"]],[-4046,["EPROTO","protocol error"]],[-4045,["EPROTONOSUPPORT","protocol not supported"]],[-4044,["EPROTOTYPE","protocol wrong type for socket"]],[-4034,["ERANGE","result too large"]],[-4043,["EROFS","read-only file system"]],[-4042,["ESHUTDOWN","cannot send after transport endpoint shutdown"]],[-4041,["ESPIPE","invalid seek"]],[-4040,["ESRCH","no such process"]],[-4039,["ETIMEDOUT","connection timed out"]],[-4038,["ETXTBSY","text file is busy"]],[-4037,["EXDEV","cross-device link not permitted"]],[-4094,["UNKNOWN","unknown error"]],[-4095,["EOF","end of file"]],[-4033,["ENXIO","no such device or address"]],[-4032,["EMLINK","too many links"]],[-4031,["EHOSTDOWN","host is down"]],[-4030,["EREMOTEIO","remote I/O error"]],[-4029,["ENOTTY","inappropriate ioctl for device"]],[-4028,["EFTYPE","inappropriate file type or format"]],[-4027,["EILSEQ","illegal byte sequence"]]]'+      : os === "darwin"+      ? '[[-7,["E2BIG","argument list too long"]],[-13,["EACCES","permission denied"]],[-48,["EADDRINUSE","address already in use"]],[-49,["EADDRNOTAVAIL","address not available"]],[-47,["EAFNOSUPPORT","address family not supported"]],[-35,["EAGAIN","resource temporarily unavailable"]],[-3000,["EAI_ADDRFAMILY","address family not supported"]],[-3001,["EAI_AGAIN","temporary failure"]],[-3002,["EAI_BADFLAGS","bad ai_flags value"]],[-3013,["EAI_BADHINTS","invalid value for hints"]],[-3003,["EAI_CANCELED","request canceled"]],[-3004,["EAI_FAIL","permanent failure"]],[-3005,["EAI_FAMILY","ai_family not supported"]],[-3006,["EAI_MEMORY","out of memory"]],[-3007,["EAI_NODATA","no address"]],[-3008,["EAI_NONAME","unknown node or service"]],[-3009,["EAI_OVERFLOW","argument buffer overflow"]],[-3014,["EAI_PROTOCOL","resolved protocol is unknown"]],[-3010,["EAI_SERVICE","service not available for socket type"]],[-3011,["EAI_SOCKTYPE","socket type not supported"]],[-37,["EALREADY","connection already in progress"]],[-9,["EBADF","bad file descriptor"]],[-16,["EBUSY","resource busy or locked"]],[-89,["ECANCELED","operation canceled"]],[-4080,["ECHARSET","invalid Unicode character"]],[-53,["ECONNABORTED","software caused connection abort"]],[-61,["ECONNREFUSED","connection refused"]],[-54,["ECONNRESET","connection reset by peer"]],[-39,["EDESTADDRREQ","destination address required"]],[-17,["EEXIST","file already exists"]],[-14,["EFAULT","bad address in system call argument"]],[-27,["EFBIG","file too large"]],[-65,["EHOSTUNREACH","host is unreachable"]],[-4,["EINTR","interrupted system call"]],[-22,["EINVAL","invalid argument"]],[-5,["EIO","i/o error"]],[-56,["EISCONN","socket is already connected"]],[-21,["EISDIR","illegal operation on a directory"]],[-62,["ELOOP","too many symbolic links encountered"]],[-24,["EMFILE","too many open files"]],[-40,["EMSGSIZE","message too long"]],[-63,["ENAMETOOLONG","name too long"]],[-50,["ENETDOWN","network is down"]],[-51,["ENETUNREACH","network is unreachable"]],[-23,["ENFILE","file table overflow"]],[-55,["ENOBUFS","no buffer space available"]],[-19,["ENODEV","no such device"]],[-2,["ENOENT","no such file or directory"]],[-12,["ENOMEM","not enough memory"]],[-4056,["ENONET","machine is not on the network"]],[-42,["ENOPROTOOPT","protocol not available"]],[-28,["ENOSPC","no space left on device"]],[-78,["ENOSYS","function not implemented"]],[-57,["ENOTCONN","socket is not connected"]],[-20,["ENOTDIR","not a directory"]],[-66,["ENOTEMPTY","directory not empty"]],[-38,["ENOTSOCK","socket operation on non-socket"]],[-45,["ENOTSUP","operation not supported on socket"]],[-1,["EPERM","operation not permitted"]],[-32,["EPIPE","broken pipe"]],[-100,["EPROTO","protocol error"]],[-43,["EPROTONOSUPPORT","protocol not supported"]],[-41,["EPROTOTYPE","protocol wrong type for socket"]],[-34,["ERANGE","result too large"]],[-30,["EROFS","read-only file system"]],[-58,["ESHUTDOWN","cannot send after transport endpoint shutdown"]],[-29,["ESPIPE","invalid seek"]],[-3,["ESRCH","no such process"]],[-60,["ETIMEDOUT","connection timed out"]],[-26,["ETXTBSY","text file is busy"]],[-18,["EXDEV","cross-device link not permitted"]],[-4094,["UNKNOWN","unknown error"]],[-4095,["EOF","end of file"]],[-6,["ENXIO","no such device or address"]],[-31,["EMLINK","too many links"]],[-64,["EHOSTDOWN","host is down"]],[-4030,["EREMOTEIO","remote I/O error"]],[-25,["ENOTTY","inappropriate ioctl for device"]],[-79,["EFTYPE","inappropriate file type or format"]],[-92,["EILSEQ","illegal byte sequence"]]]'+      : os === "linux"+      ? '[[-7,["E2BIG","argument list too long"]],[-13,["EACCES","permission denied"]],[-98,["EADDRINUSE","address already in use"]],[-99,["EADDRNOTAVAIL","address not available"]],[-97,["EAFNOSUPPORT","address family not supported"]],[-11,["EAGAIN","resource temporarily unavailable"]],[-3000,["EAI_ADDRFAMILY","address family not supported"]],[-3001,["EAI_AGAIN","temporary failure"]],[-3002,["EAI_BADFLAGS","bad ai_flags value"]],[-3013,["EAI_BADHINTS","invalid value for hints"]],[-3003,["EAI_CANCELED","request canceled"]],[-3004,["EAI_FAIL","permanent failure"]],[-3005,["EAI_FAMILY","ai_family not supported"]],[-3006,["EAI_MEMORY","out of memory"]],[-3007,["EAI_NODATA","no address"]],[-3008,["EAI_NONAME","unknown node or service"]],[-3009,["EAI_OVERFLOW","argument buffer overflow"]],[-3014,["EAI_PROTOCOL","resolved protocol is unknown"]],[-3010,["EAI_SERVICE","service not available for socket type"]],[-3011,["EAI_SOCKTYPE","socket type not supported"]],[-114,["EALREADY","connection already in progress"]],[-9,["EBADF","bad file descriptor"]],[-16,["EBUSY","resource busy or locked"]],[-125,["ECANCELED","operation canceled"]],[-4080,["ECHARSET","invalid Unicode character"]],[-103,["ECONNABORTED","software caused connection abort"]],[-111,["ECONNREFUSED","connection refused"]],[-104,["ECONNRESET","connection reset by peer"]],[-89,["EDESTADDRREQ","destination address required"]],[-17,["EEXIST","file already exists"]],[-14,["EFAULT","bad address in system call argument"]],[-27,["EFBIG","file too large"]],[-113,["EHOSTUNREACH","host is unreachable"]],[-4,["EINTR","interrupted system call"]],[-22,["EINVAL","invalid argument"]],[-5,["EIO","i/o error"]],[-106,["EISCONN","socket is already connected"]],[-21,["EISDIR","illegal operation on a directory"]],[-40,["ELOOP","too many symbolic links encountered"]],[-24,["EMFILE","too many open files"]],[-90,["EMSGSIZE","message too long"]],[-36,["ENAMETOOLONG","name too long"]],[-100,["ENETDOWN","network is down"]],[-101,["ENETUNREACH","network is unreachable"]],[-23,["ENFILE","file table overflow"]],[-105,["ENOBUFS","no buffer space available"]],[-19,["ENODEV","no such device"]],[-2,["ENOENT","no such file or directory"]],[-12,["ENOMEM","not enough memory"]],[-64,["ENONET","machine is not on the network"]],[-92,["ENOPROTOOPT","protocol not available"]],[-28,["ENOSPC","no space left on device"]],[-38,["ENOSYS","function not implemented"]],[-107,["ENOTCONN","socket is not connected"]],[-20,["ENOTDIR","not a directory"]],[-39,["ENOTEMPTY","directory not empty"]],[-88,["ENOTSOCK","socket operation on non-socket"]],[-95,["ENOTSUP","operation not supported on socket"]],[-1,["EPERM","operation not permitted"]],[-32,["EPIPE","broken pipe"]],[-71,["EPROTO","protocol error"]],[-93,["EPROTONOSUPPORT","protocol not supported"]],[-91,["EPROTOTYPE","protocol wrong type for socket"]],[-34,["ERANGE","result too large"]],[-30,["EROFS","read-only file system"]],[-108,["ESHUTDOWN","cannot send after transport endpoint shutdown"]],[-29,["ESPIPE","invalid seek"]],[-3,["ESRCH","no such process"]],[-110,["ETIMEDOUT","connection timed out"]],[-26,["ETXTBSY","text file is busy"]],[-18,["EXDEV","cross-device link not permitted"]],[-4094,["UNKNOWN","unknown error"]],[-4095,["EOF","end of file"]],[-6,["ENXIO","no such device or address"]],[-31,["EMLINK","too many links"]],[-112,["EHOSTDOWN","host is down"]],[-121,["EREMOTEIO","remote I/O error"]],[-25,["ENOTTY","inappropriate ioctl for device"]],[-4028,["EFTYPE","inappropriate file type or format"]],[-84,["EILSEQ","illegal byte sequence"]]]'+      : unreachable(),

This is pretty unreadable and I'm not sure how this is passing lint.

Please reformat this with 80 column maximum line width.

schwarzkopfb

comment created time in 39 minutes

PullRequestReviewEvent

push eventdenoland/deno

Casper Beyer

commit sha 9caeff3208a33098418ac2c64414010a3060a362

fix(cli/repl): interpret object literals as expressions (#7591)

view details

push time in 17 hours

PR merged denoland/deno

fix(cli/repl): interpret object literals as expressions

This wraps object literals in parenthesis so that they're interpreted as expressions rather than block statements which matches the behaviour of Node and web-browsers.

Fixes #1421

+40 -1

7 comments

2 changed files

caspervonb

pr closed time in 17 hours

issue closeddenoland/deno

REPL emits surprising output on `> {a: 1}`

Currently,

> {a:1}
1
>

Expected:

> {a:1}
{ a: 1 }
>

This is due to v8 considering {} as a scope instead of object. In Node, this is solved by secretly adding a pair of parentheses around the object, like

{a:1} => ({a:1})

The code implementing this is available here: https://github.com/nodejs/node/blob/ae73b73eeb99101188c860cce488ccc085b2f268/lib/repl.js#L235-L243

I am expecting a similar patch for this after #1407 and #1420 are landed...

closed time in 17 hours

kevinkassimo
PullRequestReviewEvent
PullRequestReviewEvent

pull request commentdenoland/deno

feat(cli/repl): automatically indent multi-line inputs

Thanks for the patch Casper. This is a nice usability feature - I tried it manually - works well. But it's also extra complexity. I'm not sure if its worth the trade off without a test.

caspervonb

comment created time in 17 hours

issue commentdenoland/deno

(cli/net) op_datagram_send panic for unixpacket transport

@bartlomieju This is a concrete reason why we need this "weak ref" pattern.

pevers

comment created time in 18 hours

push eventcaspervonb/deno

Nayeem Rahman

commit sha aaa5e6613a739f8e2ff7579b69c2504bcdc37d4f

fix(cli/rt): make some web API constructors illegal at runtime (#7468)

view details

Bartek Iwańczuk

commit sha b657d743a22802b8232fbf558f2f00bf2942096f

refactor: remove CliState, use OpState, add CliModuleLoader (#7588) - remove "CliState.workers" and "CliState.next_worker_id", instead store them on "OpState" using type aliases. - remove "CliState.global_timer" and "CliState.start_time", instead store them on "OpState" using type aliases. - remove "CliState.is_internal", instead pass it to Worker::new - move "CliState::permissions" to "OpState" - move "CliState::main_module" to "OpState" - move "CliState::global_state" to "OpState" - move "CliState::check_unstable()" to "GlobalState" - change "cli_state()" to "global_state()" - change "deno_core::ModuleLoader" trait to pass "OpState" to callbacks - rename "CliState" to "CliModuleLoader"

view details

Nayeem Rahman

commit sha 51019dc2674de9b4f5c3beb09c193b98fd582d25

fix(cli/flags): Make --unstable a global flag (#7585)

view details

Yusuke Tanaka

commit sha db5004f2003486aa78751a5dd5bf2989824e724e

fix(fmt,lint): do not print number of checked files when `--quiet` is enabled (#7579)

view details

Nayeem Rahman

commit sha 0a9d7e4e397a688dbd5d9448cdcbb119182ed446

fix(cli/installer): Don't reload by default (#7596)

view details

Bartek Iwańczuk

commit sha d1b88510cf31e1a9e5218f3195d15390e904f38a

refactor: remove GlobalState::compile_lock (#7598)

view details

Rob Waller

commit sha 333462b9c2ca662a9a26c9de6eeddbd545428a18

docs: titles in examples should be sentence case (#7609)

view details

Luca Casonato

commit sha dc6571909ba446fc732b2c6a48742eb4b9614513

fix: make --watch and --inspect conflicting args (#7610)

view details

tokiedokie

commit sha c4ed3fb7e767311dc5a6fc931fceaf4fdee885de

chore: add copyright (#7593)

view details

Casper Beyer

commit sha e06875e9f7e4b3365b9f30322e3e5307903feed4

refactor(cli/coverage): await for inspector message response (#7584)

view details

William Perron

commit sha 42772845f6dde1b27a9e55c7738743388350f2b2

fix(info): add --importmap flag (#7424)

view details

Casper Beyer

commit sha 9d738fc1977e0bd3d36f361198a1101e17c3b3b3

test(std/wasi): add fd_renumber test (#7574)

view details

Bartek Iwańczuk

commit sha 92edc364426ddb4c80292ebe7e702c02f9344c5b

refactor: use futures and serde_json from deno_core (#7614)

view details

Ryan Dahl

commit sha 01a66ac3dae4bbd9291c448532a7bdcb93ece75d

Merge branch 'master' into feat-cli-repl-autodetect-indent-level

view details

push time in 20 hours

pull request commentdenoland/deno

feat(cli/installer): Add missing flags for deno install

Looks good - thanks @nayeemrmn. I think this should wait for 1.5.0?

nayeemrmn

comment created time in 20 hours

PR closed denoland/deno_install

ask to automatically add Deno to the PATH

This modification to the script will ask the user if they want to automatically add Deno to their PATH.

+17 -3

2 comments

1 changed file

SirJosh3917

pr closed time in 21 hours

pull request commentdenoland/deno_install

ask to automatically add Deno to the PATH

Thanks for the patch, but we're trying to keep the script simple https://github.com/denoland/deno_install/blob/4d960274a86fa46265ca5ba9adc01a2405baded1/install.sh#L3 Closing without merge.

SirJosh3917

comment created time in 21 hours

pull request commentdenoland/deno

fix(cli): Use safe shell escaping in `deno install`

Could you add a test case that demonstrates an escaping failure?

solson

comment created time in 21 hours

pull request commentdenoland/deno

Websocket add missing close events and remove extra error event

@crowlKats what about a test that counts the number of events? Wouldn't that be a sufficient test?

crowlKats

comment created time in a day

PullRequestReviewEvent
PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentdenoland/deno

Add example for deno_core #7453

+// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.+/*+ This example shows you how to define ops in Rust+ and then call them from JavaScript.+*/++use std::io::Write;++use deno_core::{JsRuntime, Op, RuntimeOptions};+use serde_json::json;++pub fn main() -> Result<(), deno_core::error::AnyError> {+  // Initialize a runtime instance+  let mut runtime = JsRuntime::new(RuntimeOptions {+    js_error_create_fn: None,+    module_loader: None,+    startup_snapshot: None,+    will_snapshot: false,+    heap_limits: None,+  });++  /*+   The first thing we do is define two ops.+   They will be used to show how to pass data+   to Rust and back to JavaScript.++   The first one is used to print data to stdout,+   because by default the JavaScript console functions+   are just stubs (they don't do anything).++   The second one just transforms some input and returns it to JavaScript.+  */++  // Register the op for outputting bytes to stdout.+  // It can be invoked with Deno.core.dispatch and the id this method returns+  // or Deno.core.dispatchByName and the name provided.+  runtime.register_op(+    "op_print",+    // The op_fn callback takes a state object OpState+    // and a vector of ZeroCopyBuf's, which are mutable references+    // to ArrayBuffer's in JavaScript.+    |_state, zero_copy| {+      let mut out = std::io::stdout();++      // Write the contents of every buffer to stdout+      for buf in zero_copy {+        out.write_all(&buf).unwrap();+      }++      Op::Sync(Box::new([])) // No meaningful result+    },+  );++  // Register the JSON op for summing a number array.+  // A JSON op is just an op where the first ZeroCopyBuf is+  // a serialized JSON value,+  // the return value is also a serialized JSON value.+  // It can be invoked with Deno.core.jsonOpSync and the name.+  runtime.register_op("op_sum", |_state, zero_copy| {+    // This helper function creates a JSON error result+    // which throws an exception on the JavaScript side.+    fn new_type_error(message: &str) -> Op {+      // Create the value+      let type_error_json = json!({+        "err": {+          "className": "TypeError",+          "message": message,+        }+      });+      Op::Sync(+        // And serialize it+        serde_json::to_vec(&type_error_json)+          .unwrap()+          .into_boxed_slice(),+      )+    }++    // First we check that we got the JSON argument+    if zero_copy.len() != 1 {+      return new_type_error("Expected exactly one argument");+    }++    // Then we deserialize it+    let json: serde_json::Value = match serde_json::from_slice(&zero_copy[0]) {+      Ok(v) => v,+      Err(_) => {+        return new_type_error("Invalid JSON");+      }+    };++    // We check its type+    if !json.is_array() {+      new_type_error("Argument is not of type array")+    } else if !json+      .as_array()+      .unwrap()+      .iter()+      .all(|value| value.is_number())+    {+      new_type_error("Argument is not array of numbers")+    } else {+      // And if everything checks out do our actual task+      let sum = json+        .as_array()+        .unwrap()+        .iter()+        .fold(0.0, |a, v| a + v.as_f64().unwrap());++      // Finally we return a JSON result object+      let result = json!({ "ok": sum });+      Op::Sync(serde_json::to_vec(&result).unwrap().into_boxed_slice())+    }+  });++  /*+    Now we see how to invoke the ops we just defined.+    The runtime automatically contains a Deno.core object+    with several functions for interacting with the runtime.+    You can find its definition in core.js.+  */++  runtime.execute(+    "<init>",+    r#"+// First we initialize the ops cache.+// This maps op names to their id's.+Deno.core.ops();++// Then we define a print function that uses+// our op_print op to display the stringified argument.+const _newline = new Uint8Array([10]);+function print(value) {+  Deno.core.dispatchByName('op_print', Deno.core.encode(value.toString()), _newline);+}++// Finally we register the error class used by op_sum+// so that it throws the correct error class.+Deno.core.registerErrorClass('TypeError', TypeError);+"#,+  )?;++  /*+     Now we can finally use this in an example.+  */++  runtime.execute(+    "<usage>",+    r#"+const arr = [1, 2, 3];+print("The sum of");+print(arr);+print("is");+print(Deno.core.jsonOpSync('op_sum', arr));+"#,+  )?;++  Ok(())+}

Nice!

SyrupThinker

comment created time in a day

PullRequestReviewEvent

Pull request review commentdenoland/deno

Add example for deno_core #7453

+// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.+/*+ This example shows you how to define ops in Rust+ and then call them from JavaScript.+*/++use std::io::Write;++use deno_core::{JsRuntime, Op, RuntimeOptions};+use serde_json::json;++pub fn main() -> Result<(), deno_core::error::AnyError> {+  // Initialize a runtime instance+  let mut runtime = JsRuntime::new(RuntimeOptions {+    js_error_create_fn: None,+    module_loader: None,+    startup_snapshot: None,+    will_snapshot: false,+    heap_limits: None,+  });++  /*+   The first thing we do is define two ops.+   They will be used to show how to pass data+   to Rust and back to JavaScript.++   The first one is used to print data to stdout,+   because by default the JavaScript console functions+   are just stubs (they don't do anything).++   The second one just transforms some input and returns it to JavaScript.+  */++  // Register the op for outputting bytes to stdout.+  // It can be invoked with Deno.core.dispatch and the id this method returns+  // or Deno.core.dispatchByName and the name provided.+  runtime.register_op(+    "op_print",+    // The op_fn callback takes a state object OpState+    // and a vector of ZeroCopyBuf's, which are mutable references+    // to ArrayBuffer's in JavaScript.+    |_state, zero_copy| {+      let mut out = std::io::stdout();++      // Write the contents of every buffer to stdout+      for buf in zero_copy {+        out.write_all(&buf).unwrap();+      }++      Op::Sync(Box::new([])) // No meaningful result+    },+  );++  // Register the JSON op for summing a number array.+  // A JSON op is just an op where the first ZeroCopyBuf is+  // a serialized JSON value,+  // the return value is also a serialized JSON value.+  // It can be invoked with Deno.core.jsonOpSync and the name.+  runtime.register_op("op_sum", |_state, zero_copy| {+    // This helper function creates a JSON error result+    // which throws an exception on the JavaScript side.+    fn new_type_error(message: &str) -> Op {+      // Create the value+      let type_error_json = json!({+        "err": {+          "className": "TypeError",+          "message": message,+        }+      });+      Op::Sync(+        // And serialize it+        serde_json::to_vec(&type_error_json)+          .unwrap()+          .into_boxed_slice(),+      )+    }++    // First we check that we got the JSON argument+    if zero_copy.len() != 1 {+      return new_type_error("Expected exactly one argument");+    }++    // Then we deserialize it+    let json: serde_json::Value = match serde_json::from_slice(&zero_copy[0]) {

This can be done automatically by using https://docs.rs/deno_core/0.58.0/deno_core/fn.json_op_sync.html

SyrupThinker

comment created time in a day

PullRequestReviewEvent
PullRequestReviewEvent
PullRequestReviewEvent

issue commentdenoland/deno

The simpler overload of `Deno.test` should have an options argument

I agree with @bartlomieju - we shouldn't further complicate the already-complicated Deno.test signature.

solson

comment created time in a day

push eventdenoland/deno

tokiedokie

commit sha c4ed3fb7e767311dc5a6fc931fceaf4fdee885de

chore: add copyright (#7593)

view details

push time in a day

PR merged denoland/deno

chore: add copyright

adds copyright comment in files that don't have one

+130 -13

0 comment

117 changed files

tokiedokie

pr closed time in a day

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentdenoland/deno

refactor: remove CliState, use OpState, add CliModuleLoader

 // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.-use crate::state::CliState;+use crate::permissions::Permissions;  pub fn init(rt: &mut deno_core::JsRuntime) {-  super::reg_json_async(rt, "op_fetch", deno_fetch::op_fetch::<CliState>);+  super::reg_json_async(rt, "op_fetch", deno_fetch::op_fetch::<Permissions>);

Nice

bartlomieju

comment created time in 3 days

PullRequestReviewEvent
PullRequestReviewEvent
PullRequestReviewEvent

push eventvitormmatos/deno

Ryan Dahl

commit sha 46bf660e361c854c7a139b488a4630a2eb1cab28

refactor: make fetch use op_fetch_read instead of op_read (#7529)

view details

Ryan Dahl

commit sha 3e98d9091f678eb8a1673fef933ace0eadbe1b2a

fix: Use Buffer.writeSync in MultipartBuilder (#7542)

view details

Luca Casonato

commit sha 303ebc0df4fc889d8c1d3bb4375eeb57aedfe3ce

chore: remove readJson/writeJson from manual (#7541)

view details

Bartek Iwańczuk

commit sha 3421f4dbbd5cabb3a0866ebb3b8aeae5b62730ef

refactor: disable URL.createObjectUrl (#7543)

view details

Bartek Iwańczuk

commit sha bda937938550a0969588a6878d2fb6d72c17b22d

refactor: move op_resources and op_close to deno_core (#7539) Moves op_close and op_resources to deno_core::ops and exports them. Adds serde dependency to deno_core and reexports it. Moves JS implementation of those ops to Deno.core and reexports them in Deno.

view details

Bartek Iwańczuk

commit sha c307e3e4be4e02de86103cd48d28f5ba3b18628d

refactor: use Symbol.for instead of Symbol in cli/rt/ (#7537)

view details

Casper Beyer

commit sha a6f4559174c64066d45210b02f6a06aa2f67c2cd

fix(cli/console): escape non printable characters in object entries (#7533)

view details

Bartek Iwańczuk

commit sha 6453cb75670b6aefbfc712c7d05b1135bee6226c

refactor: Move URL to op_crates/web (#7544)

view details

Bartek Iwańczuk

commit sha d245ececb6c3eed9d6a01b877cfbbf7642454fc3

fix: disable rustyline logs (#7535)

view details

Pig Fang

commit sha e4188f7dfb95ad16750874dd2cdd4a80b48b1ecc

fix(cli/fmt): make fmt output more readable (#7534)

view details

Jarrett Helton

commit sha cead79f5b8ffd376d339b6e0c30e872bfe6820f6

feat(std/node) stub out process.stdin, stdout, stderr (#7184)

view details

Bartek Iwańczuk

commit sha 7845740637eb646c0b13dc541f043fd65136fc03

refactor: deno_fetch op crate (#7524)

view details

Casper Beyer

commit sha 38196f7850d7498e98f5ec7c66801deadabe09cf

fix(cli/console): always quote and escape inspected strings (#7546)

view details

Bartek Iwańczuk

commit sha ec174170ba090728ebb83b05450d5550a514f43f

refactor: move FileReader to op_crates/web (#7554)

view details

Casper Beyer

commit sha 93e8e59a7e651277f9943b8e9bf4ff6342243a90

fix(cli/console): surround non alpha-numeric object keys with quotes (#7550)

view details

Ryan Dahl

commit sha 8edf099485903a402d8e9df4810b9362ed1b1f15

publish deno_fetch during CI (#7557)

view details

Casper Beyer

commit sha de95fbebc467a51577c692ff7808c09d3d26fac6

fix(cli/repl): format evaluation results with the object specifier (#7561)

view details

tokiedokie

commit sha 4c2920ddd7729da2555728905c22aa2ece237758

fix(cli/fmt): canonicalize files in current dir (#7508)

view details

Ryan Dahl

commit sha 526d668102291b26628c6fced511e17807a4699f

Use reqwest from deno_fetch export (#7562)

view details

Nayeem Rahman

commit sha 4fcfff0393a90bef6313df2c8895cd285da29440

fix(bundle, eval, repl): Add missing flags (#7414) Restructures flag helpers and applies them consistently.

view details

push time in 4 days

pull request commentdenoland/deno

complete readme redesign

@vitormmatos can you please check the CLA again - it's not green.

vitormmatos

comment created time in 4 days

push eventdenoland/deno

Nayeem Rahman

commit sha 4fcfff0393a90bef6313df2c8895cd285da29440

fix(bundle, eval, repl): Add missing flags (#7414) Restructures flag helpers and applies them consistently.

view details

push time in 4 days

PR merged denoland/deno

feat(bundle, eval, repl): Add missing flags

Restructures flag helpers and applies them consistently.

Adds:

  • deno bundle --no-remote
  • deno eval --importmap
  • deno eval --no-remote
  • deno eval --config
  • deno eval --no-check
  • deno eval --reload
  • deno eval --lock
  • deno eval --lock-write
  • deno eval --cached-only
  • deno eval --seed
  • deno repl --importmap
  • deno repl --no-remote
  • deno repl --config
  • deno repl --no-check
  • deno repl --reload
  • deno repl --lock
  • deno repl --lock-write
  • deno repl --cached-only
  • deno repl --seed
+144 -238

1 comment

1 changed file

nayeemrmn

pr closed time in 4 days

PullRequestReviewEvent

delete branch ry/deno

delete branch : reqwest_from_deno_fetch

delete time in 4 days

push eventdenoland/deno

Ryan Dahl

commit sha 526d668102291b26628c6fced511e17807a4699f

Use reqwest from deno_fetch export (#7562)

view details

push time in 4 days

PR merged denoland/deno

Use reqwest from deno_fetch export

<!-- Before submitting a PR, please read https://github.com/denoland/deno/blob/master/docs/contributing.md -->

+15 -12

0 comment

6 changed files

ry

pr closed time in 4 days

push eventdenoland/deno

tokiedokie

commit sha 4c2920ddd7729da2555728905c22aa2ece237758

fix(cli/fmt): canonicalize files in current dir (#7508)

view details

push time in 4 days

PR merged denoland/deno

fix(cli/fmt): canonicalize files in current dir

fixes #7495

ignored files and explicitly specified files are canonicalized, but files that can be traced from current_dir are not canonicalized this causes the bug that deno lint with --ignore actually does't ignore any file

+37 -2

2 comments

2 changed files

tokiedokie

pr closed time in 4 days

issue closeddenoland/deno

Lint --ignore doesn't normalize file seperators

deno run ./tools/lint.ts works on unix and Windows.

deno lint --unstable --ignore=./tools/lint.ts does not work on Windows, but it does work on Unix. From my preliminary testing it seems you have to do deno lint --unstable --ignore=.\tools\lint.ts on Windows. I think we should normalize these separators.

closed time in 4 days

lucacasonato
PullRequestReviewEvent

push eventdenoland/deno

Casper Beyer

commit sha de95fbebc467a51577c692ff7808c09d3d26fac6

fix(cli/repl): format evaluation results with the object specifier (#7561)

view details

push time in 4 days

issue closeddenoland/deno

Print evaluation results in the read-eval-print-loop using the object specifier

Mentioned this in #7545

String entered at the REPL prompt are printed as strings without being escaped.

For example

> Deno 1.4.0
exit using ctrl+d or close()
> ""

> "Hello"
Hello

Expectation would be

> Deno 1.4.0
exit using ctrl+d or close()
> ""
""
> "Hello"
"Hello"

Added quotation behavior in #7546 but this only applies to inspectArgs when the object formatting specifier is used (strings and the %s specifier are printed as is without quotation and escaping) so we should use that.

closed time in 4 days

caspervonb
PullRequestReviewEvent

PR opened denoland/deno

Use reqwest from deno_fetch export

<!-- Before submitting a PR, please read https://github.com/denoland/deno/blob/master/docs/contributing.md -->

+15 -12

0 comment

6 changed files

pr created time in 4 days

create barnchry/deno

branch : reqwest_from_deno_fetch

created branch time in 4 days

push eventdenoland/deno

Ryan Dahl

commit sha 8edf099485903a402d8e9df4810b9362ed1b1f15

publish deno_fetch during CI (#7557)

view details

push time in 4 days

delete branch ry/deno

delete branch : fetch_publish

delete time in 4 days

PR merged denoland/deno

Reviewers
publish deno_fetch during CI

<!-- Before submitting a PR, please read https://github.com/denoland/deno/blob/master/docs/contributing.md -->

+23 -32

2 comments

5 changed files

ry

pr closed time in 4 days

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentdenoland/deno

refactor: move fields from CliState to OpState

 impl Worker {       let ca_file = global_state.flags.ca_file.as_deref();       let client = crate::http_util::create_http_client(ca_file).unwrap();       op_state.put(client);++      let global_timer = RefCell::new(GlobalTimer::default());+      op_state.put(global_timer);++      if let Some(seed) = global_state.flags.seed {+        let rng = StdRng::seed_from_u64(seed);+        op_state.put(RefCell::new(rng));

I think you don't need the RefCell here.

bartlomieju

comment created time in 4 days

pull request commentdenoland/deno

fix(cli/http_utils): accept a single key-multiple values headers

Probably better to use an array of arrays headers: [ [ "Content-Type", "text/plain"], ["User-Agent", "Deno"]]

tokiedokie

comment created time in 4 days

push eventdenoland/deno

Casper Beyer

commit sha 93e8e59a7e651277f9943b8e9bf4ff6342243a90

fix(cli/console): surround non alpha-numeric object keys with quotes (#7550)

view details

push time in 4 days

issue closeddenoland/deno

Inspect should quote non-simple object keys

This is a follow-on from https://github.com/denoland/deno/issues/7532 where I noticed Deno is not doing what I expected for object keys.

In node we get this:

> ({ "foo\b": 1, "bar": 2 })
{ 'foo\b': 1, bar: 2 }

While in deno (latest commit, https://github.com/denoland/deno/commit/e4188f7dfb95ad16750874dd2cdd4a80b48b1ecc) we get this:

> ({ "foo\b": 1, "bar": 2 })
{ foo\b: 1, bar: 2 }

I think we essentially need to detect when object keys would be valid unquoted keys in a JS object literal, and otherwise quote them.

cc @caspervonb

closed time in 4 days

solson
PullRequestReviewEvent

push eventry/deno

Ryan Dahl

commit sha 9d15e1b53cc1d944f61b4da4fa5613b5386bad8c

x

view details

push time in 4 days

push eventry/deno

Ryan Dahl

commit sha a82742a49744a6d591b3d1b02e5d53ac4c1b8f2c

Add #![deny(warnings)] back

view details

push time in 4 days

push eventry/deno

Ryan Dahl

commit sha b5f4bc72952b1116fbecdee695fe7a82e6f9a00f

fix warning

view details

push time in 4 days

pull request commentdenoland/deno

publish deno_fetch during CI

Those warnings aren't introduced in this PR

ry

comment created time in 4 days

PR opened denoland/deno_website2

Add link to HN comments
+2 -0

0 comment

1 changed file

pr created time in 4 days

PR opened denoland/deno

publish deno_fetch during CI

<!-- Before submitting a PR, please read https://github.com/denoland/deno/blob/master/docs/contributing.md -->

+18 -31

0 comment

4 changed files

pr created time in 4 days

create barnchry/deno

branch : fetch_publish

created branch time in 4 days

push eventdenoland/deno

Casper Beyer

commit sha 38196f7850d7498e98f5ec7c66801deadabe09cf

fix(cli/console): always quote and escape inspected strings (#7546)

view details

push time in 4 days

issue closeddenoland/deno

Inspect should always quote and escape strings

This is similar to #7532 but for plain strings.

We are returning strings back as-is from Deno.inspect which isn't very useful.

const value = "\x1b[2J";
console.log(Deno.inspect(value));

Expected output

"\x1b[2j" // Deno.inspect yields a string with \"\\x1b[2j\"

Actual output

\x1b[2j

This manifests itself in quite a few different ways including but not limited to;

  • Doing an asserting error with something that returns a terminal sequence can blow up the terminal.
  • Impossible to spot string diffs in testing/asserts.
  • Typing in a terminal sequence in the prompt can blow up the terminal as it echoes back without being escaped.

closed time in 4 days

caspervonb
PullRequestReviewEvent

push eventdenoland/deno

Bartek Iwańczuk

commit sha 7845740637eb646c0b13dc541f043fd65136fc03

refactor: deno_fetch op crate (#7524)

view details

push time in 4 days

PR merged denoland/deno

deno_fetch attempt 2

Depends on https://github.com/denoland/deno/pull/7521

+2544 -2234

0 comment

34 changed files

bartlomieju

pr closed time in 4 days

PullRequestReviewEvent

issue commentdenoland/deno

Code sample for WebAssembly doesn't compile on 1.4.0

it runs as javascript

ozanmuyes

comment created time in 4 days

Pull request review commentdenoland/deno

deno_fetch attempt 2

+// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.++use deno_core::error::bad_resource_id;+use deno_core::error::type_error;+use deno_core::error::AnyError;+use deno_core::futures;+use deno_core::js_check;+use deno_core::serde_json;+use deno_core::serde_json::json;+use deno_core::serde_json::Value;+use deno_core::url;+use deno_core::url::Url;+use deno_core::BufVec;+use deno_core::JsRuntime;+use deno_core::OpState;+use deno_core::ZeroCopyBuf;+use reqwest::header::HeaderMap;+use reqwest::header::HeaderName;+use reqwest::header::HeaderValue;+use reqwest::header::USER_AGENT;+use reqwest::redirect::Policy;+use reqwest::Client;+use reqwest::Method;+use reqwest::Response;+use serde::Deserialize;+use std::cell::RefCell;+use std::convert::From;+use std::fs::File;+use std::io::Read;+use std::path::Path;+use std::path::PathBuf;+use std::rc::Rc;++pub fn init(isolate: &mut JsRuntime) {+  let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));+  let files = vec![+    manifest_dir.join("01_fetch_util.js"),+    manifest_dir.join("03_dom_iterable.js"),+    manifest_dir.join("11_streams.js"),+    manifest_dir.join("20_headers.js"),+    manifest_dir.join("26_fetch.js"),+  ];+  // TODO(nayeemrmn): https://github.com/rust-lang/cargo/issues/3946 to get the+  // workspace root.+  let display_root = manifest_dir.parent().unwrap().parent().unwrap();+  for file in files {+    println!("cargo:rerun-if-changed={}", file.display());+    let display_path = file.strip_prefix(display_root).unwrap();+    let display_path_str = display_path.display().to_string();+    js_check(isolate.execute(+      &("deno:".to_string() + &display_path_str.replace('\\', "/")),+      &std::fs::read_to_string(&file).unwrap(),+    ));+  }+}++pub trait FetchPermissions {+  fn check_net_url(&self, url: &Url) -> Result<(), AnyError>;+  fn check_read(&self, p: &PathBuf) -> Result<(), AnyError>;+}++pub fn get_declaration() -> PathBuf {+  PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("lib.deno_fetch.d.ts")+}++#[derive(Deserialize)]+#[serde(rename_all = "camelCase")]+struct FetchArgs {+  method: Option<String>,+  url: String,+  headers: Vec<(String, String)>,+  client_rid: Option<u32>,+}++pub async fn op_fetch<FP>(+  state: Rc<RefCell<OpState>>,+  args: Value,+  data: BufVec,+) -> Result<Value, AnyError>+where+  FP: FetchPermissions + 'static,+{+  let args: FetchArgs = serde_json::from_value(args)?;+  let url = args.url;++  let client = if let Some(rid) = args.client_rid {+    let state_ = state.borrow();+    let r = state_+      .resource_table+      .get::<HttpClientResource>(rid)+      .ok_or_else(bad_resource_id)?;+    r.client.clone()+  } else {+    let state_ = state.borrow();+    let client = state_.borrow::<reqwest::Client>();+    client.clone()+  };++  let method = match args.method {+    Some(method_str) => Method::from_bytes(method_str.as_bytes())?,+    None => Method::GET,+  };++  let url_ = url::Url::parse(&url)?;++  // Check scheme before asking for net permission+  let scheme = url_.scheme();+  if scheme != "http" && scheme != "https" {+    return Err(type_error(format!("scheme '{}' not supported", scheme)));+  }++  {+    let state_ = state.borrow();+    // TODO(ry) The Rc below is a hack because we store Rc<CliState> in OpState.+    // Ideally it could be removed.+    let permissions = state_.borrow::<Rc<FP>>();+    permissions.check_net_url(&url_)?;+  }++  let mut request = client.request(method, url_);++  match data.len() {+    0 => {}+    1 => request = request.body(Vec::from(&*data[0])),+    _ => panic!("Invalid number of arguments"),+  }++  for (key, value) in args.headers {+    let name = HeaderName::from_bytes(key.as_bytes()).unwrap();+    let v = HeaderValue::from_str(&value).unwrap();+    request = request.header(name, v);+  }+  //debug!("Before fetch {}", url);++  let res = request.send().await?;++  //debug!("Fetch response {}", url);+  let status = res.status();+  let mut res_headers = Vec::new();+  for (key, val) in res.headers().iter() {+    res_headers.push((key.to_string(), val.to_str().unwrap().to_owned()));+  }++  let rid = state+    .borrow_mut()+    .resource_table+    .add("httpBody", Box::new(res));++  Ok(json!({+    "bodyRid": rid,+    "status": status.as_u16(),+    "statusText": status.canonical_reason().unwrap_or(""),+    "headers": res_headers+  }))+}++pub async fn op_fetch_read(+  state: Rc<RefCell<OpState>>,+  args: Value,+  _data: BufVec,+) -> Result<Value, AnyError> {+  #[derive(Deserialize)]+  #[serde(rename_all = "camelCase")]+  struct Args {+    rid: u32,+  }++  let args: Args = serde_json::from_value(args)?;+  let rid = args.rid;++  use futures::future::poll_fn;+  use futures::ready;+  use futures::FutureExt;+  let f = poll_fn(move |cx| {+    let mut state = state.borrow_mut();+    let response = state+      .resource_table+      .get_mut::<Response>(rid as u32)+      .ok_or_else(bad_resource_id)?;++    let mut chunk_fut = response.chunk().boxed_local();+    let r = ready!(chunk_fut.poll_unpin(cx))?;+    if let Some(chunk) = r {+      Ok(json!({ "chunk": &*chunk })).into()+    } else {+      Ok(json!({ "chunk": null })).into()+    }+  });+  f.await+  /*+  // I'm programming this as I want it to be programmed, even though it might be+  // incorrect, normally we would use poll_fn here. We need to make this await pattern work.+  let chunk = response.chunk().await?;+  if let Some(chunk) = chunk {+    // TODO(ry) This is terribly inefficient. Make this zero-copy.+    Ok(json!({ "chunk": &*chunk }))+  } else {+    Ok(json!({ "chunk": null }))+  }+  */+}++struct HttpClientResource {+  client: Client,+}++impl HttpClientResource {+  fn new(client: Client) -> Self {+    Self { client }+  }+}++pub fn op_create_http_client<FP>(+  state: &mut OpState,+  args: Value,+  _zero_copy: &mut [ZeroCopyBuf],+) -> Result<Value, AnyError>+where+  FP: FetchPermissions + 'static,+{+  #[derive(Deserialize, Default, Debug)]+  #[serde(rename_all = "camelCase")]+  #[serde(default)]+  struct CreateHttpClientOptions {+    ca_file: Option<String>,+  }+

There's no unstable check currently https://github.com/denoland/deno/blob/cead79f5b8ffd376d339b6e0c30e872bfe6820f6/cli/ops/fetch.rs#L174-L191

bartlomieju

comment created time in 4 days

push eventbartlomieju/deno

Ryan Dahl

commit sha a9642b430ee0d0ea03d60030a753ece85312b7fd

links to reenable issue

view details

push time in 4 days

Pull request review commentdenoland/deno

deno_fetch attempt 2

 unitTest(function nativeEndLine(): void {    assertEquals(blob.size, Deno.build.os === "windows" ? 12 : 11); });+*/

I remembered you created an issue with all the tests to fix? Can you link me to it?

bartlomieju

comment created time in 4 days

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentdenoland/deno

deno_fetch attempt 2

 fn main() {     "cargo:rustc-env=DENO_WEB_LIB_PATH={}",     deno_web::get_declaration().display()   );+  println!(+    "cargo:rustc-env=DENO_FETCH_LIB_PATH={}",+    deno_fetch::get_declaration().display()+  );

This method of passing the declaration file is not so elegant. I hope we can find a better solution in the future.

bartlomieju

comment created time in 4 days

PullRequestReviewEvent

push eventbartlomieju/deno

Ryan Dahl

commit sha 8f33bc5eef09ed684fec78ce7dac40d9f048cfe5

Add TODO comment

view details

push time in 4 days

PullRequestReviewEvent

push eventbartlomieju/deno

Ryan Dahl

commit sha 7efca03f6637bd5df9ab86a92dc7433755e136e0

x

view details

push time in 4 days

push eventdenoland/deno

Jarrett Helton

commit sha cead79f5b8ffd376d339b6e0c30e872bfe6820f6

feat(std/node) stub out process.stdin, stdout, stderr (#7184)

view details

push time in 4 days

more