From 10a9b80dbf20c10c6cef0689535ee695c8ed28b2 Mon Sep 17 00:00:00 2001 From: Sven Fehler <38158426+Sv443@users.noreply.github.com> Date: Fri, 24 Jan 2025 20:10:52 +0100 Subject: [PATCH] docs: random stuff I found --- docs.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs.md b/docs.md index 53e789c..c9a9123 100644 --- a/docs.md +++ b/docs.md @@ -4,10 +4,11 @@ ## Preamble: -This library is written in TypeScript and contains builtin TypeScript declarations. +This library is written in TypeScript and contains builtin TypeScript declarations, but it will also work in plain JavaScript after removing the `: type` annotations. Each feature has example code that can be expanded by clicking on the text "Example - click to view". -The signatures and examples are written in TypeScript and use ESM import syntax, but the library can also be used in plain JavaScript after removing the type annotations (and changing the imports if you are using CommonJS or the global declaration). +The signatures and examples are written in TypeScript and use ESM import syntax to show you which types need to be provided and will be returned. +The library itself supports importing an ESM, CommonJS or global variable definition bundle, depending on your use case. If the signature section contains multiple signatures of the function, each occurrence represents an overload and you can choose which one you want to use. They will also be further explained in the description below that section. @@ -1932,8 +1933,10 @@ Signature: autoPlural(str: string, num: number | Array | NodeList): string ``` -Automatically pluralizes a string if the given number is not 1. +Crudely pluralizes a string by appending an `s` if the given number is not 1. If an array or NodeList is passed, the amount of contained items will be used. + +Of course some English words go from `-y` to `-ies`, in which case this function will not work.
Example - click to view @@ -1986,9 +1989,9 @@ fetchAdvanced(input: string | Request | URL, options?: { }): Promise ``` -A drop-in replacement for the native `fetch()` function that adds options like a timeout property. +A drop-in replacement for the native `fetch()` function that adds a timeout property. The timeout will default to 10 seconds if left undefined. Set it to a negative number to disable the timeout. -Pass an [AbortController's signal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) to the `signal` property to be able to abort the request before it finishes or the timeout kicks in. +Pass an [AbortController's signal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) to the `signal` property to be able to abort the request manually in addition to the automatic timeout.
Example - click to view