执行过npm install命令的vue-element-admin源码
康凯
2022-05-20 aa4c235a8ca67ea8b731f90c951a465e92c0a865
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
/**
 * @fileoverview This module provides some functions to check the type of variable
 * @author NHN.
 *         FE Development Lab <dl_javascript@nhn.com>
 */
 
'use strict';
 
var toString = Object.prototype.toString;
 
/**
 * Check whether the given variable is existing or not.<br>
 *  If the given variable is not null and not undefined, returns true.
 * @param {*} param - Target for checking
 * @returns {boolean} Is existy?
 * @memberof tui.util
 * @example
 * //-- #1. Get Module --//
 * var util = require('tui-code-snippet'); // node, commonjs
 * var util = tui.util; // distribution file
 *
 * //-- #2. Use property --//
 * util.isExisty(''); //true
 * util.isExisty(0); //true
 * util.isExisty([]); //true
 * util.isExisty({}); //true
 * util.isExisty(null); //false
 * util.isExisty(undefined); //false
*/
function isExisty(param) {
    return !isUndefined(param) && !isNull(param);
}
 
/**
 * Check whether the given variable is undefined or not.<br>
 *  If the given variable is undefined, returns true.
 * @param {*} obj - Target for checking
 * @returns {boolean} Is undefined?
 * @memberof tui.util
 */
function isUndefined(obj) {
    return obj === undefined; // eslint-disable-line no-undefined
}
 
/**
 * Check whether the given variable is null or not.<br>
 *  If the given variable(arguments[0]) is null, returns true.
 * @param {*} obj - Target for checking
 * @returns {boolean} Is null?
 * @memberof tui.util
 */
function isNull(obj) {
    return obj === null;
}
 
/**
 * Check whether the given variable is truthy or not.<br>
 *  If the given variable is not null or not undefined or not false, returns true.<br>
 *  (It regards 0 as true)
 * @param {*} obj - Target for checking
 * @returns {boolean} Is truthy?
 * @memberof tui.util
 */
function isTruthy(obj) {
    return isExisty(obj) && obj !== false;
}
 
/**
 * Check whether the given variable is falsy or not.<br>
 *  If the given variable is null or undefined or false, returns true.
 * @param {*} obj - Target for checking
 * @returns {boolean} Is falsy?
 * @memberof tui.util
 */
function isFalsy(obj) {
    return !isTruthy(obj);
}
 
/**
 * Check whether the given variable is an arguments object or not.<br>
 *  If the given variable is an arguments object, return true.
 * @param {*} obj - Target for checking
 * @returns {boolean} Is arguments?
 * @memberof tui.util
 */
function isArguments(obj) {
    var result = isExisty(obj) &&
        ((toString.call(obj) === '[object Arguments]') || !!obj.callee);
 
    return result;
}
 
/**
 * Check whether the given variable is an instance of Array or not.<br>
 *  If the given variable is an instance of Array, return true.
 * @param {*} obj - Target for checking
 * @returns {boolean} Is array instance?
 * @memberof tui.util
 */
function isArray(obj) {
    return obj instanceof Array;
}
 
/**
 * Check whether the given variable is an object or not.<br>
 *  If the given variable is an object, return true.
 * @param {*} obj - Target for checking
 * @returns {boolean} Is object?
 * @memberof tui.util
 */
function isObject(obj) {
    return obj === Object(obj);
}
 
/**
 * Check whether the given variable is a function or not.<br>
 *  If the given variable is a function, return true.
 * @param {*} obj - Target for checking
 * @returns {boolean} Is function?
 * @memberof tui.util
 */
function isFunction(obj) {
    return obj instanceof Function;
}
 
/**
 * Check whether the given variable is a number or not.<br>
 *  If the given variable is a number, return true.
 * @param {*} obj - Target for checking
 * @returns {boolean} Is number?
 * @memberof tui.util
 */
function isNumber(obj) {
    return typeof obj === 'number' || obj instanceof Number;
}
 
/**
 * Check whether the given variable is a string or not.<br>
 *  If the given variable is a string, return true.
 * @param {*} obj - Target for checking
 * @returns {boolean} Is string?
 * @memberof tui.util
 */
function isString(obj) {
    return typeof obj === 'string' || obj instanceof String;
}
 
/**
 * Check whether the given variable is a boolean or not.<br>
 *  If the given variable is a boolean, return true.
 * @param {*} obj - Target for checking
 * @returns {boolean} Is boolean?
 * @memberof tui.util
 */
function isBoolean(obj) {
    return typeof obj === 'boolean' || obj instanceof Boolean;
}
 
/**
 * Check whether the given variable is an instance of Array or not.<br>
 *  If the given variable is an instance of Array, return true.<br>
 *  (It is used for multiple frame environments)
 * @param {*} obj - Target for checking
 * @returns {boolean} Is an instance of array?
 * @memberof tui.util
 */
function isArraySafe(obj) {
    return toString.call(obj) === '[object Array]';
}
 
/**
 * Check whether the given variable is a function or not.<br>
 *  If the given variable is a function, return true.<br>
 *  (It is used for multiple frame environments)
 * @param {*} obj - Target for checking
 * @returns {boolean} Is a function?
 * @memberof tui.util
 */
function isFunctionSafe(obj) {
    return toString.call(obj) === '[object Function]';
}
 
/**
 * Check whether the given variable is a number or not.<br>
 *  If the given variable is a number, return true.<br>
 *  (It is used for multiple frame environments)
 * @param {*} obj - Target for checking
 * @returns {boolean} Is a number?
 * @memberof tui.util
 */
function isNumberSafe(obj) {
    return toString.call(obj) === '[object Number]';
}
 
/**
 * Check whether the given variable is a string or not.<br>
 *  If the given variable is a string, return true.<br>
 *  (It is used for multiple frame environments)
 * @param {*} obj - Target for checking
 * @returns {boolean} Is a string?
 * @memberof tui.util
 */
function isStringSafe(obj) {
    return toString.call(obj) === '[object String]';
}
 
/**
 * Check whether the given variable is a boolean or not.<br>
 *  If the given variable is a boolean, return true.<br>
 *  (It is used for multiple frame environments)
 * @param {*} obj - Target for checking
 * @returns {boolean} Is a boolean?
 * @memberof tui.util
 */
function isBooleanSafe(obj) {
    return toString.call(obj) === '[object Boolean]';
}
 
/**
 * Check whether the given variable is a instance of HTMLNode or not.<br>
 *  If the given variables is a instance of HTMLNode, return true.
 * @param {*} html - Target for checking
 * @returns {boolean} Is HTMLNode ?
 * @memberof tui.util
 */
function isHTMLNode(html) {
    if (typeof HTMLElement === 'object') {
        return (html && (html instanceof HTMLElement || !!html.nodeType));
    }
 
    return !!(html && html.nodeType);
}
 
/**
 * Check whether the given variable is a HTML tag or not.<br>
 *  If the given variables is a HTML tag, return true.
 * @param {*} html - Target for checking
 * @returns {Boolean} Is HTML tag?
 * @memberof tui.util
 */
function isHTMLTag(html) {
    if (typeof HTMLElement === 'object') {
        return (html && (html instanceof HTMLElement));
    }
 
    return !!(html && html.nodeType && html.nodeType === 1);
}
 
/**
 * Check whether the given variable is empty(null, undefined, or empty array, empty object) or not.<br>
 *  If the given variables is empty, return true.
 * @param {*} obj - Target for checking
 * @returns {boolean} Is empty?
 * @memberof tui.util
 */
function isEmpty(obj) {
    if (!isExisty(obj) || _isEmptyString(obj)) {
        return true;
    }
 
    if (isArray(obj) || isArguments(obj)) {
        return obj.length === 0;
    }
 
    if (isObject(obj) && !isFunction(obj)) {
        return !_hasOwnProperty(obj);
    }
 
    return true;
}
 
/**
 * Check whether given argument is empty string
 * @param {*} obj - Target for checking
 * @returns {boolean} whether given argument is empty string
 * @memberof tui.util
 * @private
 */
function _isEmptyString(obj) {
    return isString(obj) && obj === '';
}
 
/**
 * Check whether given argument has own property
 * @param {Object} obj - Target for checking
 * @returns {boolean} - whether given argument has own property
 * @memberof tui.util
 * @private
 */
function _hasOwnProperty(obj) {
    var key;
    for (key in obj) {
        if (obj.hasOwnProperty(key)) {
            return true;
        }
    }
 
    return false;
}
 
/**
 * Check whether the given variable is not empty
 * (not null, not undefined, or not empty array, not empty object) or not.<br>
 *  If the given variables is not empty, return true.
 * @param {*} obj - Target for checking
 * @returns {boolean} Is not empty?
 * @memberof tui.util
 */
function isNotEmpty(obj) {
    return !isEmpty(obj);
}
 
/**
 * Check whether the given variable is an instance of Date or not.<br>
 *  If the given variables is an instance of Date, return true.
 * @param {*} obj - Target for checking
 * @returns {boolean} Is an instance of Date?
 * @memberof tui.util
 */
function isDate(obj) {
    return obj instanceof Date;
}
 
/**
 * Check whether the given variable is an instance of Date or not.<br>
 *  If the given variables is an instance of Date, return true.<br>
 *  (It is used for multiple frame environments)
 * @param {*} obj - Target for checking
 * @returns {boolean} Is an instance of Date?
 * @memberof tui.util
 */
function isDateSafe(obj) {
    return toString.call(obj) === '[object Date]';
}
 
module.exports = {
    isExisty: isExisty,
    isUndefined: isUndefined,
    isNull: isNull,
    isTruthy: isTruthy,
    isFalsy: isFalsy,
    isArguments: isArguments,
    isArray: isArray,
    isArraySafe: isArraySafe,
    isObject: isObject,
    isFunction: isFunction,
    isFunctionSafe: isFunctionSafe,
    isNumber: isNumber,
    isNumberSafe: isNumberSafe,
    isDate: isDate,
    isDateSafe: isDateSafe,
    isString: isString,
    isStringSafe: isStringSafe,
    isBoolean: isBoolean,
    isBooleanSafe: isBooleanSafe,
    isHTMLNode: isHTMLNode,
    isHTMLTag: isHTMLTag,
    isEmpty: isEmpty,
    isNotEmpty: isNotEmpty
};