New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

libzap

Package Overview
Dependencies
Maintainers
1
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libzap - npm Package Compare versions

Comparing version 0.0.44 to 0.0.45

1

lib/ot/workspace.d.ts

@@ -27,2 +27,3 @@ import { EditOps } from "./textDoc";

};
export declare function toString(op: WorkspaceOp, maxLengthPerItem?: number): string;
export declare function emptyMap(v?: {

@@ -29,0 +30,0 @@ [file: string]: string;

@@ -11,2 +11,49 @@ "use strict";

const stringify_1 = require("../util/stringify");
function toString(op, maxLengthPerItem = 50) {
const parts = [];
if (op.copy) {
parts.push(`copy(${mapToString(op.copy, undefined)})`);
}
if (op.rename) {
parts.push(`rename(${mapToString(op.rename, undefined)})`);
}
if (op.save) {
parts.push(`save(${op.save.join(" ")})`);
}
if (op.create) {
parts.push(`create(${op.create.join(" ")})`);
}
if (op.delete) {
parts.push(`delete(${op.delete.join(" ")})`);
}
if (op.edit) {
parts.push(`edit(${mapToString(op.edit, maxLengthPerItem)})`);
}
if (op.sel) {
parts.push(`sel(${mapToString(op.sel, maxLengthPerItem)})`);
}
if (op.head) {
parts.push(`head(${op.head})`);
}
return `{${parts.join(" ")}}`;
}
exports.toString = toString;
function mapToString(map, maxLengthPerItem) {
return Object.keys(map).sort().map(key => {
let rhs = typeof map[key] === "string" ? map[key] : truncate(map[key], maxLengthPerItem);
return `${key}:${rhs}`;
}).join(" ");
}
function truncate(v, maxLength) {
if (typeof v === "number") {
return v;
}
if (typeof v === "string") {
if (maxLength) {
return v.length > maxLength ? (v.slice(0, maxLength) + "…") : v;
}
return v;
}
return JSON.stringify(v.map ? v.map(e => truncate(e, maxLength)) : v);
}
function emptyArray(v) {

@@ -13,0 +60,0 @@ return v === undefined || (typeof v.length === "number" && v.length === 0);

11

lib/remote/handler.js

@@ -12,2 +12,3 @@ "use strict";

const client_1 = require("../ot/client");
const workspace_1 = require("../ot/workspace");
const client_2 = require("./client");

@@ -184,3 +185,3 @@ const protocol_1 = require("./protocol");

this.ot.send = (rev, op) => {
this.send(rev, op).then(() => { }, err => { console.error(`ERROR: op ${JSON.stringify(op)} sending failed: ${err}`); });
this.send(rev, op).then(() => { }, err => { console.error(`ERROR: op ${workspace_1.toString(op)} sending failed: ${err}`); });
};

@@ -199,3 +200,3 @@ }

if (process.env.DEV) {
console.log(`Client=${process.env.ZAP_E2E_NAME} SEND:${this.refID.ref} @${rev} ${JSON.stringify(op)} failures=${failures}`);
console.log(`Client=${process.env.ZAP_E2E_NAME} SEND:${this.refID.ref} @${rev} ${workspace_1.toString(op)} failures=${failures}`);
}

@@ -217,3 +218,3 @@ yield this.remoteClient.sendRequest(protocol_1.RefUpdateUpstreamRequest.type, {

if (failures === maxFailures) {
throw new Error(`send failed ${failures} times: ${err} (rev ${rev}, op ${JSON.stringify(op)})`);
throw new Error(`send failed ${failures} times: ${err} (rev ${rev}, op ${workspace_1.toString(op)})`);
}

@@ -224,3 +225,3 @@ if (!this.mergeStrategy || this.mergeStrategy === MergeStrategy.RemoteClobbersLocal) {

const t0 = Date.now();
console.error(`Error sending ${JSON.stringify(op)} at rev ${rev}: ${err}. Merge strategy is ${MergeStrategy[this.mergeStrategy]}. Will retry...`);
console.error(`Error sending ${workspace_1.toString(op)} at rev ${rev}: ${err}. Merge strategy is ${MergeStrategy[this.mergeStrategy]}. Will retry...`);
const clientIsReadyAgain = new Promise(resolve => {

@@ -340,3 +341,3 @@ this.remoteClient.onDidChangeState((event) => {

if (process.env.DEV) {
console.log(`Client=${process.env.ZAP_E2E_NAME} RECV:${this.refID.ref} @${this.ot.rev} ${JSON.stringify(params.op)}`);
console.log(`Client=${process.env.ZAP_E2E_NAME} RECV:${this.refID.ref} @${this.ot.rev} ${workspace_1.toString(params.op)}`);
}

@@ -343,0 +344,0 @@ yield this.ot.recv(params.op);

{
"name": "libzap",
"version": "0.0.44",
"version": "0.0.45",
"description": "JavaScript library for Zap",

@@ -36,3 +36,3 @@ "license": "none",

"tslint": "^4.1.0",
"typescript": "^2.1.5"
"typescript": "^2.1.6"
},

@@ -39,0 +39,0 @@ "engines": {

@@ -32,2 +32,55 @@ import * as cloneDeep from "lodash/cloneDeep";

/**
* toString returns a human-readable string representation of op. It
* truncates it to maxLength characters.
*/
export function toString(op: WorkspaceOp, maxLengthPerItem: number = 50): string {
const parts: string[] = [];
if (op.copy) {
parts.push(`copy(${mapToString(op.copy, undefined)})`);
}
if (op.rename) {
parts.push(`rename(${mapToString(op.rename, undefined)})`);
}
if (op.save) {
parts.push(`save(${op.save.join(" ")})`);
}
if (op.create) {
parts.push(`create(${op.create.join(" ")})`);
}
if (op.delete) {
parts.push(`delete(${op.delete.join(" ")})`);
}
if (op.edit) {
parts.push(`edit(${mapToString(op.edit, maxLengthPerItem)})`);
}
if (op.sel) {
parts.push(`sel(${mapToString(op.sel, maxLengthPerItem)})`);
}
if (op.head) {
parts.push(`head(${op.head})`);
}
return `{${parts.join(" ")}}`;
}
function mapToString(map: { [key: string]: any }, maxLengthPerItem: number | undefined): string {
return Object.keys(map).sort().map(key => {
let rhs = typeof map[key] === "string" ? map[key] : truncate(map[key], maxLengthPerItem);
return `${key}:${rhs}`;
}).join(" ");
}
function truncate(v: string | number | (string | number)[], maxLength: number | undefined): string | number {
if (typeof v === "number") {
return v;
}
if (typeof v === "string") {
if (maxLength) {
return v.length > maxLength ? (v.slice(0, maxLength) + "…") : v;
}
return v;
}
return JSON.stringify(v.map ? v.map(e => truncate(e, maxLength)) : v);
}
function emptyArray(v?: string[]): v is undefined {

@@ -34,0 +87,0 @@ return v === undefined || (typeof v.length === "number" && v.length === 0);

import { Emitter, Event } from "vscode-jsonrpc";
import { Client as OTClient } from "../ot/client";
import { WorkspaceOp } from "../ot/workspace";
import { WorkspaceOp, toString as opToString } from "../ot/workspace";
import { Client, State, StateChangeEvent } from "./client";

@@ -257,3 +257,3 @@ import { IConnection } from "./connection";

() => { /* noop */ },
err => { console.error(`ERROR: op ${JSON.stringify(op)} sending failed: ${err}`); },
err => { console.error(`ERROR: op ${opToString(op)} sending failed: ${err}`); },
);

@@ -273,3 +273,3 @@ };

await this.remoteClient.onReady();
if (process.env.DEV) { console.log(`Client=${process.env.ZAP_E2E_NAME} SEND:${this.refID.ref} @${rev} ${JSON.stringify(op)} failures=${failures}`); }
if (process.env.DEV) { console.log(`Client=${process.env.ZAP_E2E_NAME} SEND:${this.refID.ref} @${rev} ${opToString(op)} failures=${failures}`); }
await this.remoteClient.sendRequest(RefUpdateUpstreamRequest.type, {

@@ -289,3 +289,3 @@ repo: this.refID.repo,

if (failures === maxFailures) {
throw new Error(`send failed ${failures} times: ${err} (rev ${rev}, op ${JSON.stringify(op)})`);
throw new Error(`send failed ${failures} times: ${err} (rev ${rev}, op ${opToString(op)})`);
}

@@ -298,3 +298,3 @@

const t0 = Date.now();
console.error(`Error sending ${JSON.stringify(op)} at rev ${rev}: ${err}. Merge strategy is ${MergeStrategy[this.mergeStrategy]}. Will retry...`);
console.error(`Error sending ${opToString(op)} at rev ${rev}: ${err}. Merge strategy is ${MergeStrategy[this.mergeStrategy]}. Will retry...`);

@@ -423,3 +423,3 @@ // Wait until the client is ready again to resend.

} else if (params.op) {
if (process.env.DEV) { console.log(`Client=${process.env.ZAP_E2E_NAME} RECV:${this.refID.ref} @${this.ot.rev} ${JSON.stringify(params.op)}`); }
if (process.env.DEV) { console.log(`Client=${process.env.ZAP_E2E_NAME} RECV:${this.refID.ref} @${this.ot.rev} ${opToString(params.op)}`); }
await this.ot.recv(params.op);

@@ -426,0 +426,0 @@ } else if (params.delete) {

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