### Package Structure Example Source: https://github.com/denoland/std/blob/main/AGENTS.md Illustrates the standard directory structure for each package within the Deno Standard Library. ```plaintext / ├── deno.json # Name (@std/), version, exports ├── mod.ts # Public entry point ├── .ts # Implementation (one function/class per file) ├── _test.ts # Tests for the corresponding source file └── unstable_.ts # Experimental APIs (stable packages only) ``` -------------------------------- ### Deprecated API Example Source: https://github.com/denoland/std/blob/main/AGENTS.md Shows the TSDoc format for marking deprecated APIs, including information on removal and alternatives. ```typescript /** * @deprecated This will be removed in X.Y.Z. Use {@linkcode bar} instead. */ ``` -------------------------------- ### PR Title Format Example Source: https://github.com/denoland/std/blob/main/AGENTS.md Demonstrates the required semantic commit message format for Pull Requests, including a package scope. ```plaintext feat(http): add streaming response support fix(csv): handle escaped quotes correctly docs(fmt): update docstrings deprecation(encoding): base32hex ``` -------------------------------- ### Testing Intervals with FakeTime Source: https://github.com/denoland/std/blob/main/testing/README.md This example demonstrates how to test interval functions using FakeTime to control time progression. It asserts that a callback is invoked at expected intervals and stops after clearInterval is called. ```typescript import { assertSpyCalls, spy } from "@std/testing/mock"; import { FakeTime } from "@std/testing/time"; function secondInterval(cb: () => void) { return setInterval(cb, 1000); } Deno.test("secondInterval calls callback every second and stops after being cleared", () => { using time = new FakeTime(); const cb = spy(); const intervalId = secondInterval(cb); assertSpyCalls(cb, 0); time.tick(500); assertSpyCalls(cb, 0); time.tick(500); assertSpyCalls(cb, 1); time.tick(3500); assertSpyCalls(cb, 4); clearInterval(intervalId); time.tick(1000); assertSpyCalls(cb, 4); }); ``` -------------------------------- ### Build Crypto WASM Module Source: https://github.com/denoland/std/blob/main/crypto/_wasm/README.md Run this command to regenerate the WASM files from the Rust source code. This command places the generated files in the `./lib/` directory. ```sh deno task build:crypto ``` -------------------------------- ### Format Bytes to Human-Readable String Source: https://github.com/denoland/std/blob/main/fmt/README.md Use the `format` function from `@std/fmt/bytes` to convert byte counts into human-readable strings with appropriate units (e.g., kB, MB). The output is styled red using `@std/fmt/colors`. ```typescript import { format } from "@std/fmt/bytes"; import { red } from "@std/fmt/colors"; console.log(red(format(1337))); // Prints "1.34 kB" ``` -------------------------------- ### Generate Root Certificate Authority (CA) Source: https://github.com/denoland/std/blob/main/http/testdata/tls/README.md Creates a self-signed root CA certificate and private key. This CA will be used to sign other certificates. ```shell openssl req -x509 -nodes -new -sha256 -days 36135 -newkey rsa:2048 -keyout RootCA.key -out RootCA.pem -subj "/C=US/CN=Example-Root-CA" openssl x509 -outform pem -in RootCA.pem -out RootCA.crt ``` -------------------------------- ### Badge Markdown for Deno Standard Library Source: https://github.com/denoland/std/blob/main/README.md This Markdown snippet can be used to display a badge indicating a project is built with the Deno Standard Library. It links to the JSR package page. ```markdown [![Built with the Deno Standard Library](https://img.shields.io/badge/Built_with_std-black?logo=deno)](https://jsr.io/@std) ``` -------------------------------- ### Configure Domain Names for Certificate Source: https://github.com/denoland/std/blob/main/http/testdata/tls/README.md Defines the domain names that will be included in the certificate's Subject Alternative Name (SAN) field. This file is used by OpenSSL during certificate generation. ```text authorityKeyIdentifier=keyid,issuer basicConstraints=CA:FALSE keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment subjectAltName = @alt_names [alt_names] DNS.1 = localhost ``` -------------------------------- ### Generate Domain Certificate Signed by Root CA Source: https://github.com/denoland/std/blob/main/http/testdata/tls/README.md Generates a private key, a Certificate Signing Request (CSR), and finally a domain certificate signed by the previously created Root CA. It uses the domain configuration file for Subject Alternative Names. ```shell openssl req -new -nodes -newkey rsa:2048 -keyout localhost.key -out localhost.csr -subj "/C=US/ST=YourState/L=YourCity/O=Example-Certificates/CN=localhost.local" openssl x509 -req -sha256 -days 36135 -in localhost.csr -CA RootCA.pem -CAkey RootCA.key -CAcreateserial -extfile domains.txt -out localhost.crt ``` -------------------------------- ### Badge SVG for Deno Standard Library Source: https://github.com/denoland/std/blob/main/README.md This HTML snippet can be used to display a badge indicating a project is built with the Deno Standard Library. It links to the JSR package page. ```html Built with the Deno Standard Library ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.