1- import { ESCAPE_KEY , FUNCTION_KEY } from '../const'
1+ import { ESCAPE_KEY , RPC_KEY } from '../const'
22import { isValidToEscape , isValidToDecode } from '../util/isValid'
33import { getUniqueKey } from '../util/get'
44import { isInteger , isFunction } from '../util/is'
@@ -10,8 +10,8 @@ Rpc.encode = function ({ value, local_rpcs, registerLocalRpcFromEncode }) {
1010 const function_id = local_rpcs . has ( value )
1111 ? local_rpcs . get ( value )
1212 : registerLocalRpcFromEncode ( value )
13- return { [ FUNCTION_KEY ] : function_id }
14- } else if ( isValidToDecode ( { value, key : FUNCTION_KEY } ) ) {
13+ return { [ RPC_KEY ] : function_id }
14+ } else if ( isValidToDecode ( { value, key : RPC_KEY } ) ) {
1515 return { [ ESCAPE_KEY ] : value }
1616 }
1717 return value
@@ -24,19 +24,16 @@ Rpc.decode = function ({
2424 caller,
2525 function_creator,
2626} ) {
27- if (
28- getUniqueKey ( value ) === FUNCTION_KEY &&
29- isInteger ( value [ FUNCTION_KEY ] )
30- ) {
27+ if ( getUniqueKey ( value ) === RPC_KEY && isInteger ( value [ RPC_KEY ] ) ) {
3128 return createRemoteFunction ( {
32- function_id : value [ FUNCTION_KEY ] ,
29+ function_id : value [ RPC_KEY ] ,
3330 function_creator,
3431 caller,
3532 path : path . slice ( 2 ) ,
3633 } )
3734 } else if (
3835 isValidToEscape ( { value } ) &&
39- isValidToDecode ( { value : value [ ESCAPE_KEY ] , key : FUNCTION_KEY } )
36+ isValidToDecode ( { value : value [ ESCAPE_KEY ] , key : RPC_KEY } )
4037 ) {
4138 return value [ ESCAPE_KEY ]
4239 }
0 commit comments