Skip to content

Commit

Permalink
fix: usage examples (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Shaw authored Jul 10, 2021
1 parent 03bde7e commit 0f5c23b
Showing 1 changed file with 6 additions and 21 deletions.
27 changes: 6 additions & 21 deletions packages/client/src/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
*
* @example
* ```js
* import { Web3Storage, Blob } from "web3.storage"
* import { Web3Storage, File } from 'web3.storage'
* const client = new Web3Storage({ token: API_TOKEN })
*
* const cid = await client.storeBlob(new Blob(['hello world']))
* const cid = await client.put([new File(['hello world'], 'hello.txt', { type: 'text/plain' })])
* ```
* @module
*/
Expand Down Expand Up @@ -40,20 +40,8 @@ class Web3Storage {
*
* @example
* ```js
* import { Web3Storage, Blob } from "web3.storage"
* import { Web3Storage } from 'web3.storage'
* const client = new Web3Storage({ token: API_TOKEN })
* const { car, rootCid } = await client.pack(new Blob(['hello world']))
* const cid = await client.store(car)
* console.assert(cid === rootCid, 'The service should store the files with the `rootCid` I created')
* ```
* Optionally you could pass an alternative API endpoint (e.g. for testing)
* @example
* ```js
* import { Web3Storage } from "web3.storage"
* const client = new Web3Storage({
* token: API_TOKEN
* endpoint: new URL('http://localhost:8080/')
* })
* ```
*
* @param {{token: string, endpoint?:URL}} options
Expand Down Expand Up @@ -208,10 +196,8 @@ class Web3Storage {
*
* @example
* ```js
* const data = 'Hello world'
* const {root, car} = client.pack('Hello world')
* const cid = await client.store(car)
* console.assert(cid === root)
* const file = new File(['hello world'], 'hello.txt', { type: 'text/plain' })
* const cid = await client.put([file])
* ```
* @param {Iterable<API.Filelike>} files
* @param {API.PutOptions} [options]
Expand All @@ -221,15 +207,14 @@ class Web3Storage {
}

/**
* Fetch the Content Addressed Archive by it's root CID
* Fetch the Content Addressed Archive by it's root CID.
* @param {string} cid
*/
get(cid) {
return Web3Storage.get(this, cid)
}

/**
*
* @param {string} cid
*/
/* c8 ignore next 3 */
Expand Down

0 comments on commit 0f5c23b

Please sign in to comment.