Skip to content

Commit

Permalink
Merge pull request #5 from vasco-santos/chore/update-form-data-docs
Browse files Browse the repository at this point in the history
chore: update form data docs
  • Loading branch information
Gozala authored Jun 14, 2021
2 parents a9d76fc + b75e89c commit 68e89a8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 73 deletions.
14 changes: 7 additions & 7 deletions blob/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
75 changes: 12 additions & 63 deletions form-data/Readme.md
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions form-data/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -25,7 +25,7 @@
"web-streams-polyfill": "3.0.3"
},
"author": "Irakli Gozalishvili <[email protected]> (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",
Expand Down

0 comments on commit 68e89a8

Please sign in to comment.