@peerbit/blocks-interface 1.3.13 → 1.3.14-a4bb1df

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,6 +13,7 @@ export type PutOptions = {
13
13
  type MaybePromise<T> = Promise<T> | T;
14
14
  export interface Blocks extends WaitForPeer {
15
15
  put(bytes: Uint8Array): MaybePromise<string>;
16
+ maybePut(bytes: Uint8Array, condition?: (cid: string) => MaybePromise<boolean>): MaybePromise<string>;
16
17
  has(cid: string): MaybePromise<boolean>;
17
18
  get(cid: string, options?: GetOptions): MaybePromise<Uint8Array | undefined>;
18
19
  rm(cid: string): MaybePromise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7D,MAAM,MAAM,UAAU,GAAG;IACxB,MAAM,CAAC,EACJ;QACA,MAAM,CAAC,EAAE,WAAW,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;KACf,GACD,OAAO,CAAC;CACX,CAAC;AACF,MAAM,MAAM,UAAU,GAAG;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,YAAY,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAEtC,MAAM,WAAW,MAAO,SAAQ,WAAW;IAC1C,GAAG,CAAC,KAAK,EAAE,UAAU,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IAC7C,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IACxC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC,UAAU,GAAG,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AAG,EAAE,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IACxC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;IAC7E,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACpC,QAAQ,IAAI,cAAc,CAAC,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7D,IAAI,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;IAC7B,SAAS,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;CACnC;AAED,OAAO,EACN,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,QAAQ,GACR,MAAM,YAAY,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,MAAM,2BAA2B,CAAC;AA4B7D,OAAO,EACN,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,QAAQ,GACR,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,MAAM,2BAA2B,CAAC;AAgC7D,OAAO,EACN,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,QAAQ,GACR,MAAM,YAAY,CAAC"}
package/package.json CHANGED
@@ -1,85 +1,85 @@
1
1
  {
2
- "name": "@peerbit/blocks-interface",
3
- "version": "1.3.13",
4
- "description": "Block store streaming",
5
- "type": "module",
6
- "sideEffects": false,
7
- "types": "./dist/src/index.d.ts",
8
- "typesVersions": {
9
- "*": {
10
- "*": [
11
- "*",
12
- "dist/*",
13
- "dist/src/*",
14
- "dist/src/*/index"
15
- ],
16
- "src/*": [
17
- "*",
18
- "dist/*",
19
- "dist/src/*",
20
- "dist/src/*/index"
21
- ]
22
- }
23
- },
24
- "files": [
25
- "src",
26
- "dist",
27
- "!dist/e2e",
28
- "!dist/test",
29
- "!**/*.tsbuildinfo"
30
- ],
31
- "exports": {
32
- ".": {
33
- "types": "./dist/src/index.d.ts",
34
- "import": "./dist/src/index.js"
35
- }
36
- },
37
- "eslintConfig": {
38
- "extends": "peerbit",
39
- "parserOptions": {
40
- "project": true,
41
- "sourceType": "module"
42
- },
43
- "ignorePatterns": [
44
- "!.aegir.js",
45
- "test/ts-use",
46
- "*.d.ts"
47
- ]
48
- },
49
- "publishConfig": {
50
- "access": "public"
51
- },
52
- "scripts": {
53
- "clean": "aegir clean",
54
- "build": "aegir build --no-bundle",
55
- "test": "",
56
- "lint": "aegir lint"
57
- },
58
- "engines": {
59
- "node": ">=16.15.1"
60
- },
61
- "repository": {
62
- "type": "git",
63
- "url": "git+https://github.com/dao-xyz/peerbit.git"
64
- },
65
- "keywords": [
66
- "peerbit"
67
- ],
68
- "author": "dao.xyz",
69
- "license": "MIT",
70
- "bugs": {
71
- "url": "https://github.com/dao-xyz/peerbit/issues"
72
- },
73
- "homepage": "https://github.com/dao-xyz/peerbit#readme",
74
- "localMaintainers": [
75
- "dao.xyz"
76
- ],
77
- "devDependencies": {
78
- "@peerbit/libp2p-test-utils": "2.1.14"
79
- },
80
- "dependencies": {
81
- "@dao-xyz/borsh": "^5.2.3",
82
- "@peerbit/crypto": "2.3.6",
83
- "@peerbit/stream-interface": "^5.1.5"
84
- }
2
+ "name": "@peerbit/blocks-interface",
3
+ "version": "1.3.14-a4bb1df",
4
+ "description": "Block store streaming",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "types": "./dist/src/index.d.ts",
8
+ "typesVersions": {
9
+ "*": {
10
+ "*": [
11
+ "*",
12
+ "dist/*",
13
+ "dist/src/*",
14
+ "dist/src/*/index"
15
+ ],
16
+ "src/*": [
17
+ "*",
18
+ "dist/*",
19
+ "dist/src/*",
20
+ "dist/src/*/index"
21
+ ]
22
+ }
23
+ },
24
+ "files": [
25
+ "src",
26
+ "dist",
27
+ "!dist/e2e",
28
+ "!dist/test",
29
+ "!**/*.tsbuildinfo"
30
+ ],
31
+ "exports": {
32
+ ".": {
33
+ "types": "./dist/src/index.d.ts",
34
+ "import": "./dist/src/index.js"
35
+ }
36
+ },
37
+ "eslintConfig": {
38
+ "extends": "peerbit",
39
+ "parserOptions": {
40
+ "project": true,
41
+ "sourceType": "module"
42
+ },
43
+ "ignorePatterns": [
44
+ "!.aegir.js",
45
+ "test/ts-use",
46
+ "*.d.ts"
47
+ ]
48
+ },
49
+ "publishConfig": {
50
+ "access": "public"
51
+ },
52
+ "scripts": {
53
+ "clean": "aegir clean",
54
+ "build": "aegir build --no-bundle",
55
+ "test": "",
56
+ "lint": "aegir lint"
57
+ },
58
+ "engines": {
59
+ "node": ">=16.15.1"
60
+ },
61
+ "repository": {
62
+ "type": "git",
63
+ "url": "git+https://github.com/dao-xyz/peerbit.git"
64
+ },
65
+ "keywords": [
66
+ "peerbit"
67
+ ],
68
+ "author": "dao.xyz",
69
+ "license": "MIT",
70
+ "bugs": {
71
+ "url": "https://github.com/dao-xyz/peerbit/issues"
72
+ },
73
+ "homepage": "https://github.com/dao-xyz/peerbit#readme",
74
+ "localMaintainers": [
75
+ "dao.xyz"
76
+ ],
77
+ "devDependencies": {
78
+ "@peerbit/libp2p-test-utils": "2.1.14-a4bb1df"
79
+ },
80
+ "dependencies": {
81
+ "@dao-xyz/borsh": "^5.2.3",
82
+ "@peerbit/crypto": "2.3.6-a4bb1df",
83
+ "@peerbit/stream-interface": "5.2.0-a4bb1df"
84
+ }
85
85
  }
package/src/index.ts CHANGED
@@ -18,6 +18,10 @@ type MaybePromise<T> = Promise<T> | T;
18
18
 
19
19
  export interface Blocks extends WaitForPeer {
20
20
  put(bytes: Uint8Array): MaybePromise<string>;
21
+ maybePut(
22
+ bytes: Uint8Array,
23
+ condition?: (cid: string) => MaybePromise<boolean>,
24
+ ): MaybePromise<string>;
21
25
  has(cid: string): MaybePromise<boolean>;
22
26
  get(cid: string, options?: GetOptions): MaybePromise<Uint8Array | undefined>;
23
27
  rm(cid: string): MaybePromise<void>;