massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-json / node_modules / vscode-json-languageservice / lib / umd / utils / objects.js
1 /*---------------------------------------------------------------------------------------------
2 *  Copyright (c) Microsoft Corporation. All rights reserved.
3 *  Licensed under the MIT License. See License.txt in the project root for license information.
4 *--------------------------------------------------------------------------------------------*/
5 (function (factory) {
6     if (typeof module === "object" && typeof module.exports === "object") {
7         var v = factory(require, exports);
8         if (v !== undefined) module.exports = v;
9     }
10     else if (typeof define === "function" && define.amd) {
11         define(["require", "exports"], factory);
12     }
13 })(function (require, exports) {
14     "use strict";
15     Object.defineProperty(exports, "__esModule", { value: true });
16     exports.isString = exports.isBoolean = exports.isDefined = exports.isNumber = exports.equals = void 0;
17     function equals(one, other) {
18         if (one === other) {
19             return true;
20         }
21         if (one === null || one === undefined || other === null || other === undefined) {
22             return false;
23         }
24         if (typeof one !== typeof other) {
25             return false;
26         }
27         if (typeof one !== 'object') {
28             return false;
29         }
30         if ((Array.isArray(one)) !== (Array.isArray(other))) {
31             return false;
32         }
33         var i, key;
34         if (Array.isArray(one)) {
35             if (one.length !== other.length) {
36                 return false;
37             }
38             for (i = 0; i < one.length; i++) {
39                 if (!equals(one[i], other[i])) {
40                     return false;
41                 }
42             }
43         }
44         else {
45             var oneKeys = [];
46             for (key in one) {
47                 oneKeys.push(key);
48             }
49             oneKeys.sort();
50             var otherKeys = [];
51             for (key in other) {
52                 otherKeys.push(key);
53             }
54             otherKeys.sort();
55             if (!equals(oneKeys, otherKeys)) {
56                 return false;
57             }
58             for (i = 0; i < oneKeys.length; i++) {
59                 if (!equals(one[oneKeys[i]], other[oneKeys[i]])) {
60                     return false;
61                 }
62             }
63         }
64         return true;
65     }
66     exports.equals = equals;
67     function isNumber(val) {
68         return typeof val === 'number';
69     }
70     exports.isNumber = isNumber;
71     function isDefined(val) {
72         return typeof val !== 'undefined';
73     }
74     exports.isDefined = isDefined;
75     function isBoolean(val) {
76         return typeof val === 'boolean';
77     }
78     exports.isBoolean = isBoolean;
79     function isString(val) {
80         return typeof val === 'string';
81     }
82     exports.isString = isString;
83 });