js-rpc2 2.3.1 → 2.3.2
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.
- package/package.json +1 -1
- package/src/lib.js +17 -14
package/package.json
CHANGED
package/src/lib.js
CHANGED
@@ -774,10 +774,10 @@ export function _testCreateRpcClientHttp(param) {
|
|
774
774
|
method: 'POST',
|
775
775
|
signal: param.signal,
|
776
776
|
// @ts-ignore
|
777
|
-
duplex:'half',
|
777
|
+
duplex: 'half',
|
778
778
|
body: new ReadableStream({
|
779
|
-
async pull(controller){
|
780
|
-
controller.enqueue(chunk.slice(0,10))
|
779
|
+
async pull(controller) {
|
780
|
+
controller.enqueue(chunk.slice(0, 10))
|
781
781
|
await sleep(1000)
|
782
782
|
controller.enqueue(chunk.slice(10))
|
783
783
|
controller.close()
|
@@ -873,25 +873,28 @@ export function createRpcClientMessagePort(param) {
|
|
873
873
|
|
874
874
|
/**
|
875
875
|
* @param {string} text
|
876
|
-
* @returns
|
877
876
|
*/
|
878
877
|
export function base64decode(text) {
|
879
|
-
const
|
880
|
-
const
|
881
|
-
|
882
|
-
|
878
|
+
const binaryString = atob(text)
|
879
|
+
const len = binaryString.length
|
880
|
+
const bytes = new Uint8Array(len)
|
881
|
+
for (let i = 0; i < len; i++) {
|
882
|
+
bytes[i] = binaryString.charCodeAt(i)
|
883
|
+
}
|
884
|
+
return bytes
|
883
885
|
}
|
884
886
|
|
885
887
|
/**
|
886
888
|
* @param {Uint8Array<ArrayBuffer>} buffer
|
887
|
-
* @returns
|
888
889
|
*/
|
889
|
-
export function base64encode(buffer
|
890
|
-
|
891
|
-
|
892
|
-
|
890
|
+
export function base64encode(buffer) {
|
891
|
+
const CHUNK_SZ = 0x8000
|
892
|
+
const chars = []
|
893
|
+
for (let i = 0; i < buffer.length; i += CHUNK_SZ) {
|
894
|
+
const chunk = buffer.subarray(i, i + CHUNK_SZ)
|
895
|
+
chars.push(String.fromCharCode.apply(null, chunk))
|
893
896
|
}
|
894
|
-
return
|
897
|
+
return btoa(chars.join(''))
|
895
898
|
}
|
896
899
|
|
897
900
|
/**
|