deno_std
#oss
Refs
https://github.com/denoland/deno_std/pulls?q=is%3Apr+author%3Aayame113+is%3Aclosed
https://qiita.com/kt3k
Denoの開発環境をVSCodeで作る
deno_stdとは?
Node.js における設計ミス By Ryan Dahl
平凡なエンジニアがDenoにコントリビュートするためにやったこと
Deno に“守り”のコントリビュートをしてきた話
https://deno.land/manual/contributing/style_guide
スタイルガイド
test(node): Enable more native node tests
https://github.com/denoland/deno_std/blob/main/node/README.md#setting-up-the-test-runner
code: zsh
deno test -A --unstable node/_tools/test.ts -- test-fs-read-zero-length.js
collections APIs
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/
Kotlinの配列ドキュメント
https://github.com/denoland/deno_std/pull/1309#discussion_r716338709
nit: We prefer the format of TODO(username):
https://deno-ja.slack.com/archives/CF7KLU413/p1633255616154600
Ryan の肝いりで node compatibility mode というのを入れる作業が始まりました https://github.com/denoland/deno/pull/12293
deno run --compat foo.mjs
という実行の仕方をすると bare import が node_modules 以下を見るようになるようです https://github.com/denoland/deno/issues/12295
Deno v1.15で導入されたNode.js互換モードについて
次の目玉
https://github.com/denoland/deno_std/issues/1525
findLastがV8に実装された
https://discord.com/channels/684898665143206084/775393009981849600/908069664544940052
V8使ってるやつどするかの議論
Hello! I was working on issue 662 for implementing isDeepStrictEqual in node/util and in the node implementation a getOwnNonIndexProperties is used from the node-bindings, is there an equivalent that can used? Or is there a way to recreate the logic in typescript without having to use Rust as I didn't fully understand what was being done in their C code with them using a v8::IndexFilter.
i think IndexFilter is just an enum
but youd probably have to recreate the behaviour in ts
okay thanks. I have started to implement it, do you think something like this would be able to do get the results?
I see that this is primarily being used for 2 cases, when the comparison is to be done for either value being
1. Array or 2. ArrayBuffers
I guess the best way would be to finish this and check it against the test cases once, else I'll just end up taking up too much time pre-emptively. However, if you do see something glaringly wrong here please do give a shout out.
Simulating the behavior in typescript is a good idea. We actually don't touch V8 APIs directly in std/node
https://github.com/denoland/deno_std/issues/662#issuecomment-966398933
https://scrapbox.io/files/618c5fcf1a0a1e001e755e40.png
code: ts
function getOwnNonIndexProperties(obj: { unknown: unknown }): string[] {
if (Array.isArray(obj)) return [];
// Object.keys(SET) will return an empty array for sets as well as weaksets
// Object.keys(MAP) will return an empty array for sets as well as weakmaps
return Object.keys(obj);
}
Denoでサーバーを建てる方法 2021年11月版
JavaScript の Object.hasOwn について
code: check.ts
import { config } from "./common.ts";
const tests = []
for await (const entry of Deno.readDir('node/_tools/versions/node-v18.8.0/test/parallel')) {
if (entry.name.includes("test-fs") && !config.tests.parallel.includes(entry.name)) {
tests.push(entry.name)
}
}
console.log(tests.sort())
code: zsh
deno run -A ./node/_tools/check.ts
https://github.com/denoland/deno_std/blob/main/node/_tools/TODO.md
issue
https://github.com/denoland/deno_std/issues/3489#issuecomment-1677724835
issue
BREAKING(testing/snapshot): change tab char serialization
snapshotのtab
issue
style(testing/snapshot): distinguish between singular and plural forms
snapshots -> snapshot
$ deno test --allow-all --unstable ./snapshot_test.ts -- -u
issue
refactor(testing): remove unnecessary context processing in snapshot teardown
feat(testing): report the number of removed snapshots
code: .ts
// ここでキューに入らない
assertSnapshotContext.pushSnapshotToUpdateQueue(name);
currentSnapshots.set(snapshotName, undefined);
"assertSnapshot" should add support for wildcards
assertSnapshot should report the number of snapshots removed
https://github.com/denoland/deno_std/pull/2179
だいぶ変わった
issue
code: zsh
------- output -------
{
value: { name: "empty", isFile: true, isDirectory: false, isSymlink: false },
done: false
}
issue
docs: give more detailed description/reasoning/alternative suggestions for the deprecation of fs.exists
issue
code: zsh
$$$$$$$$$$$$ empty
$$$$$$$$$$$$ files
$$$$$$$$$$$$ for
$$$$$$$$$$$$ just
$$$$$$$$$$$$ testing
########################
empty ==================
just ==================
code: fs-readdir-types.js
// Create the necessary files
files.forEach(function(currentFile) {
console.log("$$$$$$$$$$$$", currentFile)
fs.closeSync(fs.openSync(${readdirDir}/${currentFile}, 'w'));
});
function assertDirents(dirents) {
assert.strictEqual(files.length, dirents.length);
console.log("########################")
for (const i, dirent of dirents.entries()) {
console.log(dirent.name, "==================")
assert(dirent instanceof fs.Dirent);
assert.strictEqual(dirent.name, filesi);
assert.strictEqual(dirent.isFile(), true);
assert.strictEqual(dirent.isDirectory(), false);
// assert.strictEqual(dirent.isSocket(), false);
// assert.strictEqual(dirent.isBlockDevice(), false);
// assert.strictEqual(dirent.isCharacterDevice(), false);
// assert.strictEqual(dirent.isFIFO(), false);
assert.strictEqual(dirent.isSymbolicLink(), false);
}
}
// Check the readdir Sync version
assertDirents(fs.readdirSync(readdirDir, { withFileTypes: true }));
issue
TODO: Also accept 'path' parameter as a Node polyfill Buffer type once these are implemented
Add Node.js native module polyfills to std/node
issue
chore(node/querystring): Add test case for escape
Add node querystring polyfill によって足されている
TODO: sep = "&",eq = "="はoptionではないのか?
nodeだから関係ないわ
issue
TODO: _fs_chown.ts引数
issue
chore(node/_util): Remove any from _util_callbackify.ts
TypeScript: オーバーロードメソッドを定義する方法
TypeScript の「オーバーロード」について
issue
code: ts
const clones: Tuple<AsyncIterableClone<T>, N> = Array.from({ length: n }).map(
() => new AsyncIterableClone(),
// deno-lint-ignore no-explicit-any
) as any;
issue
deep_assign.ts
): // deno-lint-ignore ban-types
issue
https://github.com/denoland/deno_std/blob/main/node/url_test.ts
テストがほとんどない
node/test/parallel
TODO: chore(node/querystring): Add test case for escapeも合わせる
https://github.com/denoland/deno_std/pull/1309/checks?check_run_id=3706884575#step:4:4122
Windowsで落ちる
issue
feat(std/node): add os.tmpdir() implementation
参考
Support missing OS functionality(Deno本体) が実装できたら
issueもdenoだった
feat(std/node): Add back os.tmpdir() implementation
2021/9/25
issue
feat(collections/running_reduce): Change initialValue to optional
feat (collections): add runningReduce
配列追加
https://github.com/denoland/deno_std/pull/1311/checks?check_run_id=3708136691
README.mdにもテストが走る
issue
テストisWindowsはignoreとonlyでいけないか
_fs_writeFile_test.ts if (isWindows) return;
https://deno.land/manual@v1.7.5/testing#test-definition-filtering
issue
issue & PR テンプレート
issueテンプレートでコメントにしたほうがいい箇所がある
$ deno --versionもつけたほうが良い
やってくれた
issue
permissions/test.ts: 例外とファイル名
https://github.com/denoland/deno_std/pull/1314#discussion_r716176999
Deno.permissions.requestはdenoに飛んでいる
issue
https://github.com/denoland/deno_std/blob/main/collections/README.md#usage
目次つける
https://github.com/jamiebuilds/babel-handbook/pull/239/files
https://github.blog/changelog/2021-04-13-table-of-contents-support-in-markdown-files/
これがあるが...ってのも
アルファベット順
TODO: Contributing.md https://github.com/denoland/deno_std/discussions/970
BRANCH: collection-doc
issue立てる?
TODO: sumOfのREADME.md: https://github.com/denoland/deno_std/pull/1108/files
TODO: Exampleとセミコロン
issue
nodeテストの自動生成
code: zsh
~/desktop/deno_std
$ deno run --allow-read --allow-net --allow-write node/_tools/setup.ts
Check file:///Users/tagawahirotaka/Desktop/deno_std/node/_tools/setup.ts
Downloading https://nodejs.org/dist/v17.0.0/node-v17.0.0.tar.gz in path "versions/node-v17.0.0.tar.gz" ...
Downloaded: https://nodejs.org/dist/v17.0.0/node-v17.0.0.tar.gz into versions/node-v17.0.0.tar.gz
Decompressing node-v17.0.0.tar.gz...
Cleaning up previous tests
Copying test files...
TODO: setup.ts complited!! とか欲しい
issue
TODO: assertThrowsAsync 非推奨がserver_test.tsで使われている
https://github.com/denoland/deno_std/pull/1314#discussion_r716341374
issue
deno_std#6151bf2fb96bbf00006b0aa8 ドキュメント化/通らない
code: zsh
$ deno upgrade
Looking up latest version
Found latest version 1.14.1
Checking https://github.com/denoland/deno/releases/download/v1.14.1/deno-x86_64-apple-darwin.zip
28.5 MiB / 28.5 MiB (100.0%)
Deno is upgrading to version 1.14.1
Archive: /var/folders/h0/n4dr2mwn6vqbtk9y1zrcykd80000gn/T/.tmpqgtdvu/deno.zip
inflating: deno
Upgraded successfully
issue
chore(node/tools/setup): Make sure filenames are in the correct order before setting up
config.jsonの順番をテストする
code: setup.ts
console.log(config)
{
nodeVersion: "15.5.1",
ignore: { common: "index.js" , parallel: "test-assert.js", "test-assert-async.js" },
tests: {
parallel: [
"test-assert.js",
"test-assert-async.js",
"test-assert-fail.js",
...
"test-util-inherits.js"
]
},
suitesFolder: "suites",
versionsFolder: "versions"
}
issue
chore(node/_tools/test): Add --only flag to run specific tests
code: zsh
$ deno test --allow-read --allow-run node/_tools/test.ts
Check file:///Users/tagawahirotaka/Desktop/deno_std/node/_tools/test.ts
running 21 tests from file:///Users/tagawahirotaka/Desktop/deno_std/node/_tools/test.ts
test suites/parallel/test-assert-fail.js ... ok (5236ms)
test suites/parallel/test-event-emitter-invalid-listener.js ... ok (376ms)
↑ testsFolder
code: zsh
console.log(testList, 'testList');
[
/parallel\/test-assert-async.js/,
/parallel\/test-assert-fail.js/,
/parallel\/test-assert.js/,
/parallel\/test-event-emitter-add-listeners.js --only/,
/parallel\/test-event-emitter-check-listener-leaks.js/,
/parallel\/test-util-i
]
[- TODO: -- ignoreも]
issue
chore(node/url): Add tests for fileURLToPath and pathToFileURL
FYI we also have an infrastructure for running actual node.js test cases under node/_tools. (Modify node/_tools/config.json and run node/_tools/setup.ts, then it will enable the test cases listed in config.json)
fix(node/events): Accept only functions as listener arguments
ERR_INVALID_ARG_TYPEの実装例
issue
test(node/url): Enable test-url-fileurltopath.js
Node.js test cases are usually more exhaustive than ours. So if native Node.js test cases are enabled, then we don't need our own version of test cases anymore.
issue
fix(node/url): Use Class defined in node/_error.ts to throw exception
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_OR
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_OR
// todo(wafuwafu13) Add Windows and invalid caseも削除したい
どのみち通ってしまっている
code:js
if (isWindows) {
assert.throws(() => url.fileURLToPath('file:///C:/a%2F/'), {
code: 'ERR_INVALID_FILE_URL_PATH'
});
プロダクトコードのisWindowsを調整しないといけない
issue
feat(node/_error): Implement ERR_INVALID_URL_SCHEME
TODO(wafuwafu13): implement ERR_INVALID_URL_SCHEME
https://github.com/denoland/deno_std/pull/1355#issuecomment-935845408
I don't know why Generate locv is failing 😓
issue
test(node/url): Enable test-url-pathtofileurl.js
https://hg.mozilla.org/releases/mozilla-release/rev/2cd83ad751203f5f91b1a1411fb930be9bff18c1#l1.13
const StringPrototypeStartsWith = String.prototype.startsWith;
https://github.com/denoland/deno_std/runs/3825482785#step:4:418
node/tools/test通ってる
issue
feat(node/url): Add support for UNC path
issue
feat(collections/running_reduce): Support currentIndex
これは冗長
code: typescript
export function runningReduce<T, O>(
array: readonly T[],
reducer: (accumulator: O, current: T, index?: O) => O,
initialValue: O,
): O[] {
let currentResult = initialValue;
return reducer.length === 3
? array.map((el, index) =>
currentResult = reducer(currentResult, el, index as unknown as O)
)
: array.map((el) => currentResult = reducer(currentResult, el));
}
issue
TODO: isWindowsでプロダクトコードもisWindowsになる仕組み
issue
feat(node): Add dns and net modules 対応
chore(node/_tools): Set up with Node v15.5.1
test-net-write-callbacks.jsがログいっぱいのやつ
code: js
// const N = 500000;
const N = 50000;
chore(node/_tools): Respond to added tests
code: zsh
$ git checkout main
$ git fetch upstream
$ git merge upstream/main
$ git checkout repond-tests
$ git merge origin main
なぜか手元にある
code: zsh
deleted: node/_tools/suites/common/dns.js
deleted: node/_tools/suites/common/internet.js
これが原因で落ちる
test suites/internet/test-dns-ipv4.js ...error: Uncaught Error: Cannot find module '../common/internet'
https://github.com/denoland/deno_std/tree/main/node/_tools/suites/common にある => TODO: 追加
test-net-reconnect.jsが新たに生成されている
config.jsonには追加時、現在もある
ファイル自体は手元、リモートにないので操作ミスっぽい? => TODO: 削除
https://github.com/denoland/deno_std/pull/1375/files#diff-1e332023c25d6347d610343825902ed180e0f55524d7b26e7d44d010b0653c48R115
test-net-timeout.jsが消されてる => TODO: 追加
TODO: ドキュメント(issueの存在、トラブルシューテぃング)
issue
どのテストが実装されていないか
code: typescript
import { config } from "./common.ts";
for await (const entry of Deno.readDir('node/_tools/versions/node-v15.5.1/test/parallel')) {
if (entry.name.includes("test-net") && !config.tests.parallel.includes(entry.name)) {
console.log(entry.name);
}
}
ディレクトリ名 + プレフィックス
https://github.com/nodejs/node/blob/master/doc/guides/writing-tests.md#naming-test-files
なかったものの例
code: text
test-net-better-error-messages-listen-path
test-net-better-error-messages-path
test-net-binary
test-net-bytes-read
test-net-connect-bind-twice
test-net-connect-memleak
test-net-connect-options-allowhalfopen
issue
config.tests 以降の補完
issue
Add "format" to "node/url"
https://cercopes-z.com/JSDoc/tags-param-jsdoc.html
fix(op_crate/web): Add padding on URLSearchParam
issue
feat(node/url): Add url.urlToHttpOptions(url)
https://stackoverflow.com/questions/28763257/jsdoc-return-object-structure
issue
querystring実装していくかどうか
TypeError: Cannot read properties of undefined (reading 'split') から対応を始める
issue
TODO: setup時に要らないtagzやつ消すかどうか
issue
feat(node): add readline module
依存関係でトラブってる
issue
code: zsh
test suites/parallel/test-net-listen-close-server-callback-is-not-function.js ...error: TS2339 ERROR: Property 'addSignalListener' does not exist on type 'typeof Deno'.
Deno.addSignalListener(event as Deno.Signal, listener);
~~~~~~~~~~~~~~~~~
at file:///Users/tagawahirotaka/Desktop/deno_std/node/process.ts:382:12
https://github.com/denoland/deno_std/pull/1466/files
test result: FAILED. 1 passed; 110 failed; 0 ignored; 0 measured; 0 filtered out (839474ms)
https://github.com/denoland/deno/pull/12512
LGTM too, I like this API better; it will be useful for std/node
unsteableフラグ?
https://deno-ja.vercel.app/manual@v1.6.3/runtime/stability
code: zsh
~/desktop/deno_std
$ git submodule update --init
Submodule 'std/wasi/testdata' (https://github.com/khronosproject/wasi-test-suite.git) registered for path 'wasi/testdata'
Cloning into '/Users/tagawahirotaka/Desktop/deno_std/wasi/testdata'...
remote: Enumerating objects: 355, done.
remote: Counting objects: 100% (355/355), done.
remote: Compressing objects: 100% (70/70), done.
remote: Total 313 (delta 253), reused 284 (delta 225), pack-reused 0
Receiving objects: 100% (313/313), 8.02 MiB | 5.10 MiB/s, done.
Resolving deltas: 100% (253/253), completed with 3 local objects.
From https://github.com/khronosproject/wasi-test-suite
* branch aa121de88de512680fe5752f0e9bfc07e311854c -> FETCH_HEAD
Submodule path 'wasi/testdata': checked out 'aa121de88de512680fe5752f0e9bfc07e311854c'
https://github.com/denoland/deno_std/pull/1453#discussion_r735095698
https://github.com/denoland/deno/pull/12512#issuecomment-951161858
issue
process.tsのversion
issue
processの理解
30_fs.js function cwd()
issue
そもそもオーバーライド必要なくね?
オプションで指定できるしそうするべき
https://nodejs.org/api/querystring.html#querystringunescapestr
issue
これみたいに仕切りあったらいいね
混乱を生む
https://github.com/denoland/deno_std/blob/main/testing/fast_check_example.ts
issue
エラー判定されないやつ
code: zsh
test-net-write-connect-write.js
test-stream-readable-add-chunk-during-data.js
test-stream-writable-end-cb-error.js
test suites/parallel/test-net-connect-buffer2.js
issue
https://github.com/denoland/deno_std/pull/1507
Bufferの破壊的変更
issue
補完効いて欲しい
base = Number.isNaN(value.getTime()) ?
issue
inspectバグ拾い
code: js
// TODO(wafuwafu13): Implement correctly (faild test in 59~)
let type = "Function";
if (types.isGeneratorFunction(value)) {
type = Generator${type};
}
typesから攻めていくか...
https://github.com/denoland/deno_std/pull/1632/files がマージされたら
util.inspect.defaultOptions = null;
export function toPathIfFileURL(fileURLOrPath: string | URL) {のFix
issue
primodialブランチ作ってる
util-logブランチ作ってる
issue
https://github.com/denoland/deno_std/pull/1791#issuecomment-1008267370
import/exportデバッグ
issue
code: check.ts
import { config } from "./common.ts";
const tests = []
for await (const entry of Deno.readDir('node/_tools/versions/node-v16.13.0/test/parallel')) {
if (entry.name.includes("test-fs") && !config.tests.parallel.includes(entry.name)) {
tests.push(entry.name)
}
}
console.log(tests.sort())
code: zsh
[
"test-fs-assert-encoding-error.js",
"test-fs-buffer.js",
"test-fs-buffertype-writesync.js",
"test-fs-close-errors.js",
"test-fs-close.js",
"test-fs-copyfile-respect-permissions.js",
"test-fs-cp.mjs",
"test-fs-empty-readStream.js",
"test-fs-error-messages.js",
"test-fs-exists.js",
"test-fs-existssync-false.js",
"test-fs-fchmod.js",
"test-fs-fchown.js",
"test-fs-filehandle-use-after-close.js",
"test-fs-filehandle.js",
"test-fs-fmap.js",
"test-fs-fsync.js",
"test-fs-lchmod.js",
"test-fs-lchown.js",
"test-fs-link.js",
"test-fs-long-path.js",
"test-fs-make-callback.js",
"test-fs-makeStatsCallback.js",
"test-fs-mkdir-mode-mask.js",
"test-fs-mkdir-recursive-eaccess.js",
"test-fs-mkdir-rmdir.js",
"test-fs-mkdir.js",
"test-fs-mkdtemp-prefix-check.js",
"test-fs-mkdtemp.js",
"test-fs-non-number-arguments-throw.js",
"test-fs-null-bytes.js",
"test-fs-open-flags.js",
"test-fs-open-mode-mask.js",
"test-fs-open-no-close.js",
"test-fs-open-numeric-flags.js",
"test-fs-open.js",
"test-fs-opendir.js",
"test-fs-options-immutable.js",
"test-fs-promises-exists.js",
"test-fs-promises-file-handle-append-file.js",
"test-fs-promises-file-handle-chmod.js",
"test-fs-promises-file-handle-close.js",
"test-fs-promises-file-handle-read-worker.js",
"test-fs-promises-file-handle-read.js",
"test-fs-promises-file-handle-readFile.js",
"test-fs-promises-file-handle-stat.js",
"test-fs-promises-file-handle-stream.js",
"test-fs-promises-file-handle-sync.js",
"test-fs-promises-file-handle-truncate.js",
"test-fs-promises-file-handle-write.js",
"test-fs-promises-file-handle-writeFile.js",
"test-fs-promises-readfile-empty.js",
"test-fs-promises-readfile-with-fd.js",
"test-fs-promises-readfile.js",
"test-fs-promises-watch.js",
"test-fs-promises-writefile-typedarray.js",
"test-fs-promises-writefile-with-fd.js",
"test-fs-promises-writefile.js",
"test-fs-promises.js",
"test-fs-promisified.js",
"test-fs-read-empty-buffer.js",
"test-fs-read-file-assert-encoding.js",
"test-fs-read-file-sync-hostname.js",
"test-fs-read-file-sync.js",
"test-fs-read-offset-null.js",
"test-fs-read-optional-params.js",
"test-fs-read-promises-optional-params.js",
"test-fs-read-stream-autoClose.js",
"test-fs-read-stream-concurrent-reads.js",
"test-fs-read-stream-double-close.js",
"test-fs-read-stream-encoding.js",
"test-fs-read-stream-err.js",
"test-fs-read-stream-fd-leak.js",
"test-fs-read-stream-fd.js",
"test-fs-read-stream-file-handle.js",
"test-fs-read-stream-inherit.js",
"test-fs-read-stream-patch-open.js",
"test-fs-read-stream-pos.js",
"test-fs-read-stream-resume.js",
"test-fs-read-stream-throw-type-error.js",
"test-fs-read-stream.js",
"test-fs-read-type.js",
"test-fs-read-zero-length.js",
"test-fs-read.js",
"test-fs-readSync-optional-params.js",
"test-fs-readdir-buffer.js",
"test-fs-readdir-types.js",
"test-fs-readdir-ucs2.js",
"test-fs-readfile-error.js",
"test-fs-readfile-fd.js",
"test-fs-readfile-flags.js",
"test-fs-readfile-pipe-large.js",
"test-fs-readfile-pipe.js",
"test-fs-readfile-unlink.js",
"test-fs-readfile-zero-byte-liar.js",
"test-fs-readfile.js",
"test-fs-readfilesync-enoent.js",
"test-fs-readfilesync-pipe-large.js",
"test-fs-readlink-type-check.js",
"test-fs-readv-promises.js",
... 70 more items
]