UNPKG

1.54 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(props) {
17 if (props === void 0) {
18 props = {};
19 }
20
21 return props.navigation && typeof props.navigation.nextEl === 'undefined' && typeof props.navigation.prevEl === 'undefined';
22}
23
24function needsPagination(props) {
25 if (props === void 0) {
26 props = {};
27 }
28
29 return props.pagination && typeof props.pagination.el === 'undefined';
30}
31
32function needsScrollbar(props) {
33 if (props === void 0) {
34 props = {};
35 }
36
37 return props.scrollbar && typeof props.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