Skip to content

Commit f993b21

Browse files
committed
Naming changes, Function is now Rpc
1 parent f9adfe9 commit f993b21

File tree

3 files changed

+31
-31
lines changed

3 files changed

+31
-31
lines changed

src/const.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export const ESCAPE_KEY = '$escape'
2-
export const RPC_KEY = '$f'
2+
export const RPC_KEY = '$r'
33
export const DELETE_KEY = '$d'
4-
export const REPLACE_KEY = '$r'
4+
export const REPLACE_KEY = '$e'
55
export const SPLICE_KEY = '$s'
66
export const SWAP_KEY = '$w'
77
export const MULTI_KEY = '$m'

test/createNode.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,30 +140,30 @@ test('Testing messages', async (t) => {
140140
t.is(ten, 10)
141141
})
142142

143-
test('Escaping $f', async (t) => {
143+
test('Escaping $r', async (t) => {
144144
const serdes = { serialize: (m) => m, deserialize: (m) => m }
145145
const server = createNode(serdes)
146146
const client = createNode(serdes)
147147

148148
// server side
149149
server.open(
150150
(msg) => {
151-
t.deepEqual(msg, [-1, 0, { $escape: { $f: 1 } }])
151+
t.deepEqual(msg, [-1, 0, { $escape: { $r: 1 } }])
152152
client.message(msg)
153153
},
154154
(arg) => {
155-
t.deepEqual(arg, { $f: 0 })
156-
return { $f: 1 }
155+
t.deepEqual(arg, { $r: 0 })
156+
return { $r: 1 }
157157
}
158158
)
159159

160160
// client side
161161
const callServer = client.open((msg) => {
162-
t.deepEqual(msg, [1, 0, [{ $escape: { $f: 0 } }]])
162+
t.deepEqual(msg, [1, 0, [{ $escape: { $r: 0 } }]])
163163
server.message(msg)
164164
})
165-
const resu = await callServer({ $f: 0 })
166-
t.deepEqual(resu, { $f: 1 })
165+
const resu = await callServer({ $r: 0 })
166+
t.deepEqual(resu, { $r: 1 })
167167
})
168168

169169
test('Using resolve', async (t) => {

test/type_replace.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,72 +4,72 @@ import { testEncodeDecode, testPatchUnpatch } from './utils'
44

55
test('Valid type', function (t) {
66
const patch = { convert: TYPE.Replace({ hello: 'world' }) }
7-
const expected = { convert: { $r: { hello: 'world' } } }
7+
const expected = { convert: { $e: { hello: 'world' } } }
88
testEncodeDecode(t, patch, expected)
99
})
1010

1111
test('Escape', function (t) {
12-
const patch = { escape: { $r: 1 } }
13-
const expected = { escape: { $escape: { $r: 1 } } }
12+
const patch = { escape: { $e: 1 } }
13+
const expected = { escape: { $escape: { $e: 1 } } }
1414
testEncodeDecode(t, patch, expected)
1515
})
1616

1717
test('Ignore', function (t) {
18-
const patch = { ignore: { $r: 1, $other: 1 } }
19-
const expected = { ignore: { $r: 1, $other: 1 } }
18+
const patch = { ignore: { $e: 1, $other: 1 } }
19+
const expected = { ignore: { $e: 1, $other: 1 } }
2020
testEncodeDecode(t, patch, expected)
2121
})
2222

2323
test('$escaping', function (t) {
2424
const patch = {
2525
convert: TYPE.Replace([1, 2, 3]),
26-
escape: { $r: 1 },
26+
escape: { $e: 1 },
2727
}
2828
const expected = {
29-
convert: { $r: [1, 2, 3] },
30-
escape: { $escape: { $r: 1 } },
29+
convert: { $e: [1, 2, 3] },
30+
escape: { $escape: { $e: 1 } },
3131
}
3232
testEncodeDecode(t, patch, expected)
3333
})
3434

35-
test('This should not be escaped because $r has another valid prop', function (t) {
35+
test('This should not be escaped because $e has another valid prop', function (t) {
3636
const patch = {
3737
convert: TYPE.Replace([1, 2, 3]),
38-
ignored: { $r: [1, 2, 3], $escape: [1, 2, 3] },
38+
ignored: { $e: [1, 2, 3], $escape: [1, 2, 3] },
3939
}
4040
const expected = {
41-
convert: { $r: [1, 2, 3] },
42-
ignored: { $r: [1, 2, 3], $escape: [1, 2, 3] },
41+
convert: { $e: [1, 2, 3] },
42+
ignored: { $e: [1, 2, 3], $escape: [1, 2, 3] },
4343
}
4444
testEncodeDecode(t, patch, expected)
4545
})
4646

47-
test('This should not be escaped because $r has another valid prop 2', function (t) {
47+
test('This should not be escaped because $e has another valid prop 2', function (t) {
4848
const patch = {
4949
convert: TYPE.Replace([1, 2, 3]),
50-
escape: { $escape: [1, 2, 3], $r: TYPE.Replace([1, 2, 3]) },
50+
escape: { $escape: [1, 2, 3], $e: TYPE.Replace([1, 2, 3]) },
5151
}
5252
const expected = {
53-
convert: { $r: [1, 2, 3] },
54-
escape: { $escape: [1, 2, 3], $r: { $r: [1, 2, 3] } },
53+
convert: { $e: [1, 2, 3] },
54+
escape: { $escape: [1, 2, 3], $e: { $e: [1, 2, 3] } },
5555
}
5656
testEncodeDecode(t, patch, expected)
5757
})
5858

5959
test('Decode alone', function (t) {
6060
const patch = {
61-
convert: { $r: [1, 2, 3] },
62-
string: { $r: 'string' },
63-
escape: { $escape: { $r: [1, 2, 3] } },
61+
convert: { $e: [1, 2, 3] },
62+
string: { $e: 'string' },
63+
escape: { $escape: { $e: [1, 2, 3] } },
6464
ignore: {
65-
$escape: { $r: [1, 2, 3] },
66-
two: { $r: [1, 2, 3] },
65+
$escape: { $e: [1, 2, 3] },
66+
two: { $e: [1, 2, 3] },
6767
},
6868
}
6969
const expected = {
7070
convert: TYPE.Replace([1, 2, 3]),
7171
string: TYPE.Replace('string'),
72-
escape: { $r: [1, 2, 3] },
72+
escape: { $e: [1, 2, 3] },
7373
ignore: {
7474
$escape: TYPE.Replace([1, 2, 3]),
7575
two: TYPE.Replace([1, 2, 3]),

0 commit comments

Comments
 (0)