-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add types #189
feat: add types #189
Changes from 2 commits
354c5c0
86e44e2
1e150b2
d18f06b
77c22b5
a58de4d
6130f82
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
|
||
**To Reproduce** | ||
Steps to reproduce the behavior: | ||
1. Go to '...' | ||
2. Click on '....' | ||
3. Scroll down to '....' | ||
4. See error | ||
|
||
**Expected behavior** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**Screenshots** | ||
If applicable, add screenshots to help explain your problem. | ||
|
||
**Desktop (please complete the following information):** | ||
- OS: [e.g. iOS] | ||
- Browser [e.g. chrome, safari] | ||
- Version [e.g. 22] | ||
|
||
**Smartphone (please complete the following information):** | ||
- Device: [e.g. iPhone6] | ||
- OS: [e.g. iOS8.1] | ||
- Browser [e.g. stock browser, safari] | ||
- Version [e.g. 22] | ||
|
||
**Additional context** | ||
Add any other context about the problem here. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for this project | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Is your feature request related to a problem? Please describe.** | ||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||
|
||
**Describe the solution you'd like** | ||
A clear and concise description of what you want to happen. | ||
|
||
**Describe alternatives you've considered** | ||
A clear and concise description of any alternative solutions or features you've considered. | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the feature request here. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: ci | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: npm install | ||
- run: npx aegir lint | ||
- run: npx aegir ts -p check | ||
- run: npx aegir build | ||
- run: npx aegir dep-check | ||
- uses: ipfs/aegir/actions/bundle-size@master | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
test-node: | ||
needs: check | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [windows-latest, ubuntu-latest, macos-latest] | ||
node: [14, 15] | ||
fail-fast: true | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
- run: npm install | ||
- run: npx aegir test -t node --bail --cov | ||
- uses: codecov/codecov-action@v1 | ||
test-chrome: | ||
needs: check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: microsoft/playwright-github-action@v1 | ||
- run: npm install | ||
- run: npx aegir test -t browser -t webworker --bail --cov | ||
- uses: codecov/codecov-action@v1 | ||
test-firefox: | ||
needs: check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: microsoft/playwright-github-action@v1 | ||
- run: npm install | ||
- run: npx aegir test -t browser -t webworker --bail -- --browser firefox | ||
test-webkit: | ||
needs: check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: microsoft/playwright-github-action@v1 | ||
- run: npm install | ||
- run: npx aegir test -t browser -t webworker --bail -- --browser webkit | ||
test-electron-main: | ||
needs: check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: npm install | ||
- run: npx xvfb-maybe aegir test -t electron-main --bail | ||
test-electron-renderer: | ||
needs: check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: npm install | ||
- run: npx xvfb-maybe aegir test -t electron-renderer --bail |
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -24,10 +24,8 @@ js-multiaddr | |||||
- [Background](#background) | ||||||
- [What is multiaddr?](#what-is-multiaddr) | ||||||
- [Install](#install) | ||||||
- [Setup](#setup) | ||||||
- [Node.js](#nodejs) | ||||||
- [Browser: Browserify, Webpack, other bundlers](#browser-browserify-webpack-other-bundlers) | ||||||
- [Browser: `<script>` Tag](#browser-script-tag) | ||||||
- [NPM](#npm) | ||||||
- [Browser: `<script>` Tag](#browser-script-tag) | ||||||
- [Usage](#usage) | ||||||
- [API](#api) | ||||||
- [Resolvers](#resolvers) | ||||||
|
@@ -48,30 +46,12 @@ A standard way to represent addresses that | |||||
|
||||||
## Install | ||||||
|
||||||
### NPM | ||||||
```sh | ||||||
npm i multiaddr | ||||||
``` | ||||||
|
||||||
### Setup | ||||||
|
||||||
#### Node.js | ||||||
|
||||||
```js | ||||||
const multiaddr = require('multiaddr') | ||||||
``` | ||||||
|
||||||
#### Browser: Browserify, Webpack, other bundlers | ||||||
|
||||||
The code published to npm that gets loaded on require is in fact a ES5 | ||||||
transpiled version with the right shims added. This means that you can require | ||||||
it and use with your favourite bundler without having to adjust asset management | ||||||
process. | ||||||
|
||||||
```js | ||||||
const multiaddr = require('multiaddr') | ||||||
``` | ||||||
|
||||||
#### Browser: `<script>` Tag | ||||||
### Browser: `<script>` Tag | ||||||
|
||||||
Loading this module through a script tag will make the `Multiaddr` obj available in | ||||||
the global namespace. | ||||||
|
@@ -85,7 +65,7 @@ the global namespace. | |||||
```js | ||||||
$ node | ||||||
|
||||||
> const multiaddr = require('multiaddr') | ||||||
> const { multiaddr } = require('multiaddr') | ||||||
|
||||||
> const addr = multiaddr("/ip4/127.0.0.1/udp/1234") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there a factory method exported There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, but all the other code examples in jsdocs are with the constructor, why having these different? I also thought we were going to migrate into using the class instance in the future There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the factory method returns an instance, its just an helper i will add an example of both |
||||||
<Multiaddr /ip4/127.0.0.1/udp/1234> | ||||||
|
@@ -105,7 +85,7 @@ $ node | |||||
// gives you an object that is friendly with what Node.js core modules expect for addresses | ||||||
> addr.nodeAddress() | ||||||
{ | ||||||
family: "4", | ||||||
family: 4, | ||||||
port: 1234, | ||||||
address: "127.0.0.1" | ||||||
} | ||||||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,29 @@ | ||
'use strict' | ||
|
||
var multiaddr = require('../src') | ||
var log = console.log | ||
const { Multiaddr } = require('../src') | ||
// eslint-disable-next-line no-console | ||
const log = console.log | ||
|
||
var addr = multiaddr('/ip4/127.0.0.1/udp/1234') | ||
const addr = new Multiaddr('/ip4/127.0.0.1/udp/1234') | ||
log(addr) | ||
log(addr.bytes) | ||
log(addr.toString()) | ||
log(multiaddr(addr.bytes)) | ||
log(new Multiaddr(addr.bytes)) | ||
|
||
log(addr.protoCodes()) | ||
log(addr.protoNames()) | ||
log(addr.protos()) | ||
|
||
log(addr.nodeAddress()) | ||
log(multiaddr.fromNodeAddress(addr.nodeAddress(), 'udp')) | ||
log(Multiaddr.fromNodeAddress(addr.nodeAddress(), 'udp')) | ||
|
||
log(addr.encapsulate('/sctp/5678')) | ||
log(addr.decapsulate('/udp')) | ||
|
||
var printer = multiaddr('/ip4/192.168.0.13/tcp/80') | ||
var proxy = multiaddr('/ip4/10.20.30.40/tcp/443') | ||
var printerOverProxy = proxy.encapsulate(printer) | ||
const printer = new Multiaddr('/ip4/192.168.0.13/tcp/80') | ||
const proxy = new Multiaddr('/ip4/10.20.30.40/tcp/443') | ||
const printerOverProxy = proxy.encapsulate(printer) | ||
log(printerOverProxy) | ||
|
||
var proxyAgain = printerOverProxy.decapsulate('/ip4') | ||
const proxyAgain = printerOverProxy.decapsulate('/ip4') | ||
log(proxyAgain) |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
theres a factory method exported
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but all the other code examples in jsdocs are with the constructor, why having these different? I also thought we were going to migrate into using the class instance in the future