UNPKG

1.56 kBJavaScriptView Raw
1function isObject(o) {
2 return typeof o === 'object' && o !== null && o.constructor && Object.prototype.toString.call(o).slice(8, -1) === 'Object';
3}
4
5function extend(target, src) {
6 const noExtend = ['__proto__', 'constructor', 'prototype'];
7 Object.keys(src).filter(key => noExtend.indexOf(key) < 0).forEach(key => {
8 if (typeof target[key] === 'undefined') target[key] = src[key];else if (isObject(src[key]) && isObject(target[key]) && Object.keys(src[key]).length > 0) {
9 if (src[key].__swiper__) target[key] = src[key];else extend(target[key], src[key]);
10 } else {
11 target[key] = src[key];
12 }
13 });
14}
15
16function needsNavigation(params) {
17 if (params === void 0) {
18 params = {};
19 }
20
21 return params.navigation && typeof params.navigation.nextEl === 'undefined' && typeof params.navigation.prevEl === 'undefined';
22}
23
24function needsPagination(params) {
25 if (params === void 0) {
26 params = {};
27 }
28
29 return params.pagination && typeof params.pagination.el === 'undefined';
30}
31
32function needsScrollbar(params) {
33 if (params === void 0) {
34 params = {};
35 }
36
37 return params.scrollbar && typeof params.scrollbar.el === 'undefined';
38}
39
40function uniqueClasses(classNames) {
41 if (classNames === void 0) {
42 classNames = '';
43 }
44
45 const classes = classNames.split(' ').map(c => c.trim()).filter(c => !!c);
46 const unique = [];
47 classes.forEach(c => {
48 if (unique.indexOf(c) < 0) unique.push(c);
49 });
50 return unique.join(' ');
51}
52
53export { isObject, extend, needsNavigation, needsPagination, needsScrollbar, uniqueClasses };
\No newline at end of file