Skip to content

Commit e669855

Browse files
committed
deps!: update multiformats to v11
`multiformats@11.x.x` shipped with a [breaking change](multiformats/js-multiformats#230) so update all deps using multiformats to the latest version.
1 parent eabdd43 commit e669855

File tree

5 files changed

+44
-102
lines changed

5 files changed

+44
-102
lines changed

.gitignore

+4-64
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,6 @@
1-
dist/
2-
docs/
3-
4-
# Logs
5-
logs
6-
*.log
7-
npm-debug.log*
8-
yarn-debug.log*
9-
yarn-error.log*
10-
11-
# Runtime data
12-
pids
13-
*.pid
14-
*.seed
15-
*.pid.lock
16-
17-
# Directory for instrumented libs generated by jscoverage/JSCover
18-
lib-cov
19-
20-
# Coverage directory used by tools like istanbul
21-
coverage
22-
23-
# nyc test coverage
24-
.nyc_output
25-
26-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
27-
.grunt
28-
29-
# Bower dependency directory (https://bower.io/)
30-
bower_components
31-
32-
# node-waf configuration
33-
.lock-wscript
34-
35-
# Compiled binary addons (http://nodejs.org/api/addons.html)
36-
build/Release
37-
38-
# Dependency directories
39-
node_modules/
40-
jspm_packages/
41-
42-
# Typescript v1 declaration files
43-
typings/
44-
45-
# Optional npm cache directory
46-
.npm
47-
48-
# Optional eslint cache
49-
.eslintcache
50-
51-
# Optional REPL history
52-
.node_repl_history
53-
54-
# Output of 'npm pack'
55-
*.tgz
56-
57-
# Yarn Integrity file
58-
.yarn-integrity
59-
60-
# dotenv environment variables file
61-
.env
62-
63-
# while testing npm5
1+
node_modules
2+
dist
3+
.docs
4+
.coverage
645
package-lock.json
656
yarn.lock
66-
types

README.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@
33
[![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech)
44
[![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech)
55
[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-datastore-pubsub.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-datastore-pubsub)
6-
[![CI](https://img.shields.io/github/workflow/status/ipfs/js-datastore-pubsub/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-datastore-pubsub/actions/workflows/js-test-and-release.yml)
6+
[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/js-datastore-pubsub/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/ipfs/js-datastore-pubsub/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)
77

88
> Responsible for providing an interface-datastore compliant api to pubsub
99
1010
## Table of contents <!-- omit in toc -->
1111

1212
- [Install](#install)
13+
- [Browser `<script>` tag](#browser-script-tag)
1314
- [Usage](#usage)
1415
- [API](#api)
1516
- - [Setup](#setup)
1617
- [Get](#get)
1718
- [Put](#put)
1819
- [Unsubscribe](#unsubscribe)
1920
- [Contribute](#contribute)
21+
- [API Docs](#api-docs)
2022
- [License](#license)
2123
- [Contribute](#contribute-1)
2224

@@ -26,6 +28,14 @@
2628
$ npm i datastore-pubsub
2729
```
2830

31+
### Browser `<script>` tag
32+
33+
Loading this module through a script tag will make it's exports available as `DatastorePubsub` in the global namespace.
34+
35+
```html
36+
<script src="https://unpkg.com/datastore-pubsub/dist/index.min.js"></script>
37+
```
38+
2939
## Usage
3040

3141
```js
@@ -109,6 +119,10 @@ This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/c
109119

110120
[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md)
111121

122+
## API Docs
123+
124+
- <https://ipfs.github.io/js-datastore-pubsub>
125+
112126
## License
113127

114128
Licensed under either of

package.json

+11-23
Original file line numberDiff line numberDiff line change
@@ -154,39 +154,27 @@
154154
"test:firefox": "aegir test -t browser -- --browser firefox",
155155
"test:firefox-webworker": "aegir test -t webworker -- --browser firefox",
156156
"test:electron-main": "aegir test -t electron-main",
157-
"dep-check": "aegir dep-check -i rimraf"
157+
"dep-check": "aegir dep-check",
158+
"docs": "aegir docs"
158159
},
159160
"dependencies": {
160-
"@libp2p/interface-dht": "^1.0.1",
161+
"@libp2p/interface-dht": "^2.0.0",
161162
"@libp2p/interface-pubsub": "^3.0.0",
162-
"@libp2p/interfaces": "^3.0.3",
163+
"@libp2p/interfaces": "^3.2.0",
163164
"@libp2p/logger": "^2.0.0",
164165
"datastore-core": "^8.0.1",
165-
"debug": "^4.2.0",
166-
"err-code": "^3.0.1",
167166
"interface-datastore": "^7.0.0",
168167
"uint8arrays": "^4.0.2"
169168
},
170169
"devDependencies": {
171-
"@libp2p/floodsub": "^5.0.0",
172-
"@libp2p/interface-compliance-tests": "^3.0.2",
173-
"@libp2p/interface-mocks": "^7.0.1",
174-
"@libp2p/interface-peer-id": "^1.0.5",
170+
"@libp2p/floodsub": "^6.0.0",
171+
"@libp2p/interface-mocks": "^9.0.0",
172+
"@libp2p/interface-peer-id": "^2.0.0",
175173
"@libp2p/interface-registrar": "^2.0.3",
176-
"@libp2p/peer-id-factory": "^1.0.9",
177-
"@libp2p/record": "^2.0.0",
178-
"@types/detect-node": "^2.0.0",
179-
"aegir": "^37.0.13",
180-
"detect-node": "^2.0.4",
181-
"install": "^0.13.0",
182-
"ipfs-core-types": "^0.12.1",
183-
"it-pair": "^2.0.2",
184-
"libp2p": "next",
185-
"npm": "^8.10.0",
174+
"@libp2p/peer-id-factory": "^2.0.0",
175+
"@libp2p/record": "^3.0.0",
176+
"aegir": "^37.10.0",
186177
"p-wait-for": "^5.0.0",
187-
"peer-id": "^0.16.0",
188-
"rimraf": "^3.0.2",
189-
"sinon": "^14.0.0",
190-
"util": "^0.12.4"
178+
"sinon": "^15.0.1"
191179
}
192180
}

src/index.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Key } from 'interface-datastore'
22
import { BaseDatastore } from 'datastore-core'
33
import { encodeBase32, keyToTopic, topicToKey } from './utils.js'
44
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
5-
import errcode from 'err-code'
5+
import { CodeError } from '@libp2p/interfaces/errors'
66
import { logger } from '@libp2p/logger'
77

88
const log = logger('datastore-pubsub:publisher')
@@ -32,19 +32,19 @@ export class PubSubDatastore extends BaseDatastore {
3232
super()
3333

3434
if (!validator) {
35-
throw errcode(new TypeError('missing validator'), 'ERR_INVALID_PARAMETERS')
35+
throw new CodeError('missing validator', 'ERR_INVALID_PARAMETERS')
3636
}
3737

3838
if (typeof validator !== 'function') {
39-
throw errcode(new TypeError('missing validate function'), 'ERR_INVALID_PARAMETERS')
39+
throw new CodeError('missing validate function', 'ERR_INVALID_PARAMETERS')
4040
}
4141

4242
if (typeof selector !== 'function') {
43-
throw errcode(new TypeError('missing select function'), 'ERR_INVALID_PARAMETERS')
43+
throw new CodeError('missing select function', 'ERR_INVALID_PARAMETERS')
4444
}
4545

4646
if (subscriptionKeyFn && typeof subscriptionKeyFn !== 'function') {
47-
throw errcode(new TypeError('invalid subscriptionKeyFn received'), 'ERR_INVALID_PARAMETERS')
47+
throw new CodeError('invalid subscriptionKeyFn received', 'ERR_INVALID_PARAMETERS')
4848
}
4949

5050
this._pubsub = pubsub
@@ -72,14 +72,14 @@ export class PubSubDatastore extends BaseDatastore {
7272
const errMsg = 'datastore key does not have a valid format'
7373

7474
log.error(errMsg)
75-
throw errcode(new Error(errMsg), 'ERR_INVALID_DATASTORE_KEY')
75+
throw new CodeError(errMsg, 'ERR_INVALID_DATASTORE_KEY')
7676
}
7777

7878
if (!(val instanceof Uint8Array)) {
7979
const errMsg = 'received value is not a Uint8Array'
8080

8181
log.error(errMsg)
82-
throw errcode(new Error(errMsg), 'ERR_INVALID_VALUE_RECEIVED')
82+
throw new CodeError(errMsg, 'ERR_INVALID_VALUE_RECEIVED')
8383
}
8484

8585
const stringifiedTopic = keyToTopic(key)
@@ -102,7 +102,7 @@ export class PubSubDatastore extends BaseDatastore {
102102
const errMsg = 'datastore key does not have a valid format'
103103

104104
log.error(errMsg)
105-
throw errcode(new Error(errMsg), 'ERR_INVALID_DATASTORE_KEY')
105+
throw new CodeError(errMsg, 'ERR_INVALID_DATASTORE_KEY')
106106
}
107107

108108
const stringifiedTopic = keyToTopic(key)
@@ -120,7 +120,7 @@ export class PubSubDatastore extends BaseDatastore {
120120
const errMsg = `cannot subscribe topic ${stringifiedTopic}`
121121

122122
log.error(errMsg)
123-
throw errcode(new Error(errMsg), 'ERR_SUBSCRIBING_TOPIC')
123+
throw new CodeError(errMsg, 'ERR_SUBSCRIBING_TOPIC')
124124
}
125125
log(`subscribed values for key ${stringifiedTopic}`)
126126

@@ -158,19 +158,19 @@ export class PubSubDatastore extends BaseDatastore {
158158
const errMsg = `unexpected error getting the ipns record for ${routingKey.toString()}`
159159

160160
log.error(errMsg)
161-
throw errcode(new Error(errMsg), 'ERR_UNEXPECTED_ERROR_GETTING_RECORD')
161+
throw new CodeError(errMsg, 'ERR_UNEXPECTED_ERROR_GETTING_RECORD')
162162
}
163163
const errMsg = `local record requested was not found for ${routingKey.toString()}`
164164

165165
log.error(errMsg)
166-
throw errcode(new Error(errMsg), 'ERR_NOT_FOUND')
166+
throw new CodeError(errMsg, 'ERR_NOT_FOUND')
167167
}
168168

169169
if (!(dsVal instanceof Uint8Array)) {
170170
const errMsg = 'found record that we couldn\'t convert to a value'
171171

172172
log.error(errMsg)
173-
throw errcode(new Error(errMsg), 'ERR_INVALID_RECORD_RECEIVED')
173+
throw new CodeError(errMsg, 'ERR_INVALID_RECORD_RECEIVED')
174174
}
175175

176176
return dsVal
@@ -286,7 +286,7 @@ export class PubSubDatastore extends BaseDatastore {
286286
const errMsg = 'record received through pubsub is not valid'
287287

288288
log.error(errMsg)
289-
throw errcode(new Error(errMsg), 'ERR_NOT_VALID_RECORD')
289+
throw new CodeError(errMsg, 'ERR_NOT_VALID_RECORD')
290290
}
291291

292292
// Get Local record

test/index.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { expect } from 'aegir/chai'
44
import sinon from 'sinon'
55
import errcode from 'err-code'
6-
import isNode from 'detect-node'
6+
import { isNode } from 'aegir/env'
77
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
88
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
99
import { PubSubDatastore } from '../src/index.js'

0 commit comments

Comments
 (0)