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

@eclipse-glsp/protocol

Package Overview
Dependencies
Maintainers
5
Versions
310
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eclipse-glsp/protocol - npm Package Compare versions

Comparing version 0.10.0-next.385713d.170 to 0.10.0-next.4268ced.175

1

lib/model/default-types.d.ts

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

const LABEL = "label";
const BUTTON = "button";
const BUTTON_EXPAND = "button:expand";

@@ -36,0 +37,0 @@ const ISSUE_MARKER = "marker";

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

// UI elements
DefaultTypes.BUTTON = 'button';
DefaultTypes.BUTTON_EXPAND = 'button:expand';

@@ -45,0 +46,0 @@ DefaultTypes.ISSUE_MARKER = 'marker';

36

lib/utils/array-util.d.ts

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

********************************************************************************/
import { Constructor, Primitive } from './type-util';
/**

@@ -26,11 +27,31 @@ * A union type for for objects that can either be a single element or and array of elements.

*/
export declare function first<T>(array: T[]): number;
export declare function first<T>(array: T[]): T;
/**
* Returns the first n elements of the given array.
* @param array the array.
* @param n the number of elements that should be returned
* @returns the first n elements of the array
* @param array The array.
* @param n The number of elements that should be returned
* @returns The first n elements of the array
*/
export declare function first<T>(array: T[], n: number): T[];
/**
* Returns the last element of the given array.
* @param array The array.
* @returns The last element in the array.
*/
export declare function last<T>(array: T[]): T;
/**
* Returns the last n elements of the given array.
* @param array The array.
* @param n The number of elements that should be returned
* @returns The last n elements of the array
*/
export declare function last<T>(array: T[], n: number): T[];
/**
* Plucks (i.e. extracts) the property value that corresponds to the given key from all objects of the array.
* @param array The array which should be plucked.
* @param key The key of the property that should be extracted.
* @returns A new array containing the plugged property for each element of the array.
*/
export declare function pluck<T, K extends keyof T>(array: T[], key: K): Array<T[K]>;
/**
* Removes the given values from the given array (if present).

@@ -56,6 +77,2 @@ * @param array The array to execute the remove operation on.

export declare function distinctAdd<T>(array: T[], ...values: T[]): void;
interface Constructor<T> {
new (...args: any[]): T;
}
declare type PrimitiveType = 'bigint' | 'boolean' | 'function' | 'number' | 'object' | 'string' | 'symbol' | 'undefined';
/**

@@ -87,3 +104,3 @@ * A typeguard function to check wether a given object is an array of a specific type `T`. As it checks the type of each individual

*/
export declare function isArrayOfPrimitive<T>(object: any, primitiveType: PrimitiveType, supportEmpty?: boolean): object is T[];
export declare function isArrayOfPrimitive<T>(object: any, primitiveType: Primitive, supportEmpty?: boolean): object is T[];
/**

@@ -105,3 +122,2 @@ * A typeguard function to check wether a given object is an array of a strings. As it checks the type of each individual

export declare function isArrayMatching(object: any, predicate: (elem: any) => boolean, supportEmpty?: boolean): boolean;
export {};
//# sourceMappingURL=array-util.d.ts.map
"use strict";
/********************************************************************************
* Copyright (c) 2019-2022 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
Object.defineProperty(exports, "__esModule", { value: true });
exports.isArrayMatching = exports.isStringArray = exports.isArrayOfPrimitive = exports.isArrayOfClass = exports.isArrayOfType = exports.distinctAdd = exports.flatPush = exports.remove = exports.first = void 0;
exports.isArrayMatching = exports.isStringArray = exports.isArrayOfPrimitive = exports.isArrayOfClass = exports.isArrayOfType = exports.distinctAdd = exports.flatPush = exports.remove = exports.pluck = exports.last = exports.first = void 0;
function first(array, n) {

@@ -11,3 +26,20 @@ if (n) {

exports.first = first;
function last(array, n) {
if (n) {
return array.filter((_, index) => array.length - index <= n);
}
return array[array.length - 1];
}
exports.last = last;
/**
* Plucks (i.e. extracts) the property value that corresponds to the given key from all objects of the array.
* @param array The array which should be plucked.
* @param key The key of the property that should be extracted.
* @returns A new array containing the plugged property for each element of the array.
*/
function pluck(array, key) {
return array.map(element => element[key]);
}
exports.pluck = pluck;
/**
* Removes the given values from the given array (if present).

@@ -14,0 +46,0 @@ * @param array The array to execute the remove operation on.

@@ -31,2 +31,20 @@ /********************************************************************************

/**
* Utility type to capture all primitive types.
*/
export declare type Primitive = string | number | boolean | bigint | symbol | undefined | null;
/**
* Utility type to describe objects that have a constructor function i.e. classes.
*/
export interface Constructor<T> {
new (...args: any[]): T;
}
/**
* Utility type to declare a given type `T` as writable. Essentially this removes
* all readonly modifiers of the type`s properties. Please use with care and only in instances
* where you know that overwriting a readonly property is safe and doesn't cause any unintended side effects.
*/
export declare type Writable<T> = {
-readonly [P in keyof T]: Writable<T[P]>;
};
/**
* Utility type to describe typeguard functions.

@@ -36,2 +54,9 @@ */

/**
* Utility function that create a typeguard function for a given class constructor.
* Essentially this wraps an instance of check as typeguard function.
* @param constructor The constructor fo the class for which the typeguard should be created.
* @returns The typeguard for this class.
*/
export declare function toTypeGuard<G>(constructor: Constructor<G>): TypeGuard<G>;
/**
* Validates whether the given object as a property of type `string` with the given key.

@@ -38,0 +63,0 @@ * @param object The object that should be validated

@@ -18,3 +18,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.hasArrayProp = exports.hasObjectProp = exports.hasNumberProp = exports.hasBooleanProp = exports.hasStringProp = exports.AnyObject = void 0;
exports.hasArrayProp = exports.hasObjectProp = exports.hasNumberProp = exports.hasBooleanProp = exports.hasStringProp = exports.toTypeGuard = exports.AnyObject = void 0;
var AnyObject;

@@ -34,2 +34,12 @@ (function (AnyObject) {

/**
* Utility function that create a typeguard function for a given class constructor.
* Essentially this wraps an instance of check as typeguard function.
* @param constructor The constructor fo the class for which the typeguard should be created.
* @returns The typeguard for this class.
*/
function toTypeGuard(constructor) {
return (element) => element instanceof constructor;
}
exports.toTypeGuard = toTypeGuard;
/**
* Validates whether the given object as a property of type `string` with the given key.

@@ -36,0 +46,0 @@ * @param object The object that should be validated

{
"name": "@eclipse-glsp/protocol",
"version": "0.10.0-next.385713d.170+385713d",
"version": "0.10.0-next.4268ced.175+4268ced",
"description": "The protocol definition for client-server communication in GLSP",

@@ -57,3 +57,3 @@ "license": "(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)",

"types": "lib/index",
"gitHead": "385713d3bc42d68a1066243341e7bc6a0a9fca68"
"gitHead": "4268cedc5a3e1d0ad278fc12a1222e70f051048a"
}

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

// UI elements
export const BUTTON = 'button';
export const BUTTON_EXPAND = 'button:expand';

@@ -46,0 +47,0 @@ export const ISSUE_MARKER = 'marker';

@@ -16,2 +16,5 @@ /********************************************************************************

********************************************************************************/
import { Constructor, Primitive } from './type-util';
/**

@@ -27,8 +30,9 @@ * A union type for for objects that can either be a single element or and array of elements.

*/
export function first<T>(array: T[]): number;
export function first<T>(array: T[]): T;
/**
* Returns the first n elements of the given array.
* @param array the array.
* @param n the number of elements that should be returned
* @returns the first n elements of the array
* @param array The array.
* @param n The number of elements that should be returned
* @returns The first n elements of the array
*/

@@ -44,2 +48,33 @@ export function first<T>(array: T[], n: number): T[];

/**
* Returns the last element of the given array.
* @param array The array.
* @returns The last element in the array.
*/
export function last<T>(array: T[]): T;
/**
* Returns the last n elements of the given array.
* @param array The array.
* @param n The number of elements that should be returned
* @returns The last n elements of the array
*/
export function last<T>(array: T[], n: number): T[];
export function last<T>(array: T[], n?: number): T[] | T {
if (n) {
return array.filter((_, index) => array.length - index <= n);
}
return array[array.length - 1];
}
/**
* Plucks (i.e. extracts) the property value that corresponds to the given key from all objects of the array.
* @param array The array which should be plucked.
* @param key The key of the property that should be extracted.
* @returns A new array containing the plugged property for each element of the array.
*/
export function pluck<T, K extends keyof T>(array: T[], key: K): Array<T[K]> {
return array.map(element => element[key]);
}
/**
* Removes the given values from the given array (if present).

@@ -82,6 +117,2 @@ * @param array The array to execute the remove operation on.

}
interface Constructor<T> {
new (...args: any[]): T;
}
type PrimitiveType = 'bigint' | 'boolean' | 'function' | 'number' | 'object' | 'string' | 'symbol' | 'undefined';

@@ -120,3 +151,3 @@ /**

*/
export function isArrayOfPrimitive<T>(object: any, primitiveType: PrimitiveType, supportEmpty = false): object is T[] {
export function isArrayOfPrimitive<T>(object: any, primitiveType: Primitive, supportEmpty = false): object is T[] {
return isArrayMatching(object, element => typeof element === primitiveType, supportEmpty);

@@ -123,0 +154,0 @@ }

@@ -37,2 +37,22 @@ /********************************************************************************

/**
* Utility type to capture all primitive types.
*/
export type Primitive = string | number | boolean | bigint | symbol | undefined | null;
/**
* Utility type to describe objects that have a constructor function i.e. classes.
*/
export interface Constructor<T> {
new (...args: any[]): T;
}
/**
* Utility type to declare a given type `T` as writable. Essentially this removes
* all readonly modifiers of the type`s properties. Please use with care and only in instances
* where you know that overwriting a readonly property is safe and doesn't cause any unintended side effects.
*/
// eslint-disable-next-line @typescript-eslint/ban-types
export type Writable<T> = { -readonly [P in keyof T]: Writable<T[P]> };
/**
* Utility type to describe typeguard functions.

@@ -43,2 +63,12 @@ */

/**
* Utility function that create a typeguard function for a given class constructor.
* Essentially this wraps an instance of check as typeguard function.
* @param constructor The constructor fo the class for which the typeguard should be created.
* @returns The typeguard for this class.
*/
export function toTypeGuard<G>(constructor: Constructor<G>): TypeGuard<G> {
return (element: any): element is G => element instanceof constructor;
}
/**
* Validates whether the given object as a property of type `string` with the given key.

@@ -45,0 +75,0 @@ * @param object The object that should be validated

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 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