Skip to content

Commit

Permalink
Improve typings
Browse files Browse the repository at this point in the history
  • Loading branch information
siposdani87 authored and dsipos committed Aug 19, 2023
1 parent c88aef5 commit 4b75724
Show file tree
Hide file tree
Showing 37 changed files with 1,754 additions and 1,304 deletions.
2 changes: 1 addition & 1 deletion coverage/eslint.json

Large diffs are not rendered by default.

2,013 changes: 1,015 additions & 998 deletions coverage/lcov.info

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion coverage/stylelint.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dist/component/cardCollection.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { contain, each, format } from '../utils/operation';
import { contain, eachArray, format } from '../utils/operation';
import { Collection } from '../core/collection';
import { Knot } from '../core/knot';
import { Objekt } from '../core/objekt';
Expand Down Expand Up @@ -102,15 +102,15 @@ export class CardCollection {
const regex = new RegExp('{{[a-zA-Z._,() ]*}}', 'g');
const matches = this.template.match(regex);
let cloneTemplate = this.template;
each(matches, (match) => {
eachArray(matches, (match) => {
const expression = match.replace('{{', '').replace('}}', '');
if (contain(expression, 'ctrl.')) {
const paramsRegex = new RegExp('(([a-zA-Z._, ]*))', 'g');
const expressionMatches = expression.match(paramsRegex);
const fnName = expressionMatches[0].replace('ctrl.', '');
const fnKeys = expressionMatches[2].split(', ');
const fnParams = [];
each(fnKeys, (key) => {
eachArray(fnKeys, (key) => {
if (key === 'item') {
fnParams.push(item);
}
Expand Down Expand Up @@ -217,7 +217,7 @@ export class CardCollection {
*/
_draw() {
this.body.removeChildren();
each(this._getItems(), (item) => {
eachArray(this._getItems(), (item) => {
this._addCard(item);
});
mdl(this.body);
Expand Down
8 changes: 4 additions & 4 deletions dist/component/dropdown.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export declare class Dropdown {
options: Objekt;
collection: Collection<Objekt>;
actions: Action[];
item: Object;
item: Objekt;
buttonKnot: Knot;
menuKnot: Knot;
/**
Expand Down Expand Up @@ -40,11 +40,11 @@ export declare class Dropdown {
*/
private _appendMenu;
/**
* @param {!Array} actions
* @param {!Object} item
* @param {!Array<Action>} actions
* @param {!Objekt} item
* @return {undefined}
*/
setActions(actions: Array<any>, item: Object): void;
setActions(actions: Array<Action>, item: Objekt): void;
/**
* @private
* @return {undefined}
Expand Down
4 changes: 2 additions & 2 deletions dist/component/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ export class Dropdown {
this.dropdown.appendChild(this.menuKnot);
}
/**
* @param {!Array} actions
* @param {!Object} item
* @param {!Array<Action>} actions
* @param {!Objekt} item
* @return {undefined}
*/
setActions(actions, item) {
Expand Down
8 changes: 4 additions & 4 deletions dist/component/googleMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export class GoogleMap {
*/
updatePolygon(id, title, points, opt_polygonData = {}, opt_options = {}) {
const polygonData = this.getPolygon(id);
each(this._cleanPolygonData(opt_polygonData), (value, key) => {
eachObject(this._cleanPolygonData(opt_polygonData), (value, key) => {
polygonData.set(key, value);
});
const polygon = polygonData.get('_polygon');
Expand All @@ -225,7 +225,7 @@ export class GoogleMap {
*/
_cleanPolygonData(polygonData) {
const cleanData = new Objekt();
each(polygonData, (value, key) => {
eachObject(polygonData, (value, key) => {
if (!inArray(['_polygon', '_map_label', '_bounds'], key)) {
cleanData.set(key, value);
}
Expand Down Expand Up @@ -706,7 +706,7 @@ export class GoogleMap {
*/
updateMarker(id, title, iconName, latitude, longitude, opt_markerData = {}, opt_options = {}) {
const markerData = this.getMarker(id);
each(this._cleanMarkerData(opt_markerData), (value, key) => {
eachObject(this._cleanMarkerData(opt_markerData), (value, key) => {
markerData.set(key, value);
});
const text = title.toString();
Expand All @@ -726,7 +726,7 @@ export class GoogleMap {
*/
_cleanMarkerData(markerData) {
const cleanData = new Objekt();
each(markerData, (value, key) => {
eachObject(markerData, (value, key) => {
if (!inArray(['_marker', '_map_label'], key)) {
cleanData.set(key, value);
}
Expand Down
20 changes: 10 additions & 10 deletions dist/component/table.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Action } from '../utils';
/**
* @class
*/
export declare class Table<T = Objekt> {
export declare class Table<T extends Objekt = Objekt> {
tableKnot: Knot;
options: Objekt;
collection: Collection<T>;
Expand Down Expand Up @@ -111,21 +111,21 @@ export declare class Table<T = Objekt> {
private _getColumn;
/**
* @private
* @param {!Objekt} item
* @param {!T} item
* @param {number} rowIndex
* @return {undefined}
*/
private _addHeaderRow;
/**
* @private
* @param {!Objekt} item
* @param {!T} item
* @param {number} rowIndex
* @return {!Array<string>}
*/
private _getRowStyle;
/**
* @private
* @param {!Objekt} item
* @param {!T} item
* @param {number} rowIndex
* @return {undefined}
*/
Expand All @@ -137,7 +137,7 @@ export declare class Table<T = Objekt> {
setActions(actions: Array<Action>): void;
/**
* @private
* @param {!Objekt} item
* @param {!T} item
* @param {number} rowIndex
* @param {string} column
* @param {!Knot} parentKnot
Expand All @@ -157,29 +157,29 @@ export declare class Table<T = Objekt> {
/**
* @private
* @param {!Knot} tableDataKnot
* @param {!Objekt} item
* @param {!T} item
* @return {undefined}
*/
private _renderActions;
/**
* @private
* @param {!Knot} containerKnot
* @param {!Objekt} item
* @param {!T} item
* @return {undefined}
*/
private _renderActionKnots;
/**
* @private
* @param {!Knot} dropDownKnot
* @param {!Objekt} item
* @param {!T} item
* @return {undefined}
*/
private _renderDropDownKnot;
/**
* @private
* @param {!Knot} containerKnot
* @param {{style: !Function, click: !Function}} action
* @param {!Objekt} item
* @param {!T} item
* @return {undefined}
*/
private _createActionButton;
Expand All @@ -195,7 +195,7 @@ export declare class Table<T = Objekt> {
setCount(count: number): void;
/**
* @private
* @return {!Array}
* @return {!Array<T>}
*/
private _getItems;
/**
Expand Down
26 changes: 13 additions & 13 deletions dist/component/table.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { eq, inArray, contain, format, isFunction, isArray, each, eachArray, instanceOf, } from '../utils/operation';
import { eq, inArray, contain, format, isFunction, isArray, eachArray, instanceOf, } from '../utils/operation';
import { Collection } from '../core/collection';
import { Knot } from '../core/knot';
import { Objekt } from '../core/objekt';
Expand Down Expand Up @@ -303,7 +303,7 @@ export class Table {
}
/**
* @private
* @param {!Objekt} item
* @param {!T} item
* @param {number} rowIndex
* @return {undefined}
*/
Expand All @@ -327,7 +327,7 @@ export class Table {
}
/**
* @private
* @param {!Objekt} item
* @param {!T} item
* @param {number} rowIndex
* @return {!Array<string>}
*/
Expand All @@ -346,7 +346,7 @@ export class Table {
}
/**
* @private
* @param {!Objekt} item
* @param {!T} item
* @param {number} rowIndex
* @return {undefined}
*/
Expand All @@ -355,7 +355,7 @@ export class Table {
const cssClasses = this._getRowStyle(item, rowIndex);
tableRow.addClass(['data'].concat(cssClasses));
this.tbody.appendChild(tableRow);
each(this.options.columns, (column, columnIndex) => {
eachArray(this.options.columns, (column, columnIndex) => {
const tableDataKnot = new Knot('td');
tableRow.appendChild(tableDataKnot);
this._renderDataKnot(tableDataKnot, item, rowIndex, column, columnIndex);
Expand All @@ -370,7 +370,7 @@ export class Table {
}
/**
* @private
* @param {!Objekt} item
* @param {!T} item
* @param {number} rowIndex
* @param {string} column
* @param {!Knot} parentKnot
Expand Down Expand Up @@ -431,7 +431,7 @@ export class Table {
/**
* @private
* @param {!Knot} tableDataKnot
* @param {!Objekt} item
* @param {!T} item
* @return {undefined}
*/
_renderActions(tableDataKnot, item) {
Expand All @@ -449,18 +449,18 @@ export class Table {
/**
* @private
* @param {!Knot} containerKnot
* @param {!Objekt} item
* @param {!T} item
* @return {undefined}
*/
_renderActionKnots(containerKnot, item) {
each(this.actions, (action) => {
eachArray(this.actions, (action) => {
this._createActionButton(containerKnot, action, item);
});
}
/**
* @private
* @param {!Knot} dropDownKnot
* @param {!Objekt} item
* @param {!T} item
* @return {undefined}
*/
_renderDropDownKnot(dropDownKnot, item) {
Expand All @@ -471,7 +471,7 @@ export class Table {
* @private
* @param {!Knot} containerKnot
* @param {{style: !Function, click: !Function}} action
* @param {!Objekt} item
* @param {!T} item
* @return {undefined}
*/
_createActionButton(containerKnot, action, item) {
Expand Down Expand Up @@ -527,7 +527,7 @@ export class Table {
}
/**
* @private
* @return {!Array}
* @return {!Array<T>}
*/
_getItems() {
let items = this.collection.getItems();
Expand All @@ -542,7 +542,7 @@ export class Table {
*/
_draw() {
this.tbody.removeChildren();
each(this._getItems(), (item, rowIndex) => {
eachArray(this._getItems(), (item, rowIndex) => {
this._addHeaderRow(item, rowIndex);
this._addRow(item, rowIndex);
});
Expand Down
4 changes: 2 additions & 2 deletions dist/core/async.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { each, isUndefined, isFunction, eq } from '../utils/operation';
import { isUndefined, isFunction, eq, eachArray } from '../utils/operation';
import { consoleWarn } from '../utils/log';
import { Deferred } from './deferred';
/**
Expand All @@ -25,7 +25,7 @@ export class Async {
this._clear();
}
else {
each(calls, (call, index) => {
eachArray(calls, (call, index) => {
this.call.results[index] = null;
this._parallelWrapper(call, calls.length, false, index, opt_args).defer(deferred);
});
Expand Down
8 changes: 4 additions & 4 deletions dist/core/collection.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export declare class Collection<T extends Object = Objekt> {
* @param {!Function=} opt_type
* @param {!Object=} opt_options
*/
constructor(opt_items?: Array<any> | undefined, opt_type?: any, opt_options?: Object);
constructor(opt_items?: Array<T> | undefined, opt_type?: any, opt_options?: Object);
/**
* @private
* @param {!Object=} opt_options
Expand All @@ -40,7 +40,7 @@ export declare class Collection<T extends Object = Objekt> {
* @param {!Object|!T} object
* @return {T}
*/
private _createKnot;
private _createItem;
/**
* @param {number} index
* @param {!Object|!T} object
Expand All @@ -62,12 +62,12 @@ export declare class Collection<T extends Object = Objekt> {
* @param {!Array<T>=} opt_items
* @return {!Array<T>}
*/
iterator(callback: (_item: T) => any, next: (_item: T, _index: number) => any, opt_items?: Array<T> | undefined): Array<T>;
iterator(callback: (_item: T) => boolean, next: (_item: T, _index: number) => void, opt_items?: Array<T> | undefined): Array<T>;
/**
* @param {function(T, number)} next
* @return {undefined}
*/
each(next: (_item: T, _index: number) => any): void;
each(next: (_item: T, _index: number) => void): void;
/**
* @template K
* @param {number} index
Expand Down
Loading

0 comments on commit 4b75724

Please sign in to comment.