UNPKG

vscode-languageserver-protocol

Version:
46 lines (45 loc) 1.64 kB
/* -------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. * ------------------------------------------------------------------------------------------ */ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.boolean = boolean; exports.string = string; exports.number = number; exports.error = error; exports.func = func; exports.array = array; exports.stringArray = stringArray; exports.typedArray = typedArray; exports.objectLiteral = objectLiteral; function boolean(value) { return value === true || value === false; } function string(value) { return typeof value === 'string' || value instanceof String; } function number(value) { return typeof value === 'number' || value instanceof Number; } function error(value) { return value instanceof Error; } function func(value) { return typeof value === 'function'; } function array(value) { return Array.isArray(value); } function stringArray(value) { return array(value) && value.every(elem => string(elem)); } function typedArray(value, check) { return Array.isArray(value) && value.every(check); } function objectLiteral(value) { // Strictly speaking class instances pass this check as well. Since the LSP // doesn't use classes we ignore this for now. If we do we need to add something // like this: `Object.getPrototypeOf(Object.getPrototypeOf(x)) === null` return value !== null && typeof value === 'object'; }