Vincent LE GOFF zekth Brest, France https://zekth.github.io/ I'm Vincent. I solve problems. Contributing on @denoland & @reef-pi

pull request commentdenoland/deno_std

Added read file str

Rebased and done the reviews @ry

zekth

comment created time in 5 hours

push eventzekth/deno_std

push time in 5 hours

push eventzekth/deno_std

Vincent LE GOFF

commit sha 1805c18ac7ed3aa6727f509ee2ec55f718ff2f61

Improve jsdoc (#277)

view details

Axetroy

commit sha e9d104a424d50e772b64253914452ccf71a72188

feat: add writeJson/writeJsonSync for fs modules (#271)

view details

Ryan Dahl

commit sha c44fbec1351c9032cb21d933b8a9c9c45be7892d

Bump to v0.3.3 (#279)

view details

Vincent LE GOFF

commit sha 6e0bec1f940cbb935525ce68ee43b617df5d1932

Add strings/pad (#282)

view details

Axetroy

commit sha da4abcd9a3a5775939c3941a884d1c6f4d287d0f

extract internal method isSubdir to fs/utils.ts (#285)

view details

Yoshiya Hinosawa

commit sha fae48d5dfbbe6267c71a0dc48647548b190dd875

Add prettier styling options (#281)

view details

Vincent LE GOFF

commit sha b699fa67befaef4423f365e55eff0fec2e14def8

Documentation clean up (#288)

view details

Axetroy

commit sha 264a51c093e00f3538f735ce8f0c25d20471a33d

fix: fs.exists not work for symlink (#291)

view details

Vincent LE GOFF

commit sha 0bb040e8d41788c188fa9aad8458dbfba78db4f4

Test reorganization (#290)

view details

Axetroy

commit sha 59adafe86710038c6864fc0686f0292bf7fd9b1d

fix: wrong usage of assertThrowsAsync which without await keyword (#295)

view details

Axetroy

commit sha a00c51b05b6172d250b04a3bb6c244e5276c2704

remove unnecessary path.resolve in move/readJson/writeJson (#292)

view details

Axetroy

commit sha e80f14489084d748bb52c4311519f5d0c7696f47

move test file out of tests dir in flags module (#293)

view details

Vincent LE GOFF

commit sha 37134a13003dcbe751642d5d8fb9917884ebde27

Added read file str

view details

Vincent LE GOFF

commit sha cb15a6d76a61858aeed892f65e0e7fcf1e404fce

add default

view details

Vincent LE GOFF

commit sha 133e5cc418d4553630bd843e3abb1f3d89962784

jsdoc default fix

view details

Vincent LE GOFF

commit sha 174baf6656ca13e9eaa54be82ff04cdd32214653

review

view details

Vincent LE GOFF

commit sha 87e37401c34580ed58e7b691d158c0bdfe2561fd

format

view details

Vincent LE GOFF

commit sha 7a98eda955ccf1d6ebfb6962b7966ec7632c89cc

review

view details

LE GOFF Vincent

commit sha ae08bd3abf4ed8fcc539e2cd9f3c12e61b5b4b46

added test

view details

LE GOFF Vincent

commit sha b1cf10b5bc3624365d77e6714c987101ee510105

Merge branch 'readfilestr' of https://github.com/zekth/deno_std into readfilestr

view details

push time in 6 hours

push eventzekth/deno

Ryan Dahl

commit sha 6b07ed189cc0a787065d3cdb87a0bf2e09b29d58

Small cleanups for //core (#1914) * Privatize a few deno_core::Isolate methods * Add deno_core::Isolate docs

view details

Ryan Dahl

commit sha 9691d7b53bea5a2656ec47e8437fac1f527b3cce

Sort ops

view details

Ryan Dahl

commit sha 58cc69f672f91841984fc4e1e9bcfb1a75362677

Make timers act like normal ops This is in preperation for core integration.

view details

andy finch

commit sha 7e092210312af337a118c70865c2eb2593c83192

--no-prompt flag for non-interactive environments (#1913)

view details

Ryan Dahl

commit sha 3dbb06e699398549e8cfabc896ef3256ab433cba

v0.3.3

view details

Jack Rowlingson

commit sha bf9e5334a8c8432ea7513efced39a180a81b4675

Fix command in manual.md (#1931)

view details

Ryan Dahl

commit sha 630ead1296dd53fa8f13b7598fd6700dc7a2d9f1

Upload mac/sccache that doesn't link to openssl (#1929) Fixes #1787

view details

Ryan Dahl

commit sha 45fad1b7cfd44376d8be35288b7213636bc93450

allow v8 cli flags on deno_core_http_bench (#1934)

view details

Ryan Dahl

commit sha 76c73ec61ec4271581795a2f0e3ae60072676dae

Add --no-binary-download option to setup.py (#1916)

view details

Ryan Dahl

commit sha 1811318097b57c136913bd95bb9e16d820cc1a1a

core: Behavior shouldn't be generic We always pass around Box<[u8]>, and adding this generic is an unnecessary complication. Add deno_core_http_bench_test to test.py sharedQueue works on deno_core_http_bench

view details

Ryan Dahl

commit sha 1e3509df42e996ea092ae7e8b5a61aef51c92c2b

disable arm64 test

view details

Yoshiya Hinosawa

commit sha 4dbc33c6e3824bc56c884a58a8cfd814e266257d

docs: fix example (#1936)

view details

Vincent LE GOFF

commit sha b2f15cf21ae7b08986468dd8d18b06f9c2e97dc2

jsdoc style guide update (#1932)

view details

Ryan Dahl

commit sha bb642e8c7c9f8ab16540d2e3b1ef6a5543ded91e

Fix TextDecoder for SharedArrayBuffer backed TypedArray (#1940)

view details

Bert Belder

commit sha 62761a4e3a12e123d32c7d78a06f6565118d63b4

core: remove reset() from SharedQueue API

view details

Vincent LE GOFF

commit sha 23108b06b9c8803e44e0e251bdbe193a5cf16ad6

Add test style guide (#1918)

view details

joemclo

commit sha 785b48a423abf98490ac1ea7aebc2020fe445bc1

Fix a missing import in manual.md example for testing (#1935)

view details

Nikola Ristic

commit sha 22f791c26caca980305bd74692de020d900cfff0

Typo fix in styleguide (#1946)

view details

Ryan Dahl

commit sha 52b7cc5499061bb79708a0db92bf9b2d0828f3c3

Fix entry point for tools/docs.py

view details

Ryan Dahl

commit sha 59ac2063e0563586a901b664f6ea05e9b6ef11b5

Remove unused tools/build_test.py file

view details

push time in 9 hours

Pull request review commentdenoland/deno

[WIP] High precision

 fn op_now(   data: libdeno::deno_buf, ) -> Box<Op> {   assert_eq!(data.len(), 0);-  let start = SystemTime::now();-  let since_the_epoch = start.duration_since(UNIX_EPOCH).unwrap();-  let time = since_the_epoch.as_secs() * 1000-    + u64::from(since_the_epoch.subsec_millis());+  let start = Instant::now();+  let since_the_epoch = start.duration_since(_isolate.start_time).as_nanos();+  let time = since_the_epoch;

Have done some modifications and it's working. Have to rebase everything now.

zekth

comment created time in 10 hours

push eventzekth/deno

LE GOFF Vincent

commit sha 20e89a6b3c0fa3ce49d896d1a1e737f10bf2944a

updated msg

view details

LE GOFF Vincent

commit sha e40be7b0c4176c0179cc865be74de77f1f8f8fb7

review

view details

LE GOFF Vincent

commit sha e8daff29847903e9da595f45ba4e54a084e030e1

updated types + lint

view details

push time in 10 hours

Pull request review commentdenoland/deno

[WIP] High precision

 fn op_now(   data: libdeno::deno_buf, ) -> Box<Op> {   assert_eq!(data.len(), 0);-  let start = SystemTime::now();-  let since_the_epoch = start.duration_since(UNIX_EPOCH).unwrap();-  let time = since_the_epoch.as_secs() * 1000-    + u64::from(since_the_epoch.subsec_millis());+  let start = Instant::now();+  let since_the_epoch = start.duration_since(_isolate.start_time).as_nanos();+  let time = since_the_epoch;

Excellent alternative!

zekth

comment created time in 10 hours

Pull request review commentdenoland/deno

[WIP] High precision

 fn op_now(   data: libdeno::deno_buf, ) -> Box<Op> {   assert_eq!(data.len(), 0);-  let start = SystemTime::now();-  let since_the_epoch = start.duration_since(UNIX_EPOCH).unwrap();-  let time = since_the_epoch.as_secs() * 1000-    + u64::from(since_the_epoch.subsec_millis());+  let start = Instant::now();+  let since_the_epoch = start.duration_since(_isolate.start_time).as_nanos();+  let time = since_the_epoch;

Also need to add libmath crate i think.

zekth

comment created time in 12 hours

issue openeddenoland/deno

Add ICU in embedded v8

As seen in https://github.com/denoland/deno/issues/1952 / https://github.com/denoland/deno/issues/1636 ICU needs to be added in Deno build.

Switching this flag to true maybe: https://github.com/denoland/deno/blob/master/.gn#L50 ?

ref: https://v8.dev/docs/i18n

created time in 13 hours

push eventzekth/deno_std

push time in a day

push eventzekth/deno_std

Vincent LE GOFF

commit sha b699fa67befaef4423f365e55eff0fec2e14def8

Documentation clean up (#288)

view details

Axetroy

commit sha 264a51c093e00f3538f735ce8f0c25d20471a33d

fix: fs.exists not work for symlink (#291)

view details

Vincent LE GOFF

commit sha 0bb040e8d41788c188fa9aad8458dbfba78db4f4

Test reorganization (#290)

view details

Vincent LE GOFF

commit sha bd3948bf25b378fc9779aa0717ce9cd916daa281

Added EOL detect / format

view details

Vincent LE GOFF

commit sha 10d939e8d2f76d97d7b5d3cbff2cca3d757648e6

test clean

view details

Vincent LE GOFF

commit sha 42c029aa2026f5b8952d00760efddc02f708a897

bug fix

view details

LE GOFF Vincent

commit sha 919a5f72d3668b47e3491cceff3cf434e4619bf8

mixed input fix

view details

LE GOFF Vincent

commit sha ba27e8e2d9fa4d7edce736019fe70406e6ea6ef1

rebase

view details

LE GOFF Vincent

commit sha 0ff8a3d5ff3b1375d08008e8d73700595d24666c

Merge branch 'newline_detect' of https://github.com/zekth/deno_std into newline_detect

view details

push time in a day

push eventzekth/deno_std

LE GOFF Vincent

commit sha 31a97a40dfaf0d12b83792e22071a9d2572fe493

mixed input fix

view details

push time in a day

Pull request review commentdenoland/deno_std

Added EOL detect / format

+// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.++/** EndOfLine character enum */+export enum EOL {+  LF = "\n",+  CRLF = "\r\n"+}++const regDetect = /(?:\r?\n)/g;+const regCRLF = /\r\n/g;+const regLF = /\n/g;++/**+ * Detect the EOL character for string input.+ * returns null if no newline+ */+export function detect(content: string): EOL | null {+  const d = content.match(regDetect);+  if (!d || d.length === 0) {+    return null;+  }+  const crlf = d.filter(x => x === EOL.CRLF);+  if (crlf.length > 0) {+    return EOL.CRLF;+  } else {+    return EOL.LF;+  }+}++/** Format the file to the targeted EOL */+export function format(content: string, eol: EOL): string {+  const _eol = detect(content);+  if (!_eol) {+    return content;+  } else if (_eol === eol) {+    return content;

I was really wondering about this case. Is that really possible? And in this case, what would you do? Because the file is somehow invalid no?

zekth

comment created time in a day

PR opened denoland/deno

Add Proxy support

this is a draft ATM. https://github.com/denoland/deno_third_party/pull/37 has to be merged to get it building.

Also i'm experiencing an issue here: https://github.com/denoland/deno/compare/master...zekth:deno_proxy?expand=1#diff-5ffba955858802f9b51335c94a75f31eR71

Because of the type mismatch. Is there a common interface for the proxy?

cc @kevinkassimo @hayd

+24 -5

0 comment

3 changed files

pr created time in a day

push eventzekth/deno

LE GOFF Vincent

commit sha 50cc4412e7b19c6b410dfe69f5340acf1c5a1f5a

getting proxy

view details

push time in a day

PR opened denoland/deno_third_party

Add hyper-proxy crate

Add hyper-proxy crate to fix the proxy issue in deno: https://github.com/denoland/deno/issues/588

+898 -0

0 comment

9 changed files

pr created time in a day

create barnchzekth/deno_third_party

branch : hyper_proxy

created branch time in a day

create barnchzekth/deno

branch : deno_proxy

created branch time in a day

delete branch zekth/deno_std

delete branch : doc_clean

delete time in a day

pull request commentdenoland/deno_std

feat: add assertNotThrows/assertNotThrowsAsync for testing/assert module

Some cleaning work cannot be done

May hooks have to be added to the test() function.

axetroy

comment created time in 2 days

push eventzekth/deno_std

Vincent LE GOFF

commit sha 6f1e44c3a7342fc48aaee12749585117efabbad2

format

view details

push time in 2 days

PR opened denoland/deno_std

Test reorganization

As deno_std has more and more modules, ./test.ts was getting a bit fullfilled with a lot of test file imports. I've managed to call an entrypoint in each module which import its own test files. Easier to manage / update / merge.

+28 -23

0 comment

7 changed files

pr created time in 2 days

create barnchzekth/deno_std

branch : test_reorg

created branch time in 2 days

push eventzekth/deno_std

Vincent LE GOFF

commit sha 145c124d5436e7b90ec598f183e7f20993a1b65a

bug fix

view details

push time in 2 days

push eventzekth/deno_std

Vincent LE GOFF

commit sha eaac85e7a7ad7f7b9dd281cc740a92d118dc991a

test clean

view details

push time in 2 days

PR opened denoland/deno_std

Added EOL detect / format

As files may be used in a Linux env but may come from a windows env, EOL is not the same. Added a FS helper for the detection / format. ATM it gets a string input, maybe coupled with readFileStr ( https://github.com/denoland/deno_std/pull/276 ) in the future?

+68 -0

0 comment

3 changed files

pr created time in 2 days

create barnchzekth/deno_std

branch : newline_detect

created branch time in 2 days

issue commentdenoland/deno_std

implement fs-extra api for fs modules

Adding this for readfilestr ref: https://github.com/denoland/deno_std/pull/276

axetroy

comment created time in 2 days

issue commentdenoland/deno_std

implement fs-extra api for fs modules

Hi please consider adding safe delete (move to trash-bin)

I think move to trash bin may have it's place in another repository instead of being into the std lib.

axetroy

comment created time in 2 days

push eventzekth/deno_std

Vincent LE GOFF

commit sha 8c17924d92123e1746369631d9d692c3c9882590

import fix

view details

push time in 2 days

issue openeddenoland/deno

String.normalize()

Was working on a removeDiacritics() helper for deno_std and it appears that Deno is not properly handling string.normalize(). env:

deno: 0.3.2
v8: 7.4.238
typescript: 3.2.1

Example: strTest.ts

let input = "éèñëàäáüúùìíîïæç";
console.log(input.normalize("NFD").replace(/[\u0300-\u036f]/g, ""));
tsc strTest.ts -target esnext | node strTest.js // output: eeneaaauuuiiiiæc
deno strTest.ts // output: éèñëàäáüúùìíîïæç

ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize

created time in 2 days

issue commentdenoland/deno_std

Decouple test runner (testing/mod.ts) from the asserts (testing/asserts.ts)

This can be closed.

ry

comment created time in 2 days

issue closeddenoland/deno_std

Color terminal capabilities

As mention in : https://github.com/denoland/deno_std/blob/master/colors/README.md

It should actually detect, specifically windows and adjust properly.

Here is the OS detection: https://github.com/denoland/deno/blob/master/js/build.ts

Problem is we just return the OS property, which is not enough to detect the capabilities of the env. For example windows 7 does not support this in CMD. To make this possible we have to know the current version of the running env. @kevinkassimo could you provide this info throught platform properties?

Another possibility is to check the env variable: TERM=xterm which is set on capable terminals and not on windows 7 for example. Have to check on a w10 env. ref: https://github.com/PowerShell/Win32-OpenSSH/issues/828

Problem is, if we check the env variable we got prompted for the grand to read env-variable. I'll push a draft of implementation.

closed time in 2 days

zekth

PR opened denoland/deno_std

Documentation cleaning

After some discussions on issues, updated JsDoc to fit Deno format. Also added missing readme files for modules. Move color examples to examples folder

+87 -20

0 comment

6 changed files

pr created time in 2 days

push eventzekth/deno_std

Axetroy

commit sha da4abcd9a3a5775939c3941a884d1c6f4d287d0f

extract internal method isSubdir to fs/utils.ts (#285)

view details

Yoshiya Hinosawa

commit sha fae48d5dfbbe6267c71a0dc48647548b190dd875

Add prettier styling options (#281)

view details

Vincent LE GOFF

commit sha 6b3cc174550a8e9f26add4a6f3eff0ddd5b08283

example clearance

view details

Vincent LE GOFF

commit sha dd20890e60cfaf64b151a4087576b6ee8fcdced2

update documentation for asserts.

view details

Vincent LE GOFF

commit sha 944695d92941f7129189d387826c6f8a2db69f7d

added pad documentation

view details

Vincent LE GOFF

commit sha 57e143c62a6df34918c2ecc3542af4d186362747

added datetime doc

view details

Vincent LE GOFF

commit sha bc216ba1cd9f6ee177aa38eb8604a2fb8106ad4d

moving color example

view details

Vincent LE GOFF

commit sha d5705d3b38e08c064b6d3c187a4cf9c3538b56ee

Merge branch 'doc_clean' of https://github.com/zekth/deno_std into doc_clean

view details

push time in 2 days

pull request commentdenoland/deno_std

feat: add assertNotThrows/assertNotThrowsAsync for testing/assert module

A bit overkill no? Because if the assert throws, the test gets an exception and make it fail.

axetroy

comment created time in 2 days

PR opened denoland/deno

[WIP] High precision

As mentionned here : https://github.com/denoland/deno/issues/1777

I've worked on an implementation with @hayd . Btw i need your help to make it work. Tried my best :)

+71 -28

0 comment

7 changed files

pr created time in 2 days

push eventzekth/deno

andy finch

commit sha da004fb6c8213956cf6fa608e1d732f8f75da481

fix snapshots in gn build (#1886) Bug introduced in 75fe80d5a4992ddad89160c2e0113a1af8d3d24a

view details

Grant Timmerman

commit sha 4f623e37c58dc8ab6fff7fd3c5588eb9708c7952

Fix website manual link (#1889)

view details

Andy Hayden

commit sha 91364cabae8687e7620edac406b43cb40cb55878

Replace deno.land/x/std with deno.land/std (#1890)

view details

Kevin (Kun) "Kassimo" Qian

commit sha de1a10e5f7afe793a66b2349642ea135fc066104

Reorganize version and platform into Deno.build and Deno.version (#1879)

view details

Ryan Dahl

commit sha c42a9d737081fb8ee768c7178dae0e1f19c0f343

Upgrade deno_std (#1892) A major API change was that asserts are imported from testing/asserts.ts now rather than testing/mod.ts and assertEqual as renamed to assertEquals to conform to what is most common in JavaScript.

view details

Ryan Dahl

commit sha 535037b519711d238dc0bfa2c4d2ffb4b17dec53

v0.3.2

view details

Kitson Kelly

commit sha 0473d832c138a7acc25372441cfa01848e6b9915

Cleanup node_modules, update packages (#1894) And fix new lint issues.

view details

Ryan Dahl

commit sha cd1992aeaab92c4446ac289bced3ec548050467d

Upgrade deno_std to 395392 (#1902)

view details

Kitson Kelly

commit sha 24d6bf6aeb2b9ac929808e2b8ae4cd5e844a9f8b

Remove 'deno' builtin module (#1895)

view details

Yoshiya Hinosawa

commit sha aed3e590ba31039eede60e7023b6097df944c46f

docs: package.ts -> deps.ts (#1903)

view details

andy finch

commit sha 8c7a12d1b258f0ef5ab27f49c424331d43e8d97f

Add basic Arm64 build to CI (#1887)

view details

Kitson Kelly

commit sha 034e2cc02829c9244b32232074c7a48af827a2fb

Migrate from tslint to eslint for linting (#1905)

view details

Kitson Kelly

commit sha 75a500ba81d50c77c58c8ec0c1ff62769f5eeb4c

Update to TypeScript 3.3 (#1908)

view details

Vincent LE GOFF

commit sha 830ce9378538a2617145592d7905d7a3de7f127a

Add OSType enum (#1909)

view details

Ryan Dahl

commit sha 72f9a2e20de7839deb446b5cb6bc6dd7e5faf4f2

core: Abstract out Behavior from Isolate (#1904) Move v8_set_flags and v8_version to core. (The idea is that src/ should not depend on libdeno.rs anymore. This is a step towards that.)

view details

Ryan Dahl

commit sha 8828bb8c0e743d9ac2b13a144ea4565d6d2ea7fc

Rename Deno.build.gnArgs to Deno.build.args

view details

Ryan Dahl

commit sha ae4405d747f8a990e1dd31b7bb1166ca7fad9921

Make some renames in js/build.ts (#1912) * Replace Deno.OSType enum with Deno.OperatingSystem type alias * Add arm64 to supported CPU architectures * add type alias for cpu arch Deno.Arch

view details

Jed Fox

commit sha ad21be837036574154e8aa69b06001a1eb380b2b

manual: Improve formatting (#1842)

view details

Ryan Dahl

commit sha 6b07ed189cc0a787065d3cdb87a0bf2e09b29d58

Small cleanups for //core (#1914) * Privatize a few deno_core::Isolate methods * Add deno_core::Isolate docs

view details

Ryan Dahl

commit sha 9691d7b53bea5a2656ec47e8437fac1f527b3cce

Sort ops

view details

push time in 2 days

pull request commentdenoland/deno

Core integration attempt #5

You still bench on raw data or serialized?

ry

comment created time in 2 days

Pull request review commentdenoland/deno_std

Added read file str

+// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.++export interface ReadOptions {+  encoding?: string;+}++/**+ * Read file synchronously and output it as a string.+ *+ * @param filename File to read+ * @param opts Read options+ */+export function readFileSync(filename: string, opts: ReadOptions = {}): string {+  const decoder = new TextDecoder(opts.encoding);+  return decoder.decode(Deno.readFileSync(filename));+}++/**+ * Read file and output it as a string.+ *+ * @param filename File to read+ * @param opts Read options+ */+export async function readFile(

updated it

zekth

comment created time in 3 days

delete branch zekth/deno

delete branch : dep_clean

delete time in 3 days

PR closed denoland/deno

[help needed] Duplicate code cleaning

I've spotted some duplicates code in js/util.ts which was implemented in deno_std. So exported them in js/test_util.ts like done for some others and cleaned the files calling it.

+46 -56

3 comments

28 changed files

zekth

pr closed time in 3 days

pull request commentdenoland/deno

[help needed] Duplicate code cleaning

@zekth Did not check too careful before.

I believe duplicates in util.ts and test_util.ts are intended:

util.ts contents are imported and will be bundled into the generated js file for v8 to take a snapshot and goes into the Deno binary. You'll notice that the imports there does not include the .ts extensions.

test_util.ts is just for testing purposes. All these tests are directly run on Deno, so imports with .ts extensions in that file are fine.

That's exactly what i just figured out. Closing it, i was totally wrong. Sorry guys.

zekth

comment created time in 3 days

Pull request review commentdenoland/deno

[help needed] Duplicate code cleaning

 // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.-import { assert, createResolvable, notImplemented, isTypedArray } from "./util";+import { createResolvable, isTypedArray } from "./util";+import { assert, unreachable, unimplemented } from "./test_util";

Fixed some imports errors but still got the same issue :/

zekth

comment created time in 3 days

push eventzekth/deno

LE GOFF Vincent

commit sha fee64693010d74d754d7d7775fc80100cdaaa2df

import fix

view details

LE GOFF Vincent

commit sha 2412ceb621d38c7fe74848c2d5c1a1b0f74bca1e

import fix

view details

push time in 3 days

pull request commentdenoland/deno

Duplicate code cleaning

I don't really find why i got those errors. Maybe i'm missing something?

zekth

comment created time in 3 days

push eventzekth/deno

LE GOFF Vincent

commit sha c4bfb41ae40ebece77262e55d95aac85fbb6d8cb

import fixing + signature

view details

push time in 3 days

push eventzekth/deno

LE GOFF Vincent

commit sha ad2cb3599d096d324d472b0a00a0854e0dc7e28d

update std to v0.3.2

view details

push time in 3 days

push eventzekth/deno

LE GOFF Vincent

commit sha 83d08b57941f07ab0917d7a44fca3600b99af323

proper import

view details

push time in 3 days

PR opened denoland/deno

Duplicate code cleaning

I've spotted some duplicates code in js/util.ts which was implemented in deno_std. So exported them in js/test_util.ts like done for some others and cleaned the files calling it.

+15 -28

0 comment

7 changed files

pr created time in 3 days

create barnchzekth/deno

branch : dep_clean

created branch time in 3 days

issue closeddenoland/deno_std

lodash like functions

Lodash has done the past few years a lot of helpers / polyfills for the Js community. ES / Typescript have lot of those polyfills now but some usefull are missing. I think it would be revelant to add collection, array modules for example with those functions:

collection:

array:

Note: Feel free to purpose more functions

closed time in 3 days

zekth

issue commentdenoland/deno_std

lodash like functions

Seems legit. Closing it.

zekth

comment created time in 3 days

Pull request review commentdenoland/deno

Implement Web Storage

+export interface Storage {+  readonly length: number;++  key(index: number): string;+  getItem(key: string): string;+  setItem(key: string, value: string): void;+  removeItem(key: string): void;+  clear(): void;+}++export class SessionStorage implements Storage {+  private _storage: Record<string, string> = {};++  get length(): number {+    return Object.keys(this._storage).length;+  }++  key(index: number): string {+    return Object.keys(this._storage)[index];+  }+  getItem(key: string): string {

Both solution are good, it's more like a philosophy. Some APIs returns empty strings, others undefined as the return type is a string. Was just wondering.

sh7dm

comment created time in 4 days

Pull request review commentdenoland/deno

Implement Web Storage

+export interface Storage {+  readonly length: number;++  key(index: number): string;+  getItem(key: string): string;+  setItem(key: string, value: string): void;+  removeItem(key: string): void;+  clear(): void;+}++export class SessionStorage implements Storage {+  private _storage: Record<string, string> = {};++  get length(): number {+    return Object.keys(this._storage).length;+  }++  key(index: number): string {+    return Object.keys(this._storage)[index];+  }+  getItem(key: string): string {

Would it be revelant to return an empty string instead of an undefined value in this case?

sh7dm

comment created time in 4 days

issue commentdenoland/deno_std

Axios-like wrapper on top of fetch

@zekth e.g. migrating Axios apps

It's maybe more revelant to have it in deno_axios no?

sh7dm

comment created time in 4 days

issue commentdenoland/deno_std

Axios-like wrapper on top of fetch

What's the advantage of having axios if fetch is already supported?

sh7dm

comment created time in 4 days

Pull request review commentdenoland/deno

More permissions prompt options

 use ansi_term::Style; use crate::errors::permission_denied; use crate::errors::DenoResult; use std::io;-use std::sync::atomic::{AtomicBool, Ordering};+use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};+use std::sync::Arc;++/// Tri-state value for storing permission state+pub enum PermissionAccessorState {+  Allow = 0,+  Ask = 1,+  Deny = 2,+}++impl From<usize> for PermissionAccessorState {+  fn from(val: usize) -> Self {+    match val {+      0 => PermissionAccessorState::Allow,+      1 => PermissionAccessorState::Ask,+      2 => PermissionAccessorState::Deny,+      _ => unreachable!(),+    }+  }+}++impl From<bool> for PermissionAccessorState {+  fn from(val: bool) -> Self {+    match val {+      true => PermissionAccessorState::Allow,+      false => PermissionAccessorState::Ask,+    }+  }+}++#[derive(Debug)]+pub struct PermissionAccessor {+  state: Arc<AtomicUsize>,+}++impl PermissionAccessor {+  pub fn new(state: PermissionAccessorState) -> Self {+    Self {+      state: Arc::new(AtomicUsize::new(state as usize)),+    }+  }++  pub fn is_allow(&self) -> bool {+    match self.get_state() {+      PermissionAccessorState::Allow => true,+      _ => false,+    }+  }++  /// If the state is "Allow" walk it back to the default "Ask"+  /// Don't do anything if state is "Deny"+  pub fn revoke(&self) {+    if self.is_allow() {+      self.ask();+    }+  }++  pub fn allow(&self) {+    self.set_state(PermissionAccessorState::Allow)+  }++  pub fn ask(&self) {+    self.set_state(PermissionAccessorState::Ask)+  }++  pub fn deny(&self) {+    self.set_state(PermissionAccessorState::Deny)+  }++  /// Update this accessors state based on a PromptResult value+  /// This will only update the state if the PromptResult value+  /// is one of the "Always" values+  pub fn update_with_prompt_result(&self, prompt_result: &PromptResult) {+    match prompt_result {+      PromptResult::AllowAlways => self.allow(),+      PromptResult::DenyAlways => self.deny(),+      _ => {}+    }+  }++  #[inline]+  pub fn get_state(&self) -> PermissionAccessorState {+    self.state.load(Ordering::SeqCst).into()+  }+  fn set_state(&self, state: PermissionAccessorState) {+    self.state.store(state as usize, Ordering::SeqCst)+  }+}++impl From<bool> for PermissionAccessor {+  fn from(val: bool) -> Self {+    Self::new(PermissionAccessorState::from(val))+  }+}++impl Default for PermissionAccessor {+  fn default() -> Self {+    Self {+      state: Arc::new(AtomicUsize::new(PermissionAccessorState::Ask as usize)),+    }+  }+}  #[cfg_attr(feature = "cargo-clippy", allow(stutter))] #[derive(Debug, Default)] pub struct DenoPermissions {   // Keep in sync with src/permissions.ts-  pub allow_read: AtomicBool,-  pub allow_write: AtomicBool,-  pub allow_net: AtomicBool,-  pub allow_env: AtomicBool,-  pub allow_run: AtomicBool,+  pub allow_read: PermissionAccessor,+  pub allow_write: PermissionAccessor,+  pub allow_net: PermissionAccessor,+  pub allow_env: PermissionAccessor,+  pub allow_run: PermissionAccessor,   pub no_prompts: AtomicBool, }  impl DenoPermissions {   pub fn from_flags(flags: &DenoFlags) -> Self {     Self {-      allow_read: AtomicBool::new(flags.allow_read),-      allow_write: AtomicBool::new(flags.allow_write),-      allow_env: AtomicBool::new(flags.allow_env),-      allow_net: AtomicBool::new(flags.allow_net),-      allow_run: AtomicBool::new(flags.allow_run),+      allow_read: PermissionAccessor::from(flags.allow_read),+      allow_write: PermissionAccessor::from(flags.allow_write),+      allow_env: PermissionAccessor::from(flags.allow_env),+      allow_net: PermissionAccessor::from(flags.allow_net),+      allow_run: PermissionAccessor::from(flags.allow_run),       no_prompts: AtomicBool::new(flags.no_prompts),     }   }    pub fn check_run(&self) -> DenoResult<()> {-    if self.allow_run.load(Ordering::SeqCst) {-      return Ok(());-    };-    // TODO get location (where access occurred)-    let r = self.try_permissions_prompt("access to run a subprocess");-    if r.is_ok() {-      self.allow_run.store(true, Ordering::SeqCst);+    match self.allow_run.get_state() {+      PermissionAccessorState::Allow => Ok(()),+      PermissionAccessorState::Ask => {+        match self.try_permissions_prompt("access to run a subprocess") {+          Err(e) => Err(e),+          Ok(v) => {+            self.allow_run.update_with_prompt_result(&v);+            v.check()?;+            Ok(())+          }+        }+      }+      PermissionAccessorState::Deny => Err(permission_denied()),     }-    r   }    pub fn check_read(&self, filename: &str) -> DenoResult<()> {-    if self.allow_read.load(Ordering::SeqCst) {-      return Ok(());-    };-    // TODO get location (where access occurred)-    let r =-      self.try_permissions_prompt(&format!("read access to \"{}\"", filename));;-    if r.is_ok() {-      self.allow_read.store(true, Ordering::SeqCst);+    match self.allow_read.get_state() {+      PermissionAccessorState::Allow => Ok(()),+      PermissionAccessorState::Ask => match self+        .try_permissions_prompt(&format!("read access to \"{}\"", filename))+      {+        Err(e) => Err(e),+        Ok(v) => {+          self.allow_run.update_with_prompt_result(&v);+          v.check()?;+          Ok(())+        }+      },+      PermissionAccessorState::Deny => Err(permission_denied()),     }-    r   }    pub fn check_write(&self, filename: &str) -> DenoResult<()> {-    if self.allow_write.load(Ordering::SeqCst) {-      return Ok(());-    };-    // TODO get location (where access occurred)-    let r =-      self.try_permissions_prompt(&format!("write access to \"{}\"", filename));;-    if r.is_ok() {-      self.allow_write.store(true, Ordering::SeqCst);+    match self.allow_write.get_state() {+      PermissionAccessorState::Allow => Ok(()),+      PermissionAccessorState::Ask => match self+        .try_permissions_prompt(&format!("write access to \"{}\"", filename))+      {+        Err(e) => Err(e),+        Ok(v) => {+          self.allow_run.update_with_prompt_result(&v);+          v.check()?;+          Ok(())+        }+      },+      PermissionAccessorState::Deny => Err(permission_denied()),     }-    r   }    pub fn check_net(&self, domain_name: &str) -> DenoResult<()> {-    if self.allow_net.load(Ordering::SeqCst) {-      return Ok(());-    };-    // TODO get location (where access occurred)-    let r = self.try_permissions_prompt(&format!(-      "network access to \"{}\"",-      domain_name-    ));-    if r.is_ok() {-      self.allow_net.store(true, Ordering::SeqCst);+    match self.allow_net.get_state() {+      PermissionAccessorState::Allow => Ok(()),+      PermissionAccessorState::Ask => match self.try_permissions_prompt(+        &format!("network access to \"{}\"", domain_name),+      ) {+        Err(e) => Err(e),+        Ok(v) => {+          self.allow_run.update_with_prompt_result(&v);+          v.check()?;+          Ok(())+        }+      },+      PermissionAccessorState::Deny => Err(permission_denied()),     }-    r   }    pub fn check_env(&self) -> DenoResult<()> {-    if self.allow_env.load(Ordering::SeqCst) {-      return Ok(());-    };-    // TODO get location (where access occurred)-    let r = self.try_permissions_prompt(&"access to environment variables");-    if r.is_ok() {-      self.allow_env.store(true, Ordering::SeqCst);+    match self.allow_env.get_state() {+      PermissionAccessorState::Allow => Ok(()),+      PermissionAccessorState::Ask => {+        match self.try_permissions_prompt("access to environment variables") {+          Err(e) => Err(e),+          Ok(v) => {+            self.allow_run.update_with_prompt_result(&v);+            v.check()?;+            Ok(())+          }+        }+      }+      PermissionAccessorState::Deny => Err(permission_denied()),     }-    r   }    /// Try to present the user with a permission prompt   /// will error with permission_denied if no_prompts is enabled-  fn try_permissions_prompt(&self, message: &str) -> DenoResult<()> {+  fn try_permissions_prompt(&self, message: &str) -> DenoResult<PromptResult> {     if self.no_prompts.load(Ordering::SeqCst) {       return Err(permission_denied());     }+    if !atty::is(atty::Stream::Stdin) || !atty::is(atty::Stream::Stderr) {+      return Err(permission_denied());+    };     permission_prompt(message)   }    pub fn allows_run(&self) -> bool {-    return self.allow_run.load(Ordering::SeqCst);+    return self.allow_run.is_allow();   }    pub fn allows_read(&self) -> bool {-    return self.allow_read.load(Ordering::SeqCst);+    return self.allow_read.is_allow();   }    pub fn allows_write(&self) -> bool {-    return self.allow_write.load(Ordering::SeqCst);+    return self.allow_write.is_allow();   }    pub fn allows_net(&self) -> bool {-    return self.allow_net.load(Ordering::SeqCst);+    return self.allow_net.is_allow();   }    pub fn allows_env(&self) -> bool {-    return self.allow_env.load(Ordering::SeqCst);+    return self.allow_env.is_allow();   }    pub fn revoke_run(&self) -> DenoResult<()> {-    self.allow_run.store(false, Ordering::SeqCst);+    self.allow_run.revoke();     return Ok(());   }    pub fn revoke_read(&self) -> DenoResult<()> {-    self.allow_read.store(false, Ordering::SeqCst);+    self.allow_read.revoke();     return Ok(());   }    pub fn revoke_write(&self) -> DenoResult<()> {-    self.allow_write.store(false, Ordering::SeqCst);+    self.allow_write.revoke();     return Ok(());   }    pub fn revoke_net(&self) -> DenoResult<()> {-    self.allow_net.store(false, Ordering::SeqCst);+    self.allow_net.revoke();     return Ok(());   }    pub fn revoke_env(&self) -> DenoResult<()> {-    self.allow_env.store(false, Ordering::SeqCst);+    self.allow_env.revoke();     return Ok(());   }+} -  pub fn default() -> Self {-    Self {-      allow_read: AtomicBool::new(false),-      allow_write: AtomicBool::new(false),-      allow_env: AtomicBool::new(false),-      allow_net: AtomicBool::new(false),-      allow_run: AtomicBool::new(false),-      ..Default::default()+/// Quad-state value for representing user input on permission prompt+#[derive(Debug, Clone)]+pub enum PromptResult {+  AllowAlways = 0,+  AllowOnce = 1,+  DenyOnce = 2,+  DenyAlways = 3,+}++impl PromptResult {+  /// If value is any form of deny this will error with permission_denied+  pub fn check(&self) -> DenoResult<()> {+    match self {+      PromptResult::DenyOnce => Err(permission_denied()),+      PromptResult::DenyAlways => Err(permission_denied()),+      _ => Ok(()),     }   } } -fn permission_prompt(message: &str) -> DenoResult<()> {-  if !atty::is(atty::Stream::Stdin) || !atty::is(atty::Stream::Stderr) {-    return Err(permission_denied());-  };-  let msg = format!("⚠️  Deno requests {}. Grant? [yN] ", message);+fn permission_prompt(message: &str) -> DenoResult<PromptResult> {+  let msg = format!("⚠️  Deno requests {}. Grant? [a/y/n/d (a = allow always, y = allow once, n = deny once, d = deny always)] ", message);   // print to stderr so that if deno is > to a file this is still displayed.   eprint!("{}", Style::new().bold().paint(msg));-  let mut input = String::new();-  let stdin = io::stdin();-  let _nread = stdin.read_line(&mut input)?;-  let ch = input.chars().next().unwrap();-  let is_yes = ch == 'y' || ch == 'Y';-  if is_yes {-    Ok(())-  } else {-    Err(permission_denied())+  loop {+    let mut input = String::new();+    let stdin = io::stdin();+    let _nread = stdin.read_line(&mut input)?;+    let ch = input.chars().next().unwrap();+    match ch.to_ascii_lowercase() {+      'a' => return Ok(PromptResult::AllowAlways),+      'y' => return Ok(PromptResult::AllowOnce),+      'n' => return Ok(PromptResult::DenyOnce),+      'd' => return Ok(PromptResult::DenyAlways),+      _ => {+        // If we don't get a recognized option try again.+        let msg_again = format!("Unrecognized option '{}' [a/y/n/d (a = allow always, y = allow once, n = deny once, d = deny always)] ", ch);+        eprint!("{}", Style::new().bold().paint(msg_again));+      }

we can test it externally calling it by this kind of command: y | deno ./permission_test.ts and in the test you ask for permission twice for example. But i think it's more a workaround.

afinch7

comment created time in 4 days

issue commentdenoland/deno_std

lodash like functions

In a sense yes, i agree. But it's not the only library to do it, that's why i suggest those funcs to be integrated; as its really usefull and i think it has its place in ES / TS and not in a third party.

zekth

comment created time in 4 days

Pull request review commentdenoland/deno

More permissions prompt options

 use ansi_term::Style; use crate::errors::permission_denied; use crate::errors::DenoResult; use std::io;-use std::sync::atomic::{AtomicBool, Ordering};+use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};+use std::sync::Arc;++/// Tri-state value for storing permission state+pub enum PermissionAccessorState {+  Allow = 0,+  Ask = 1,+  Deny = 2,+}++impl From<usize> for PermissionAccessorState {+  fn from(val: usize) -> Self {+    match val {+      0 => PermissionAccessorState::Allow,+      1 => PermissionAccessorState::Ask,+      2 => PermissionAccessorState::Deny,+      _ => unreachable!(),+    }+  }+}++impl From<bool> for PermissionAccessorState {+  fn from(val: bool) -> Self {+    match val {+      true => PermissionAccessorState::Allow,+      false => PermissionAccessorState::Ask,+    }+  }+}++#[derive(Debug)]+pub struct PermissionAccessor {+  state: Arc<AtomicUsize>,+}++impl PermissionAccessor {+  pub fn new(state: PermissionAccessorState) -> Self {+    Self {+      state: Arc::new(AtomicUsize::new(state as usize)),+    }+  }++  pub fn is_allow(&self) -> bool {+    match self.get_state() {+      PermissionAccessorState::Allow => true,+      _ => false,+    }+  }++  /// If the state is "Allow" walk it back to the default "Ask"+  /// Don't do anything if state is "Deny"+  pub fn revoke(&self) {+    if self.is_allow() {+      self.ask();+    }+  }++  pub fn allow(&self) {+    self.set_state(PermissionAccessorState::Allow)+  }++  pub fn ask(&self) {+    self.set_state(PermissionAccessorState::Ask)+  }++  pub fn deny(&self) {+    self.set_state(PermissionAccessorState::Deny)+  }++  /// Update this accessors state based on a PromptResult value+  /// This will only update the state if the PromptResult value+  /// is one of the "Always" values+  pub fn update_with_prompt_result(&self, prompt_result: &PromptResult) {+    match prompt_result {+      PromptResult::AllowAlways => self.allow(),+      PromptResult::DenyAlways => self.deny(),+      _ => {}+    }+  }++  #[inline]+  pub fn get_state(&self) -> PermissionAccessorState {+    self.state.load(Ordering::SeqCst).into()+  }+  fn set_state(&self, state: PermissionAccessorState) {+    self.state.store(state as usize, Ordering::SeqCst)+  }+}++impl From<bool> for PermissionAccessor {+  fn from(val: bool) -> Self {+    Self::new(PermissionAccessorState::from(val))+  }+}++impl Default for PermissionAccessor {+  fn default() -> Self {+    Self {+      state: Arc::new(AtomicUsize::new(PermissionAccessorState::Ask as usize)),+    }+  }+}  #[cfg_attr(feature = "cargo-clippy", allow(stutter))] #[derive(Debug, Default)] pub struct DenoPermissions {   // Keep in sync with src/permissions.ts-  pub allow_read: AtomicBool,-  pub allow_write: AtomicBool,-  pub allow_net: AtomicBool,-  pub allow_env: AtomicBool,-  pub allow_run: AtomicBool,+  pub allow_read: PermissionAccessor,+  pub allow_write: PermissionAccessor,+  pub allow_net: PermissionAccessor,+  pub allow_env: PermissionAccessor,+  pub allow_run: PermissionAccessor,   pub no_prompts: AtomicBool, }  impl DenoPermissions {   pub fn from_flags(flags: &DenoFlags) -> Self {     Self {-      allow_read: AtomicBool::new(flags.allow_read),-      allow_write: AtomicBool::new(flags.allow_write),-      allow_env: AtomicBool::new(flags.allow_env),-      allow_net: AtomicBool::new(flags.allow_net),-      allow_run: AtomicBool::new(flags.allow_run),+      allow_read: PermissionAccessor::from(flags.allow_read),+      allow_write: PermissionAccessor::from(flags.allow_write),+      allow_env: PermissionAccessor::from(flags.allow_env),+      allow_net: PermissionAccessor::from(flags.allow_net),+      allow_run: PermissionAccessor::from(flags.allow_run),       no_prompts: AtomicBool::new(flags.no_prompts),     }   }    pub fn check_run(&self) -> DenoResult<()> {-    if self.allow_run.load(Ordering::SeqCst) {-      return Ok(());-    };-    // TODO get location (where access occurred)-    let r = self.try_permissions_prompt("access to run a subprocess");-    if r.is_ok() {-      self.allow_run.store(true, Ordering::SeqCst);+    match self.allow_run.get_state() {+      PermissionAccessorState::Allow => Ok(()),+      PermissionAccessorState::Ask => {+        match self.try_permissions_prompt("access to run a subprocess") {+          Err(e) => Err(e),+          Ok(v) => {+            self.allow_run.update_with_prompt_result(&v);+            v.check()?;+            Ok(())+          }+        }+      }+      PermissionAccessorState::Deny => Err(permission_denied()),     }-    r   }    pub fn check_read(&self, filename: &str) -> DenoResult<()> {-    if self.allow_read.load(Ordering::SeqCst) {-      return Ok(());-    };-    // TODO get location (where access occurred)-    let r =-      self.try_permissions_prompt(&format!("read access to \"{}\"", filename));;-    if r.is_ok() {-      self.allow_read.store(true, Ordering::SeqCst);+    match self.allow_read.get_state() {+      PermissionAccessorState::Allow => Ok(()),+      PermissionAccessorState::Ask => match self+        .try_permissions_prompt(&format!("read access to \"{}\"", filename))+      {+        Err(e) => Err(e),+        Ok(v) => {+          self.allow_run.update_with_prompt_result(&v);+          v.check()?;+          Ok(())+        }+      },+      PermissionAccessorState::Deny => Err(permission_denied()),     }-    r   }    pub fn check_write(&self, filename: &str) -> DenoResult<()> {-    if self.allow_write.load(Ordering::SeqCst) {-      return Ok(());-    };-    // TODO get location (where access occurred)-    let r =-      self.try_permissions_prompt(&format!("write access to \"{}\"", filename));;-    if r.is_ok() {-      self.allow_write.store(true, Ordering::SeqCst);+    match self.allow_write.get_state() {+      PermissionAccessorState::Allow => Ok(()),+      PermissionAccessorState::Ask => match self+        .try_permissions_prompt(&format!("write access to \"{}\"", filename))+      {+        Err(e) => Err(e),+        Ok(v) => {+          self.allow_run.update_with_prompt_result(&v);+          v.check()?;+          Ok(())+        }+      },+      PermissionAccessorState::Deny => Err(permission_denied()),     }-    r   }    pub fn check_net(&self, domain_name: &str) -> DenoResult<()> {-    if self.allow_net.load(Ordering::SeqCst) {-      return Ok(());-    };-    // TODO get location (where access occurred)-    let r = self.try_permissions_prompt(&format!(-      "network access to \"{}\"",-      domain_name-    ));-    if r.is_ok() {-      self.allow_net.store(true, Ordering::SeqCst);+    match self.allow_net.get_state() {+      PermissionAccessorState::Allow => Ok(()),+      PermissionAccessorState::Ask => match self.try_permissions_prompt(+        &format!("network access to \"{}\"", domain_name),+      ) {+        Err(e) => Err(e),+        Ok(v) => {+          self.allow_run.update_with_prompt_result(&v);+          v.check()?;+          Ok(())+        }+      },+      PermissionAccessorState::Deny => Err(permission_denied()),     }-    r   }    pub fn check_env(&self) -> DenoResult<()> {-    if self.allow_env.load(Ordering::SeqCst) {-      return Ok(());-    };-    // TODO get location (where access occurred)-    let r = self.try_permissions_prompt(&"access to environment variables");-    if r.is_ok() {-      self.allow_env.store(true, Ordering::SeqCst);+    match self.allow_env.get_state() {+      PermissionAccessorState::Allow => Ok(()),+      PermissionAccessorState::Ask => {+        match self.try_permissions_prompt("access to environment variables") {+          Err(e) => Err(e),+          Ok(v) => {+            self.allow_run.update_with_prompt_result(&v);+            v.check()?;+            Ok(())+          }+        }+      }+      PermissionAccessorState::Deny => Err(permission_denied()),     }-    r   }    /// Try to present the user with a permission prompt   /// will error with permission_denied if no_prompts is enabled-  fn try_permissions_prompt(&self, message: &str) -> DenoResult<()> {+  fn try_permissions_prompt(&self, message: &str) -> DenoResult<PromptResult> {     if self.no_prompts.load(Ordering::SeqCst) {       return Err(permission_denied());     }+    if !atty::is(atty::Stream::Stdin) || !atty::is(atty::Stream::Stderr) {+      return Err(permission_denied());+    };     permission_prompt(message)   }    pub fn allows_run(&self) -> bool {-    return self.allow_run.load(Ordering::SeqCst);+    return self.allow_run.is_allow();   }    pub fn allows_read(&self) -> bool {-    return self.allow_read.load(Ordering::SeqCst);+    return self.allow_read.is_allow();   }    pub fn allows_write(&self) -> bool {-    return self.allow_write.load(Ordering::SeqCst);+    return self.allow_write.is_allow();   }    pub fn allows_net(&self) -> bool {-    return self.allow_net.load(Ordering::SeqCst);+    return self.allow_net.is_allow();   }    pub fn allows_env(&self) -> bool {-    return self.allow_env.load(Ordering::SeqCst);+    return self.allow_env.is_allow();   }    pub fn revoke_run(&self) -> DenoResult<()> {-    self.allow_run.store(false, Ordering::SeqCst);+    self.allow_run.revoke();     return Ok(());   }    pub fn revoke_read(&self) -> DenoResult<()> {-    self.allow_read.store(false, Ordering::SeqCst);+    self.allow_read.revoke();     return Ok(());   }    pub fn revoke_write(&self) -> DenoResult<()> {-    self.allow_write.store(false, Ordering::SeqCst);+    self.allow_write.revoke();     return Ok(());   }    pub fn revoke_net(&self) -> DenoResult<()> {-    self.allow_net.store(false, Ordering::SeqCst);+    self.allow_net.revoke();     return Ok(());   }    pub fn revoke_env(&self) -> DenoResult<()> {-    self.allow_env.store(false, Ordering::SeqCst);+    self.allow_env.revoke();     return Ok(());   }+} -  pub fn default() -> Self {-    Self {-      allow_read: AtomicBool::new(false),-      allow_write: AtomicBool::new(false),-      allow_env: AtomicBool::new(false),-      allow_net: AtomicBool::new(false),-      allow_run: AtomicBool::new(false),-      ..Default::default()+/// Quad-state value for representing user input on permission prompt+#[derive(Debug, Clone)]+pub enum PromptResult {+  AllowAlways = 0,+  AllowOnce = 1,+  DenyOnce = 2,+  DenyAlways = 3,+}++impl PromptResult {+  /// If value is any form of deny this will error with permission_denied+  pub fn check(&self) -> DenoResult<()> {+    match self {+      PromptResult::DenyOnce => Err(permission_denied()),+      PromptResult::DenyAlways => Err(permission_denied()),+      _ => Ok(()),     }   } } -fn permission_prompt(message: &str) -> DenoResult<()> {-  if !atty::is(atty::Stream::Stdin) || !atty::is(atty::Stream::Stderr) {-    return Err(permission_denied());-  };-  let msg = format!("⚠️  Deno requests {}. Grant? [yN] ", message);+fn permission_prompt(message: &str) -> DenoResult<PromptResult> {+  let msg = format!("⚠️  Deno requests {}. Grant? [a/y/n/d (a = allow always, y = allow once, n = deny once, d = deny always)] ", message);   // print to stderr so that if deno is > to a file this is still displayed.   eprint!("{}", Style::new().bold().paint(msg));-  let mut input = String::new();-  let stdin = io::stdin();-  let _nread = stdin.read_line(&mut input)?;-  let ch = input.chars().next().unwrap();-  let is_yes = ch == 'y' || ch == 'Y';-  if is_yes {-    Ok(())-  } else {-    Err(permission_denied())+  loop {+    let mut input = String::new();+    let stdin = io::stdin();+    let _nread = stdin.read_line(&mut input)?;+    let ch = input.chars().next().unwrap();+    match ch.to_ascii_lowercase() {+      'a' => return Ok(PromptResult::AllowAlways),+      'y' => return Ok(PromptResult::AllowOnce),+      'n' => return Ok(PromptResult::DenyOnce),+      'd' => return Ok(PromptResult::DenyAlways),+      _ => {+        // If we don't get a recognized option try again.+        let msg_again = format!("Unrecognized option '{}' [a/y/n/d (a = allow always, y = allow once, n = deny once, d = deny always)] ", ch);+        eprint!("{}", Style::new().bold().paint(msg_again));+      }

Something like 'yes | deno ./test.ts ' ? And the test ask for permission twice. No?

afinch7

comment created time in 4 days

create barnchzekth/deno_std

branch : doc_clean

created branch time in 4 days

push eventzekth/deno_std

Vincent LE GOFF

commit sha 6e0bec1f940cbb935525ce68ee43b617df5d1932

Add strings/pad (#282)

view details

push time in 4 days

issue openeddenoland/deno_std

lodash like functions

Lodash has done the past few years a lot of helpers / polyfills for the Js community. ES / Typescript have lot of those polyfills now but some usefull are missing. I think it would be revelant to add collection, array modules for example with those functions:

collection:

array:

Note: Feel free to purpose more functions

created time in 4 days

delete branch zekth/deno_std

delete branch : str_pad

delete time in 4 days

pull request commentdenoland/deno_std

Added string pad

LGTM - thanks for handling all my nits

it's part of the deal : )

zekth

comment created time in 4 days

push eventzekth/deno_std

Vincent LE GOFF

commit sha 12cec7631e3b94ae49da468afbcb7fdb01958f57

example doc

view details

push time in 4 days

push eventzekth/deno_std

Vincent LE GOFF

commit sha be805ca41b1cb13225439999aa407c3be40604cf

doc

view details

push time in 4 days

Pull request review commentdenoland/deno_std

Added string pad

+// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.++/** FillOption Object */+export interface FillOption {+  /** Char to fill in */+  char: string;+  /** Side to fill in */+  side: "left" | "right";+  /** If strict, output string can't be greater than strLen*/+  strict?: boolean;+  /** char/string used to specify the string has been truncated */+  strictChar?: string;+  /** Side of truncate */+  strictSide?: "left" | "right";+}++/**+ * pad helper for strings. Also resolve substring

corrected. Sorry

zekth

comment created time in 4 days

push eventzekth/deno_std

Vincent LE GOFF

commit sha 20939ec0bae63da8845f6fb25b0346681a1412c3

documentation

view details

push time in 4 days

push eventzekth/deno_std

Vincent LE GOFF

commit sha 1808011826fc169690b3943e5069491068119a58

review

view details

push time in 5 days

Pull request review commentdenoland/deno_std

Added string pad

+// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.++/** FillOption Object */+export interface FillOption {+  /** Char to fill in */+  char: string;+  /** Side to fill in */+  side: Side;+  /** If strict, output string can't be greater than strLen*/+  strict?: boolean;+  /** char/string used to specify the string has been truncated */+  strictChar?: string;+  /** Side of truncate */+  strictSide?: Side;+}++export enum Side {

That was the only point i was doubting. But yes, changing it.

zekth

comment created time in 5 days

push eventzekth/deno

Vincent LE GOFF

commit sha 537f55f5b476902a6823bb8aaf18b3d6bf6db628

syntax

view details

push time in 5 days

Pull request review commentdenoland/deno

jsdoc style guide update

 For example:  Do not document function arguments unless they are non-obvious of their intent (though if they are non-obvious intent, the API should be considered anyways).-Therefore `@param` should generally not be used.+Therefore `@param` should generally not be used. If `@param` is used, it should+not include the `type` as Typescript is already strong typed.

nailed it

zekth

comment created time in 5 days

push eventzekth/deno_std

Vincent LE GOFF

commit sha a90b7e3eee3c4750b7a3768db105282e2f77695d

refactoring

view details

push time in 5 days

push eventzekth/deno_std

Vincent LE GOFF

commit sha 201e4d85388938b99804d40055d0a46bc13a34cf

just anoter test

view details

push time in 5 days

PR opened denoland/deno_std

Added string pad

Added string pad helper in strings. Shorthand for combination of str.padStart / str.padLeft / str.slice / str.substring.

Was needing this for a console reporter, so added it in deno_std. Maybe some opinions on the naming?

Usage:

pad("deno", { char: "*", strLen: 6, side: Side.Left }) // output : "**deno"
pad("deno", { char: "*", strLen: 6, side: Side.Right}) // output : "deno**"
pad("denosorusrex", {
      char: "*",
      strLen: 6,
      side: Side.Left,
      strict: true,
      strictSide: Side.Right,
      strictChar: "..."
    }) // output : "den..."
pad("denosorusrex", {
      char: "*",
      strLen: 6,
      side: Side.Left,
      strict: true,
      strictSide: Side.Left,
      strictChar: "..."
    }) // output : "...rex"
+125 -0

0 comment

3 changed files

pr created time in 5 days

create barnchzekth/deno_std

branch : str_pad

created branch time in 5 days

push eventzekth/deno_std

Vincent LE GOFF

commit sha 5852cd251b249ff19bda15f5eb29ac32b2176928

Datetime module improvement (#259)

view details

Axetroy

commit sha 142a1c6cf890e5c7626c4c934496fae1eee01715

add fs/exists (#260)

view details

Axetroy

commit sha 64d6bfca565acda9151ebb0b84911cc8d63c8c77

feat: add emptyDir for fs modules (#263)

view details

chiefbiiko

commit sha 4de86f04de8c83f8af184cb67b56f4022c17864f

Move benching into testing. (#258)

view details

Yoshiya Hinosawa

commit sha 61af419bbc5717c2e2552050aacb20ef1b17480b

fix: eslint errors (#265)

view details

Axetroy

commit sha 9ae941338aea09adf0d4f48d40f2b09131ae3d5f

feat: add ensureDir/ensureFile for fs modules (#264)

view details

Axetroy

commit sha a1fcfb2744a7a2c660bf03b8da03ca2c4d7753a8

feat: add move/moveSync for fs modules (#266)

view details

Axetroy

commit sha e4485d722ac978c023f9f6720734264e99e1577f

feat: add readJson/readJsonSync for fs modules (#269)

view details

Vincent LE GOFF

commit sha 1805c18ac7ed3aa6727f509ee2ec55f718ff2f61

Improve jsdoc (#277)

view details

Axetroy

commit sha e9d104a424d50e772b64253914452ccf71a72188

feat: add writeJson/writeJsonSync for fs modules (#271)

view details

Ryan Dahl

commit sha c44fbec1351c9032cb21d933b8a9c9c45be7892d

Bump to v0.3.3 (#279)

view details

push time in 5 days

pull request commentdenoland/deno

More permissions prompt options

E.g. allowing web by domain

Great idea

afinch7

comment created time in 5 days

push eventzekth/deno_std

Vincent LE GOFF

commit sha 5b3bbe538493af1ee7afe02d6e816926766bf8d6

tests

view details

Vincent LE GOFF

commit sha 6f13c2c13f6c42f0705db71e66ccfefdb1d31d48

format

view details

push time in 5 days

push eventzekth/deno_std

Vincent LE GOFF

commit sha 4380faeb396bfa03f7c65fd2fed99ca53d383597

review

view details

push time in 6 days

Pull request review commentdenoland/deno_std

Added read file str

+// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.++export interface ReadOptions {+  encoding?: string;+}++/**+ * Read file synchronously and output it as a string.+ *+ * @param filename File to read+ * @param opts Read options+ */+export function readFileSync(filename: string, opts: ReadOptions = {}): string {+  const decoder = new TextDecoder(opts.encoding);+  return decoder.decode(Deno.readFileSync(filename));+}++/**+ * Read file and output it as a string.+ *+ * @param filename File to read+ * @param opts Read options+ */+export async function readFile(

So readFileStr is right for you?

zekth

comment created time in 6 days

delete branch zekth/deno_std

delete branch : jsdoc_clearance

delete time in 6 days

issue commentdenoland/deno_std

implement fs-extra api for fs modules

Add in the task list : Write the readme.MD of the module.

Would you want me to write it?

axetroy

comment created time in 6 days

push eventzekth/deno_std

Vincent LE GOFF

commit sha 0cf258385e4776252ec8475f127c0a6b0841c501

format

view details

push time in 6 days

Pull request review commentdenoland/deno_std

feat: add writeJson/writeJsonSync for fs modules

+// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.+/* eslint-disable @typescript-eslint/no-explicit-any */

I've just fixed the date module. But we may not have any warning. I'll check on the flag module to fix it.

axetroy

comment created time in 6 days

push eventzekth/deno_std

Vincent LE GOFF

commit sha 258aaa14825b737b4c36dc5fe10a3778b2928386

fix return type

view details

push time in 6 days

push eventzekth/deno_std

Vincent LE GOFF

commit sha c905834ad75f0e59e2ed89fad63e746d85c165b8

review

view details

push time in 6 days

Pull request review commentdenoland/deno_std

feat: add copy/copySync for fs modules

+// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.+import * as path from "./path/mod.ts";+import { ensureDir, ensureDirSync } from "./ensure_dir.ts";++export interface CopyOptions {+  /* overwrite existing file or directory, default is false */+  overwrite?: boolean;+}++function isSrcSubdir(src: string, dest: string): boolean {+  const srcArray = src.split(path.sep);+  const destArray = dest.split(path.sep);++  return srcArray.reduce((acc, current, i) => {+    return acc && destArray[i] === current;+  }, true);+}++/* copy file to dest */+async function copyFile(src: string, dest: string): Promise<void> {+  await Deno.copyFile(src, dest);+}++function copyFileSync(src: string, dest: string): void {+  Deno.copyFileSync(src, dest);+}++/* copy link to dest */+/* eslint-disable-next-line @typescript-eslint/no-unused-vars */+async function copyLink(src: string, dest: string): Promise<void> {+  throw new Error("Not implemented copy link");

use unimplemented() from testing/asserts.ts

axetroy

comment created time in 6 days

push eventzekth/deno_std

Vincent LE GOFF

commit sha 6a8a92a63dbfa133efa402d2b513f64f02a9a7f0

assert improvement assertArrayContains+handle tabs

view details

Vincent LE GOFF

commit sha 6e99db78b01b073a1c93c24339731703cf3d9d46

comment add

view details

Vincent LE GOFF

commit sha 8deb34196c37022036936c034381fd4fff37a1a4

Merge branch 'assertion_improvement' of https://github.com/zekth/deno_std into assertion_improvement

view details

Vincent LE GOFF

commit sha 94c2c44e0c5192ab49c131bd95bc2f960354e7b2

format

view details

push time in 6 days

Pull request review commentdenoland/deno_std

Added read file str

+// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.++/**+ * Read file synchronously and output it as a string.+ *+ * @param filename File to read+ * @param [encoding="utf-8"] encoding Encoding of the file+ */+export function readFileStrSync(+  filename: string,+  encoding: string = "utf-8"+): string {+  const decoder = new TextDecoder(encoding);+  return decoder.decode(Deno.readFileSync(filename));+}++/**+ * Read file and output it as a string.+ *+ * @param filename File to read+ * @param [encoding="utf-8"] Encoding of the file+ */+export async function readFileStr(

Totally agree with you. First it was named like this to be in Deno and not in fs-extra as you can see in the ref.

zekth

comment created time in 6 days

Pull request review commentdenoland/deno_std

Added read file str

+// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.++/**+ * Read file synchronously and output it as a string.+ *+ * @param filename File to read+ * @param [encoding="utf-8"] encoding Encoding of the file+ */+export function readFileStrSync(+  filename: string,+  encoding: string = "utf-8"+): string {+  const decoder = new TextDecoder(encoding);+  return decoder.decode(Deno.readFileSync(filename));+}++/**+ * Read file and output it as a string.+ *+ * @param filename File to read+ * @param [encoding="utf-8"] Encoding of the file+ */+export async function readFileStr(+  filename: string,+  encoding: string = "utf-8"

Legit. Will add.

zekth

comment created time in 6 days

Pull request review commentdenoland/deno_std

Added read file str

+// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.++/**+ * Read file synchronously and output it as a string.+ *+ * @param filename File to read+ * @param [encoding="utf-8"] encoding Encoding of the file+ */+export function readFileStrSync(+  filename: string,+  encoding: string = "utf-8"+): string {+  const decoder = new TextDecoder(encoding);+  return decoder.decode(Deno.readFileSync(filename));+}++/**+ * Read file and output it as a string.+ *+ * @param filename File to read+ * @param [encoding="utf-8"] Encoding of the file+ */+export async function readFileStr(

May be confusing with the Deno.readFile no?

zekth

comment created time in 6 days

push eventzekth/deno_std

Vincent LE GOFF

commit sha af6f648db9a490a3b4f867b30a87d89e28cc3de6

quote fix

view details

push time in 6 days

push eventzekth/deno_std

Vincent LE GOFF

commit sha 7556cbb54cdc0f3ae887f76b8871368d78252206

jsdoc default fix

view details

push time in 6 days

push eventzekth/deno_std

Vincent LE GOFF

commit sha 6b47cb06c814ca1b7a12395370e31a1134a7744c

jsdoc default fix

view details

push time in 6 days

Pull request review commentdenoland/deno_std

Added read file str

+// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.++/**+ * Read file synchronously and output it as a string.+ *+ * @param filename File to read+ * @param encoding Encoding of the file. Default = "utf-8"

JSDoc supports defaults Without the type definition? Thought it was needed due to my linter. My bad. About the undefined value, it may be better to have the default in the jsdoc instead of using implicit default for automatic API documentation. Don't you think?

zekth

comment created time in 6 days

push eventzekth/deno_std

Vincent LE GOFF

commit sha af497c4f67741e821f235bb37a3259ba96a7cf80

add default

view details

push time in 6 days

pull request commentdenoland/deno_std

Added read file str

How about defaulting encoding to utf-8?

Definitely legit.

zekth

comment created time in 6 days

more