This repository was archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: typedef resolution & add examples that use types #3359
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c455699
fix: typescirpt typedef resolution
Gozala 1dd7b61
addres review comments
Gozala 58fc329
Merge remote-tracking branch 'upstream/master' into gozala/fix-type-p…
Gozala 09a6bcc
chore: align versions
Gozala a6df558
chore: fix typos
achingbrain 84d5b70
chore: rename
achingbrain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "ipfs-from-ts", | ||
"private": true, | ||
"dependencies": { | ||
"ipfs": "^0.50.1" | ||
Gozala marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
"scripts": { | ||
"test": "npx typescript --noEmit" | ||
Gozala marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import IPFS from 'ipfs' | ||
|
||
export default async function main () { | ||
const node = await IPFS.create() | ||
const version = await node.version() | ||
|
||
console.log('Version:', version.version) | ||
|
||
const file = await node.add({ | ||
path: 'hello.txt', | ||
content: new TextEncoder().encode('Hello World 101') | ||
}) | ||
|
||
console.log('Added file:', file.path, file.cid.toString()) | ||
try { | ||
// @ts-expect-error - CID is not a string | ||
file.cid.toUpperCase() | ||
} catch(error) { | ||
|
||
} | ||
|
||
const decoder = new TextDecoder() | ||
let content = '' | ||
for await (const chunk of node.cat(file.cid)) { | ||
content += decoder.decode(chunk) | ||
} | ||
|
||
console.log('Added file contents:', content) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"skipLibCheck": true, | ||
"noImplicitAny": false, | ||
"esModuleInterop": true, | ||
"moduleResolution": "Node", | ||
"noEmit": true | ||
}, | ||
"include": [ | ||
"src" | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "ipfs-from-ts", | ||
Gozala marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"private": true, | ||
"dependencies": { | ||
"ipfs": "^0.50.1" | ||
Gozala marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
"scripts": { | ||
"test": "npx typescript --noEmit" | ||
Gozala marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const IPFS = require('ipfs') | ||
|
||
async function main () { | ||
const node = await IPFS.create() | ||
const version = await node.version() | ||
|
||
console.log('Version:', version.version) | ||
|
||
const file = await node.add({ | ||
path: 'hello.txt', | ||
content: new TextEncoder().encode('Hello World 101') | ||
}) | ||
|
||
console.log('Added file:', file.path, file.cid.toString()) | ||
try { | ||
// @ts-expect-error - CID is not a string | ||
file.cid.toUpperCase() | ||
} catch(error) { | ||
|
||
} | ||
|
||
const decoder = new TextDecoder() | ||
let content = '' | ||
for await (const chunk of node.cat(file.cid)) { | ||
content += decoder.decode(chunk) | ||
} | ||
|
||
console.log('Added file contents:', content) | ||
} | ||
|
||
main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowJs": true, | ||
"checkJs": true, | ||
"strict": true, | ||
"skipLibCheck": true, | ||
"noImplicitAny": false, | ||
"esModuleInterop": true, | ||
"moduleResolution": "Node", | ||
"noEmit": true | ||
}, | ||
"include": [ | ||
"src" | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,8 @@ | |
"typesVersions": { | ||
"*": { | ||
"*": [ | ||
"dist/*" | ||
"dist/*", | ||
"dist/*/index" | ||
] | ||
} | ||
}, | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,8 @@ | |
"typesVersions": { | ||
"*": { | ||
"*": [ | ||
"dist/*" | ||
"dist/*", | ||
"dist/*/index" | ||
] | ||
} | ||
}, | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.