Skip to content
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

Types based bug fixes #695

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@
"publish-coverage-and-typedocs": "yarn typedoc && yarn coverage && yarn build:pages && yarn deploy:pages",
"jj": "npx ts-node src/json-cli/jj.ts",
"upgrade:check": "npx [email protected]",
"upgrade:interactive": "npx [email protected] --interactive"
"upgrade:interactive": "npx [email protected] --interactive",
"test:types": "npx tsc --noEmit"
},
"peerDependencies": {
"rxjs": "7",
Expand Down
8 changes: 4 additions & 4 deletions src/json-crdt-extensions/cnt/__demos__/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@
*/

import {Model, s} from '../../../json-crdt';
import {CntExt} from '..';
import {cnt} from '..';

console.clear();

const model = Model.withLogicalClock(1234);

model.ext.register(CntExt);
model.ext.register(cnt);

model.api.root({
counter: CntExt.new(1),
counter: cnt.new(1),
});
console.log(model + '');

// Excess use only ...
// 2-3 days for finding damages ...
// ..

const api = model.api.in(['counter']).asExt(CntExt);
const api = model.api.in(['counter']).asExt(cnt);
const values = api.view();

console.log(values);
Expand Down
8 changes: 4 additions & 4 deletions src/json-crdt-extensions/cnt/__demos__/usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
*/

import {Model, s} from '../../../json-crdt';
import {CntExt} from '..';
import {cnt} from '..';

console.clear();

const model = Model.withLogicalClock(1234);

model.ext.register(CntExt);
model.ext.register(cnt);

model.api.root({
cnt: CntExt.new(42),
cnt: cnt.new(42),
});

console.log('');
console.log('Initial value:');
console.log(model + '');

const api = model.api.in(['cnt']).asExt(CntExt);
const api = model.api.in(['cnt']).asExt(cnt);

api.inc(10);

Expand Down
8 changes: 4 additions & 4 deletions src/json-crdt-extensions/mval/__demos__/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
*/

import {Model, s} from '../../../json-crdt';
import {MvalExt} from '..';
import {mval} from '..';

console.clear();

const model = Model.withLogicalClock(1234);

model.ext.register(MvalExt);
model.ext.register(mval);

model.api.root({
score: MvalExt.new(1),
score: mval.new(1),
});
console.log(model + '');

const api = model.api.in(['score']).asExt(MvalExt);
const api = model.api.in(['score']).asExt(mval);
const values = api.view();

console.log(values);
Expand Down
10 changes: 5 additions & 5 deletions src/json-crdt-extensions/mval/__demos__/usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@
*/

import {Model, s} from '../../../json-crdt';
import {MvalExt} from '..';
import {mval} from '..';

console.clear();

const model = Model.withLogicalClock(1234);

model.ext.register(MvalExt);
model.ext.register(mval);

model.api.root({
obj: {
name: s.con('John'),
score: MvalExt.new(s.con(1)),
score: mval.new(s.con(1)),
},
});

console.log('');
console.log('Initial value:');
console.log(model + '');

const api = model.api.in(['obj', 'score']).asExt(MvalExt);
const api = model.api.in(['obj', 'score']).asExt(mval);

api.set(s.con(5));

Expand All @@ -36,7 +36,7 @@ console.log(model + '');

const model2 = model.fork();

const api2 = model2.api.in(['obj', 'score']).asExt(MvalExt);
const api2 = model2.api.in(['obj', 'score']).asExt(mval);

api.set(s.con(10));
api2.set(s.con(20));
Expand Down
6 changes: 3 additions & 3 deletions src/json-crdt-extensions/mval/__demos__/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
*/

import {Model, s} from '../../../json-crdt';
import {MvalExt} from '..';
import {mval} from '..';

console.clear();

const model = Model.withLogicalClock(1234);

model.ext.register(MvalExt);
model.ext.register(mval);

model.api.root(MvalExt.new(s.con(1)));
model.api.root(mval.new(s.con(1)));

console.log('');
console.log('Model with extension:');
Expand Down
7 changes: 3 additions & 4 deletions src/json-crdt/__demos__/events-level2-arr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ const main = async () => {
console.log('More changes which result in only model change:');
console.log('');
// model.api.transaction(() => {
model.api
.arr(['my', 'deep', 'arr'])
.del(1, 1)
.ins(1, [konst(2)]);
const arrNode = model.api.arr(['my', 'deep', 'arr']);
arrNode.del(1, 1);
arrNode.ins(1, [konst(2)]);
// });
await new Promise((r) => setTimeout(r, 1));
console.log('');
Expand Down
4 changes: 3 additions & 1 deletion src/json-crdt/__demos__/toString-array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ model.api.root({

const str = model.api.str(['foo']);

str.ins(3, 'def').ins(6, 'ghi').del(1, 2);
str.ins(3, 'def');
str.ins(6, 'ghi');
str.del(1, 2);

model.api.obj([]).del(['baz']);
model.api.obj([]).set({
Expand Down
22 changes: 12 additions & 10 deletions src/json-crdt/__demos__/toString-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,24 @@ console.log('After adding a nested object:');
console.log('');
console.log(model.toString());

model.api
.obj([])
.set({
about: 'I am a software engineer. I like to write code. (Codepilot wrote this demo.)',
verified: true,
sex: null,
})
.val(['age'])
.set(18);
const objNode = model.api.obj([]);
objNode.set({
about: 'I am a software engineer. I like to write code. (Codepilot wrote this demo.)',
verified: true,
sex: null,
});
objNode.val(['age']);
objNode.set(18);

console.log('');
console.log('Editing /name field a bit more:');
console.log('');
console.log(model.toString());

model.api.str(['name']).del(7, 3).ins(7, 'Bravo!').ins(0, '💪 ');
const strNode = model.api.str(['name']);
strNode.del(7, 3);
strNode.ins(7, 'Bravo!');
strNode.ins(0, '💪 ');

console.log('');
console.log('After some more name editing:');
Expand Down
4 changes: 3 additions & 1 deletion src/json-crdt/__demos__/toString-string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ console.log('Set initial string value:');
console.log('');
console.log(str.toString());

str.api.str([]).ins(2, 'l').ins(10, '!');
const strNode = str.api.str([]);
strNode.ins(2, 'l');
strNode.ins(10, '!');

console.log('');
console.log('After fixing errors in the string:');
Expand Down
4 changes: 2 additions & 2 deletions src/json-expression/__bench__/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ const fn = codegen.run().compile();
const suite = new Benchmark.Suite();
suite
.add(`json-joy/json-expression JsonExpressionCodegen`, () => {
fn({vars: new Vars(json)});
fn(new Vars(json));
})
.add(`json-joy/json-expression JsonExpressionCodegen with codegen`, () => {
const codegen = new JsonExpressionCodegen({expression, operators: operatorsMap});
const fn = codegen.run().compile();
fn({vars: new Vars(json)});
fn(new Vars(json));
})
.add(`json-joy/json-expression evaluate`, () => {
evaluate(expression, {vars: new Vars(json)});
Expand Down