Skip to content

Commit b02305f

Browse files
authored
Merge pull request #463 from streamich/api-improvements
API improvements
2 parents a63f12b + 7e190c6 commit b02305f

File tree

23 files changed

+205
-77
lines changed

23 files changed

+205
-77
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"demo:json-pointer": "ts-node src/json-pointer/__demos__/json-pointer.ts",
6060
"demo:reactive-rpc:server": "ts-node src/reactive-rpc/__demos__/server.ts",
6161
"coverage": "yarn test --collectCoverage",
62-
"typedoc": "typedoc",
62+
"typedoc": "npx typedoc",
6363
"build:pages": "rimraf gh-pages && mkdir -p gh-pages && cp -r typedocs/* gh-pages && cp -r coverage gh-pages/coverage",
6464
"deploy:pages": "gh-pages -d gh-pages",
6565
"publish-coverage-and-typedocs": "yarn typedoc && yarn coverage && yarn build:pages && yarn deploy:pages"
@@ -152,7 +152,6 @@
152152
"tslib": "^2.5.0",
153153
"tslint": "^6.1.3",
154154
"tslint-config-common": "^1.6.2",
155-
"typedoc": "^0.25.3",
156155
"typescript": "^5.2.2",
157156
"uWebSockets.js": "uNetworking/uWebSockets.js#v20.23.0",
158157
"webpack": "^5.84.1",

src/json-crdt-patch/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
*/
112112

113113
export * from './types';
114+
export * from './clock';
114115
export * from './operations';
115116
export * from './Patch';
116117
export * from './PatchBuilder';
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './types';
2+
export * from './Encoder';
3+
export * from './Decoder';
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './Encoder';
2+
export * from './Decoder';
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export * from './constants';
2+
export * from './Encoder';
3+
export * from './Decoder';
4+
export * from './ViewDecoder';
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './types';
2+
export * from './Encoder';
3+
export * from './Decoder';
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './types';
2+
export * from './Encoder';
3+
export * from './Decoder';

src/json-crdt/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
export * from './nodes';
22
export * from './extensions/types';
33
export * from './model';
4+
5+
export * from '../json-crdt-patch';

src/json-crdt/model/api/__tests__/ArrayApi.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,12 @@ test('can insert a value and delete all previous ones', () => {
1212
arr.ins(1, [69]);
1313
expect(arr.view()).toEqual([42, 69]);
1414
});
15+
16+
test('.length()', () => {
17+
const doc = Model.withLogicalClock();
18+
doc.api.root({
19+
arr: [1, 2, 3],
20+
});
21+
const arr = doc.api.arr(['arr']);
22+
expect(arr.length()).toBe(3);
23+
});

src/json-crdt/model/api/__tests__/BinaryApi.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {s} from '../../../../json-crdt-patch';
12
import {Model} from '../../Model';
23

34
test('can edit a simple binary', () => {
@@ -25,3 +26,12 @@ test('can delete across two chunks', () => {
2526
bin.del(1, 7);
2627
expect(bin.view()).toEqual(new Uint8Array([3, 1]));
2728
});
29+
30+
test('.length()', () => {
31+
const doc = Model.withLogicalClock().setSchema(
32+
s.obj({
33+
bin: s.bin(new Uint8Array([1, 2, 3])),
34+
}),
35+
);
36+
expect(doc.find.val.bin.toApi().length()).toBe(3);
37+
});

0 commit comments

Comments
 (0)