UNPKG

1.85 kBJavaScriptView Raw
1"use strict";
2// *****************************************************************************
3// Copyright (C) 2018 TypeFox and others.
4//
5// This program and the accompanying materials are made available under the
6// terms of the Eclipse Public License v. 2.0 which is available at
7// http://www.eclipse.org/legal/epl-2.0.
8//
9// This Source Code may also be made available under the following Secondary
10// Licenses when the conditions for such availability set forth in the Eclipse
11// Public License v. 2.0 are satisfied: GNU General Public License, version 2
12// with the GNU Classpath Exception which is available at
13// https://www.gnu.org/software/classpath/license.html.
14//
15// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16// *****************************************************************************
17Object.defineProperty(exports, "__esModule", { value: true });
18exports.UriSelection = void 0;
19const types_1 = require("./types");
20const uri_1 = require("./uri");
21var UriSelection;
22(function (UriSelection) {
23 function is(arg) {
24 return (0, types_1.isObject)(arg) && arg.uri instanceof uri_1.default;
25 }
26 UriSelection.is = is;
27 function getUri(selection) {
28 if (is(selection)) {
29 return selection.uri;
30 }
31 if (Array.isArray(selection) && is(selection[0])) {
32 return selection[0].uri;
33 }
34 return undefined;
35 }
36 UriSelection.getUri = getUri;
37 function getUris(selection) {
38 if (is(selection)) {
39 return [selection.uri];
40 }
41 if (Array.isArray(selection)) {
42 return selection.filter(is).map(s => s.uri);
43 }
44 return [];
45 }
46 UriSelection.getUris = getUris;
47})(UriSelection = exports.UriSelection || (exports.UriSelection = {}));
48//# sourceMappingURL=selection.js.map
\No newline at end of file