Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

lib0

Package Overview
Dependencies
Maintainers
1
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lib0 - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

.nyc_output/5533be88-6af4-4919-a434-8b62ae34ee29.json

2

.nyc_output/processinfo/index.json

@@ -1,1 +0,1 @@

{"processes":{"aee930f0-5b7e-4e59-8e2a-de9105b04816":{"parent":null,"children":[]}},"files":{},"externalIds":{}}
{"processes":{"5533be88-6af4-4919-a434-8b62ae34ee29":{"parent":null,"children":[]}},"files":{},"externalIds":{}}

@@ -6,2 +6,3 @@ /**

import * as binary from './binary.js'
import * as string from './string.js'

@@ -273,16 +274,4 @@ /**

*/
export const readVarString = decoder => {
let remainingLen = readVarUint(decoder)
let encodedString = ''
while (remainingLen > 0) {
const nextLen = remainingLen < 10000 ? remainingLen : 10000
const bytes = new Array(nextLen)
for (let i = 0; i < nextLen; i++) {
bytes[i] = decoder.arr[decoder.pos++]
}
encodedString += String.fromCodePoint.apply(null, bytes)
remainingLen -= nextLen
}
return decodeURIComponent(escape(encodedString))
}
export const readVarString = decoder =>
string.decodeUtf8(readVarUint8Array(decoder))

@@ -289,0 +278,0 @@ /**

@@ -7,3 +7,3 @@ 'use strict';

require('./map.js');
require('./string.js');
var string = require('./string.js');
require('./conditions.js');

@@ -282,16 +282,4 @@ require('./environment.js');

*/
const readVarString = decoder => {
let remainingLen = readVarUint(decoder);
let encodedString = '';
while (remainingLen > 0) {
const nextLen = remainingLen < 10000 ? remainingLen : 10000;
const bytes = new Array(nextLen);
for (let i = 0; i < nextLen; i++) {
bytes[i] = decoder.arr[decoder.pos++];
}
encodedString += String.fromCodePoint.apply(null, bytes);
remainingLen -= nextLen;
}
return decodeURIComponent(escape(encodedString))
};
const readVarString = decoder =>
string.decodeUtf8(readVarUint8Array(decoder));

@@ -298,0 +286,0 @@ /**

@@ -7,3 +7,3 @@ 'use strict';

require('./map.js');
require('./string.js');
var string = require('./string.js');
require('./conditions.js');

@@ -258,11 +258,4 @@ require('./environment.js');

*/
const writeVarString = (encoder, str) => {
const encodedString = unescape(encodeURIComponent(str));
const len = encodedString.length;
writeVarUint(encoder, len);
for (let i = 0; i < len; i++) {
// @ts-ignore
write(encoder, encodedString.codePointAt(i));
}
};
const writeVarString = (encoder, str) =>
writeVarUint8Array(encoder, string.encodeUtf8(str));

@@ -269,0 +262,0 @@ /**

@@ -41,2 +41,70 @@ 'use strict';

/**
* @param {string} str
* @return {Uint8Array}
*/
const _encodeUtf8Polyfill = str => {
const encodedString = unescape(encodeURIComponent(str));
const len = encodedString.length;
const buf = new Uint8Array(len);
for (let i = 0; i < len; i++) {
buf[i] = /** @type {number} */ (encodedString.codePointAt(i));
}
return buf
};
const utf8TextEncoder = typeof TextEncoder !== 'undefined' ? new TextEncoder() : null;
/**
* @param {string} str
* @return {Uint8Array}
*/
const _encodeUtf8Native = str => /** @type {TextEncoder} */ (utf8TextEncoder).encode(str);
/**
* @param {string} str
* @return {Uint8Array}
*/
const encodeUtf8 = utf8TextEncoder ? _encodeUtf8Native : _encodeUtf8Polyfill;
/**
* @param {Uint8Array} buf
* @return {string}
*/
const _decodeUtf8Polyfill = buf => {
let remainingLen = buf.length;
let encodedString = '';
let bufPos = 0;
while (remainingLen > 0) {
const nextLen = remainingLen < 10000 ? remainingLen : 10000;
const bytes = new Array(nextLen);
for (let i = 0; i < nextLen; i++) {
bytes[i] = buf[bufPos++];
}
encodedString += String.fromCodePoint.apply(null, bytes);
remainingLen -= nextLen;
}
return decodeURIComponent(escape(encodedString))
};
const utf8TextDecoder = typeof TextDecoder === 'undefined' ? null : new TextDecoder('utf-8', { fatal: true });
/**
* @param {Uint8Array} buf
* @return {string}
*/
const _decodeUtf8Native = buf => /** @type {TextDecoder} */ (utf8TextDecoder).decode(buf);
/**
* @param {Uint8Array} buf
* @return {string}
*/
const decodeUtf8 = utf8TextDecoder ? _decodeUtf8Native : _decodeUtf8Polyfill;
exports._decodeUtf8Native = _decodeUtf8Native;
exports._decodeUtf8Polyfill = _decodeUtf8Polyfill;
exports._encodeUtf8Native = _encodeUtf8Native;
exports._encodeUtf8Polyfill = _encodeUtf8Polyfill;
exports.decodeUtf8 = decodeUtf8;
exports.encodeUtf8 = encodeUtf8;
exports.fromCamelCase = fromCamelCase;

@@ -47,2 +115,4 @@ exports.fromCharCode = fromCharCode;

exports.utf8ByteLength = utf8ByteLength;
exports.utf8TextDecoder = utf8TextDecoder;
exports.utf8TextEncoder = utf8TextEncoder;
//# sourceMappingURL=string.js.map

@@ -187,5 +187,5 @@ 'use strict';

* @param {string} message
* @param {function():void} f
* @param {function():void|Promise} f
*/
const measureTime = (message, f) => {
const measureTime = async (message, f) => {
let duration = 0;

@@ -195,3 +195,6 @@ let iterations = 0;

while (duration < 5) {
f();
const p = f();
if (p) {
await p;
}
duration = perf.now() - start;

@@ -198,0 +201,0 @@ iterations++;

@@ -81,3 +81,2 @@ 'use strict';

wsclient.emit('connect', [{ type: 'connect' }, wsclient]);
wsclient.afterOpen.forEach(m => wsclient.send(m(wsclient)));
// set ping

@@ -115,7 +114,2 @@ pingTimeout = setTimeout(sendPing, messageReconnectTimeout / 2);

this.shouldConnect = true;
/**
* Array of functions that create messages that will be sent after a connection is opened
* @type {Array<function(WebsocketClient):any>}
*/
this.afterOpen = [];
this._checkInterval = setInterval(() => {

@@ -122,0 +116,0 @@ if (this.connected && messageReconnectTimeout < time.getUnixTime() - this.lastMessageReceived) {

@@ -11,2 +11,3 @@ /**

import * as binary from './binary.js'
import * as string from './string.js'

@@ -249,11 +250,4 @@ /**

*/
export const writeVarString = (encoder, str) => {
const encodedString = unescape(encodeURIComponent(str))
const len = encodedString.length
writeVarUint(encoder, len)
for (let i = 0; i < len; i++) {
// @ts-ignore
write(encoder, encodedString.codePointAt(i))
}
}
export const writeVarString = (encoder, str) =>
writeVarUint8Array(encoder, string.encodeUtf8(str))

@@ -260,0 +254,0 @@ /**

{
"name": "lib0",
"version": "0.1.5",
"version": "0.1.6",
"description": "",

@@ -5,0 +5,0 @@ "dependencies": {},

@@ -36,1 +36,63 @@ /**

export const utf8ByteLength = str => unescape(encodeURIComponent(str)).length
/**
* @param {string} str
* @return {Uint8Array}
*/
export const _encodeUtf8Polyfill = str => {
const encodedString = unescape(encodeURIComponent(str))
const len = encodedString.length
const buf = new Uint8Array(len)
for (let i = 0; i < len; i++) {
buf[i] = /** @type {number} */ (encodedString.codePointAt(i))
}
return buf
}
export const utf8TextEncoder = typeof TextEncoder !== 'undefined' ? new TextEncoder() : null
/**
* @param {string} str
* @return {Uint8Array}
*/
export const _encodeUtf8Native = str => /** @type {TextEncoder} */ (utf8TextEncoder).encode(str)
/**
* @param {string} str
* @return {Uint8Array}
*/
export const encodeUtf8 = utf8TextEncoder ? _encodeUtf8Native : _encodeUtf8Polyfill
/**
* @param {Uint8Array} buf
* @return {string}
*/
export const _decodeUtf8Polyfill = buf => {
let remainingLen = buf.length
let encodedString = ''
let bufPos = 0
while (remainingLen > 0) {
const nextLen = remainingLen < 10000 ? remainingLen : 10000
const bytes = new Array(nextLen)
for (let i = 0; i < nextLen; i++) {
bytes[i] = buf[bufPos++]
}
encodedString += String.fromCodePoint.apply(null, bytes)
remainingLen -= nextLen
}
return decodeURIComponent(escape(encodedString))
}
export const utf8TextDecoder = typeof TextDecoder === 'undefined' ? null : new TextDecoder('utf-8', { fatal: true })
/**
* @param {Uint8Array} buf
* @return {string}
*/
export const _decodeUtf8Native = buf => /** @type {TextDecoder} */ (utf8TextDecoder).decode(buf)
/**
* @param {Uint8Array} buf
* @return {string}
*/
export const decodeUtf8 = utf8TextDecoder ? _decodeUtf8Native : _decodeUtf8Polyfill

@@ -174,5 +174,5 @@ /**

* @param {string} message
* @param {function():void} f
* @param {function():void|Promise} f
*/
export const measureTime = (message, f) => {
export const measureTime = async (message, f) => {
let duration = 0

@@ -182,3 +182,6 @@ let iterations = 0

while (duration < 5) {
f()
const p = f()
if (p) {
await p
}
duration = perf.now() - start

@@ -185,0 +188,0 @@ iterations++

@@ -75,3 +75,2 @@ /* eslint-env browser */

wsclient.emit('connect', [{ type: 'connect' }, wsclient])
wsclient.afterOpen.forEach(m => wsclient.send(m(wsclient)))
// set ping

@@ -109,7 +108,2 @@ pingTimeout = setTimeout(sendPing, messageReconnectTimeout / 2)

this.shouldConnect = true
/**
* Array of functions that create messages that will be sent after a connection is opened
* @type {Array<function(WebsocketClient):any>}
*/
this.afterOpen = []
this._checkInterval = setInterval(() => {

@@ -116,0 +110,0 @@ if (this.connected && messageReconnectTimeout < time.getUnixTime() - this.lastMessageReceived) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc