From b75e89ce043d9eb4478ff42bbd7e5ed364bb9ec5 Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Fri, 11 Jun 2021 11:21:42 +0200 Subject: [PATCH] chore: update form data docs --- blob/Readme.md | 14 ++++---- form-data/Readme.md | 75 +++++++----------------------------------- form-data/package.json | 6 ++-- 3 files changed, 22 insertions(+), 73 deletions(-) diff --git a/blob/Readme.md b/blob/Readme.md index b108987..7ed876f 100644 --- a/blob/Readme.md +++ b/blob/Readme.md @@ -11,16 +11,16 @@ Web API compatible [Blob][] for nodejs. #### [fetch-blob][] The reason this library exists is because [fetch-blob][] chooses to compromise -Web API compatibility of [`blob.stream()`][w3c blob.stream] by useing nodejs +Web API compatibility of [`blob.stream()`][w3c blob.stream] by using nodejs native [Readable][] stream. We found this to be problematic when sharing code -across nodejs and browser rutimes. Instead this library stays true to the +across nodejs and browser runtimes. Instead this library stays true to the specification by using [ReadableStream][] implementation from [web-streams-polyfill][] -library even if that is less convinient in nodejs context. +library even if that is less convenient in nodejs context. > Note: Both node [Readable][] streams and web [ReadableStream][] implement -> `AsyncIterable` intreface and in theory either could be used with [for await][] +> `AsyncIterable` interface and in theory either could be used with [for await][] > loops. In practice however major browsers do not yet ship `AsyncIterable` -> support for [ReadableStream][]s wich in our experience makes choice made by +> support for [ReadableStream][]s which in our experience makes choice made by > [node-fetch][] impractical. [fetch-blob][] is build around node [Buffer][]s. This implementation is built @@ -45,8 +45,8 @@ for await (const chunk of blob.stream()) { ### Usage from Typescript This library makes use of [typescript using JSDOC annotations][ts-jsdoc] and -also generates type difinitions along with typed definition maps. So you should -be able to get all the type innference out of the box. +also generates type definitions along with typed definition maps. So you should +be able to get all the type inference out of the box. ## Install diff --git a/form-data/Readme.md b/form-data/Readme.md index b108987..da1171a 100644 --- a/form-data/Readme.md +++ b/form-data/Readme.md @@ -1,74 +1,23 @@ -# @web-std/blob +# @web-std/form-data ![Node.js CI][node.js ci] [![package][version.icon] ![downloads][downloads.icon]][package.url] [![styled with prettier][prettier.icon]][prettier.url] -Web API compatible [Blob][] for nodejs. - -## Comparison to Alternatives - -#### [fetch-blob][] - -The reason this library exists is because [fetch-blob][] chooses to compromise -Web API compatibility of [`blob.stream()`][w3c blob.stream] by useing nodejs -native [Readable][] stream. We found this to be problematic when sharing code -across nodejs and browser rutimes. Instead this library stays true to the -specification by using [ReadableStream][] implementation from [web-streams-polyfill][] -library even if that is less convinient in nodejs context. - -> Note: Both node [Readable][] streams and web [ReadableStream][] implement -> `AsyncIterable` intreface and in theory either could be used with [for await][] -> loops. In practice however major browsers do not yet ship `AsyncIterable` -> support for [ReadableStream][]s wich in our experience makes choice made by -> [node-fetch][] impractical. - -[fetch-blob][] is build around node [Buffer][]s. This implementation is built -around standard [Uint8Array][]s. - -[fetch-blob] chooses to use [WeakMap][]s for encapsulating private state. This -library chooses to use to use properties with names that start with `_`. While -those properties aren't truly private they do have better performance profile -and make it possible to interop with this library, which we found impossible -to do with [node-fetch][]. - -### Usage - -```js -import { Blob } from "@web-std/blob" -const blob = new Blob(["hello", new TextEncoder().encode("world")]) -for await (const chunk of blob.stream()) { - console.log(chunk) -} -``` - -### Usage from Typescript - -This library makes use of [typescript using JSDOC annotations][ts-jsdoc] and -also generates type difinitions along with typed definition maps. So you should -be able to get all the type innference out of the box. +Web API compatible [FormData][] for nodejs. ## Install - npm install @web-std/blob +```sh +npm install @web-std/form-data +``` -[node.js ci]: https://github.com/web-std/blob/workflows/Node.js%20CI/badge.svg -[version.icon]: https://img.shields.io/npm/v/@web-std/blob.svg -[downloads.icon]: https://img.shields.io/npm/dm/@web-std/blob.svg -[package.url]: https://npmjs.org/package/@web-std/blob -[downloads.image]: https://img.shields.io/npm/dm/@web-std/blob.svg -[downloads.url]: https://npmjs.org/package/@web-std/blob +[node.js ci]: https://github.com/web-std/io/workflows/Node.js%20CI/badge.svg +[version.icon]: https://img.shields.io/npm/v/@web-std/form-data.svg +[downloads.icon]: https://img.shields.io/npm/dm/@web-std/form-data.svg +[package.url]: https://npmjs.org/package/@web-std/form-data +[downloads.image]: https://img.shields.io/npm/dm/@web-std/form-data.svg +[downloads.url]: https://npmjs.org/package/@web-std/form-data [prettier.icon]: https://img.shields.io/badge/styled_with-prettier-ff69b4.svg [prettier.url]: https://github.com/prettier/prettier -[blob]: https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob -[fetch-blob]: https://github.com/node-fetch/fetch-blob -[readablestream]: https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream -[readable]: https://nodejs.org/api/stream.html#stream_readable_streams -[w3c blob.stream]: https://w3c.github.io/FileAPI/#dom-blob-stream -[web-streams-polyfill]:https://www.npmjs.com/package/web-streams-polyfill -[for await]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of -[buffer]: https://nodejs.org/api/buffer.html -[weakmap]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap -[ts-jsdoc]: https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html -[Uint8Array]:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array -[node-fetch]:https://github.com/node-fetch/ +[FormData]: https://developer.mozilla.org/en-US/docs/Web/API/FormData diff --git a/form-data/package.json b/form-data/package.json index 5c16a78..d091253 100644 --- a/form-data/package.json +++ b/form-data/package.json @@ -1,9 +1,9 @@ { "name": "@web-std/form-data", "version": "2.1.0", - "description": "Web API compatible Blob implementation", + "description": "Web API compatible Form Data implementation", "keywords": [ - "blob", + "formdata", "typed" ], "type": "module", @@ -25,7 +25,7 @@ "web-streams-polyfill": "3.0.3" }, "author": "Irakli Gozalishvili (https://gozala.io)", - "repository": "https://github.com/web-std/blob", + "repository": "https://github.com/web-std/io", "license": "MIT", "devDependencies": { "@types/node": "15.0.2",