improvements

This commit is contained in:
Rene
2020-07-25 14:26:22 +02:00
parent 4d58eb5e3a
commit f935a23185
15 changed files with 96 additions and 51 deletions
-1
View File
@@ -49,7 +49,6 @@ module.exports = {
'no-restricted-syntax': 'off',
'no-param-reassign': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/ban-types': 'off',
'no-console': 'off',
+18 -2
View File
@@ -2,6 +2,22 @@
"printWidth": 150,
"tabWidth": 2,
"singleQuote": true,
"trailingComma": "all",
"jsxBracketSameLine": true
"trailingComma": "es5",
"jsxBracketSameLine": true,
"arrowParens": "always",
"endOfLine": "lf",
"overrides": [
{
"files": "*.vue",
"options": { "parser": "vue" }
},
{
"files": "*.component.html",
"options": { "parser": "angular" }
},
{
"files": ".prettierrc",
"options": { "parser": "json" }
}
]
}
+1 -1
View File
@@ -9,6 +9,6 @@ module.exports = {
coverageDirectory: 'coverage',
moduleDirectories: resolve.directories,
moduleFileExtensions: resolve.extensions.map((ext) => ext.replace(/\./, '')),
testPathIgnorePatterns: ['\\\\node_modules\\\\', 'src/', 'dist/'],
testPathIgnorePatterns: ['\\\\node_modules\\\\'],
verbose: true,
};
+1 -1
View File
@@ -15,7 +15,7 @@ function isArrayLike(obj) {
return isArray(obj) || !isFunction(obj) && isNumber(length) && length > -1 && length % 1 == 0;
}
const keys = obj => Object.keys(obj);
const keys = obj => obj ? Object.keys(obj) : [];
function each(source, callback) {
if (isArrayLike(source)) {
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
function r(r){const s=!!r&&r.length;return function(r){return Array.isArray(r)}(r)||!function(r){return"function"==typeof r}(r)&&function(r){return"number"==typeof r}(s)&&s>-1&&s%1==0}function s(o,c){if(r(o))for(let r=0;r<o.length&&!1!==c(o[r],r,o);r++);else o&&s((i=o,Object.keys(i)),r=>c(o[r],r,o));var i;return o}const o=c=>{if(r(c))s(Array.from(c),r=>o(r));else if(c){const{parentNode:r}=c;r&&r.removeChild(c)}},c=r=>{const c=document.createElement("div");return c.innerHTML=r.trim(),s((i=c)?Array.from(i.childNodes):[],r=>o(r));var i},i={a:1,b:1,c:1};const e=1;export default()=>{const{a:r,b:s,c:o}=i;return[c(' <div class="os-host"> <div class="os-resize-observer-host"></div> <div class="os-padding"> <div class="os-viewport"> <div class="os-content"> fdfhdfgh </div> </div> </div> <div class="os-scrollbar os-scrollbar-horizontal"> <div class="os-scrollbar-track"> <div class="os-scrollbar-handle"></div> </div> </div> <div class="os-scrollbar os-scrollbar-vertical"> <div class="os-scrollbar-track"> <div class="os-scrollbar-handle"></div> </div> </div> <div class="os-scrollbar-corner"></div> </div>'),r,s,o]};export{e as a};
function r(r){const s=!!r&&r.length;return function(r){return Array.isArray(r)}(r)||!function(r){return"function"==typeof r}(r)&&function(r){return"number"==typeof r}(s)&&s>-1&&s%1==0}function s(o,c){if(r(o))for(let r=0;r<o.length&&!1!==c(o[r],r,o);r++);else o&&s((i=o)?Object.keys(i):[],r=>c(o[r],r,o));var i;return o}const o=c=>{if(r(c))s(Array.from(c),r=>o(r));else if(c){const{parentNode:r}=c;r&&r.removeChild(c)}},c=r=>{const c=document.createElement("div");return c.innerHTML=r.trim(),s((i=c)?Array.from(i.childNodes):[],r=>o(r));var i},i={a:1,b:1,c:1};const e=1;export default()=>{const{a:r,b:s,c:o}=i;return[c(' <div class="os-host"> <div class="os-resize-observer-host"></div> <div class="os-padding"> <div class="os-viewport"> <div class="os-content"> fdfhdfgh </div> </div> </div> <div class="os-scrollbar os-scrollbar-horizontal"> <div class="os-scrollbar-track"> <div class="os-scrollbar-handle"></div> </div> </div> <div class="os-scrollbar os-scrollbar-vertical"> <div class="os-scrollbar-track"> <div class="os-scrollbar-handle"></div> </div> </div> <div class="os-scrollbar-corner"></div> </div>'),r,s,o]};export{e as a};
+1 -1
View File
@@ -19,7 +19,7 @@ var OverlayScrollbars = function (exports) {
}
var keys = function keys(obj) {
return Object.keys(obj);
return obj ? Object.keys(obj) : [];
};
function each(source, callback) {
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
var OverlayScrollbars=function(r){"use strict";function s(r){var s=!!r&&r.length;return function(r){return Array.isArray(r)}(r)||!function(r){return"function"==typeof r}(r)&&function(r){return"number"==typeof r}(s)&&s>-1&&s%1==0}function o(r,i){if(s(r))for(var n=0;n<r.length&&!1!==i(r[n],n,r);n++);else r&&o((a=r,Object.keys(a)),(function(s){return i(r[s],s,r)}));var a;return r}var i=function(r){var i,n=document.createElement("div");return n.innerHTML=r.trim(),o((i=n)?Array.from(i.childNodes):[],(function(r){return function r(i){if(s(i))o(Array.from(i),(function(s){return r(s)}));else if(i){var n=i.parentNode;n&&n.removeChild(i)}}(r)}))},n=1,a=1,e=1;return r.a=1,r.default=function(){var r=n,s=a,o=e;return[i(' <div class="os-host"> <div class="os-resize-observer-host"></div> <div class="os-padding"> <div class="os-viewport"> <div class="os-content"> fdfhdfgh </div> </div> </div> <div class="os-scrollbar os-scrollbar-horizontal"> <div class="os-scrollbar-track"> <div class="os-scrollbar-handle"></div> </div> </div> <div class="os-scrollbar os-scrollbar-vertical"> <div class="os-scrollbar-track"> <div class="os-scrollbar-handle"></div> </div> </div> <div class="os-scrollbar-corner"></div> </div>'),r,s,o]},r}({});
var OverlayScrollbars=function(r){"use strict";function s(r){var s=!!r&&r.length;return function(r){return Array.isArray(r)}(r)||!function(r){return"function"==typeof r}(r)&&function(r){return"number"==typeof r}(s)&&s>-1&&s%1==0}function o(r,i){if(s(r))for(var n=0;n<r.length&&!1!==i(r[n],n,r);n++);else r&&o((a=r)?Object.keys(a):[],(function(s){return i(r[s],s,r)}));var a;return r}var i=function(r){var i,n=document.createElement("div");return n.innerHTML=r.trim(),o((i=n)?Array.from(i.childNodes):[],(function(r){return function r(i){if(s(i))o(Array.from(i),(function(s){return r(s)}));else if(i){var n=i.parentNode;n&&n.removeChild(i)}}(r)}))},n=1,a=1,e=1;return r.a=1,r.default=function(){var r=n,s=a,o=e;return[i(' <div class="os-host"> <div class="os-resize-observer-host"></div> <div class="os-padding"> <div class="os-viewport"> <div class="os-content"> fdfhdfgh </div> </div> </div> <div class="os-scrollbar os-scrollbar-horizontal"> <div class="os-scrollbar-track"> <div class="os-scrollbar-handle"></div> </div> </div> <div class="os-scrollbar os-scrollbar-vertical"> <div class="os-scrollbar-track"> <div class="os-scrollbar-handle"></div> </div> </div> <div class="os-scrollbar-corner"></div> </div>'),r,s,o]},r}({});
@@ -1,4 +1,4 @@
import { keys } from 'core/utils/object';
import { each, keys } from 'core/utils';
import { isString, isNumber, isUndefined } from 'core/utils/types';
type cssStyleObj = { [key: string]: string | number };
@@ -44,7 +44,7 @@ export function style(elm: HTMLElement, styles: string | cssStyleObj, val?: stri
}
setCSSVal(elm, styles, val);
} else {
keys(styles).forEach((key) => setCSSVal(elm, key, styles[key]));
each(keys(styles), (key) => setCSSVal(elm, key, styles[key]));
}
}
@@ -1,5 +1,6 @@
import { isArray, isFunction, isPlainObject, isNull } from 'core/utils/types';
import { each } from 'core/utils/array';
import { keys } from 'core/utils/object';
// https://github.com/jquery/jquery/blob/master/src/core.js#L116
export function extend<T, U>(target: T, object1: U): T & U;
@@ -14,9 +15,8 @@ export function extend<T, U, V, W, X, Y, Z>(
object3?: W,
object4?: X,
object5?: Y,
object6?: Z,
object6?: Z
): T & U & V & W & X & Y & Z {
/* eslint-disable no-restricted-syntax, guard-for-in */
const sources: Array<any> = [object1, object2, object3, object4, object5, object6];
// Handle case when target is a string or something (possible in deep copy)
@@ -25,44 +25,40 @@ export function extend<T, U, V, W, X, Y, Z>(
}
each(sources, (source) => {
// Only deal with non-null/undefined values
if (source != null) {
// Extend the base object
for (const name in source) {
const copy: any = source[name];
// Extend the base object
each(keys(source), (key) => {
const copy: any = source[key];
// Prevent Object.prototype pollution
// Prevent never-ending loop
if (name === '__proto__' || target === copy) {
continue;
}
const copyIsArray = isArray(copy);
// Recurse if we're merging plain objects or arrays
if (copy && (isPlainObject(copy) || copyIsArray)) {
const src = target[name];
let clone: any = src;
// Ensure proper type for the source value
if (copyIsArray && !isArray(src)) {
clone = [];
} else if (!copyIsArray && !isPlainObject(src)) {
clone = {};
}
// Never move original objects, clone them
target[name] = extend(clone, copy) as any;
// Don't bring in undefined values
} else if (copy !== undefined) {
target[name] = copy;
}
// Prevent Object.prototype pollution
// Prevent never-ending loop
if (target === copy) {
return true;
}
}
const copyIsArray = isArray(copy);
// Recurse if we're merging plain objects or arrays
if (copy && (isPlainObject(copy) || copyIsArray)) {
const src = target[key];
let clone: any = src;
// Ensure proper type for the source value
if (copyIsArray && !isArray(src)) {
clone = [];
} else if (!copyIsArray && !isPlainObject(src)) {
clone = {};
}
// Never move original objects, clone them
target[key] = extend(clone, copy) as any;
// Don't bring in undefined values
} else if (copy !== undefined) {
target[key] = copy;
}
});
});
// Return the modified object
return target as any;
/* eslint-enable */
}
@@ -10,4 +10,4 @@ export const hasOwnProperty: (obj: any, prop: string | number | symbol) => boole
* Returns the names of the enumerable string properties and methods of an object.
* @param obj The object of which the properties shall be returned.
*/
export const keys: (obj: any) => Array<string> = (obj: any) => Object.keys(obj);
export const keys: (obj: any) => Array<string> = (obj: any) => (obj ? Object.keys(obj) : []);
@@ -0,0 +1,31 @@
import { keys, hasOwnProperty } from 'core/utils/object';
describe('object utilities', () => {
describe('keys', () => {
test('correct amount of keys', () => {
const obj = {
a: 1,
b: 2,
c: 3,
};
expect(keys(obj)).toEqual(Object.keys(obj));
});
test('empty array if object null or undefined', () => {
expect(keys(undefined)).toEqual([]);
expect(keys(null)).toEqual([]);
});
});
test('hasOwnProperty', () => {
const obj = {
a: 1,
b: 2,
c: 3,
};
expect(hasOwnProperty(obj, 'a')).toBe(true);
expect(hasOwnProperty(obj, 'b')).toBe(true);
expect(hasOwnProperty(obj, 'c')).toBe(true);
expect(hasOwnProperty(obj, 'd')).toBe(false);
});
});
+4 -1
View File
@@ -53,6 +53,7 @@ export default async (config) => {
src = './src',
dist = './dist',
types = './types',
tests = './tests',
cache = [],
minVersions = true,
modules: { sourcemap: modulesSourceMap = true } = {},
@@ -64,6 +65,7 @@ export default async (config) => {
const srcPath = path.resolve(projectPath, src);
const distPath = path.resolve(projectPath, dist);
const typesPath = path.resolve(projectPath, types);
const testsPath = path.resolve(projectPath, tests);
const inputPath = path.resolve(projectPath, input);
const mainOutputArray = [
@@ -101,7 +103,7 @@ export default async (config) => {
}),
],
}))
: [],
: []
),
external: [...Object.keys(devDependencies), ...Object.keys(peerDependencies)],
plugins: [
@@ -141,6 +143,7 @@ export default async (config) => {
declaration: true,
declarationDir: typesPath,
},
exclude: ((await import(tsconfigJSONPath)).exclude || []).concat(testsPath),
},
})
: {},
+1 -1
View File
@@ -13,5 +13,5 @@
"moduleResolution": "node",
"removeComments": true
},
"exclude": ["tests", "**/tests/*", "node_modules", "**/node_modules/*"]
"exclude": ["node_modules", "**/node_modules/*"]
}