Skip to content

Commit 92d5b25

Browse files
committed
clean up types
1 parent 0aaba1b commit 92d5b25

5 files changed

Lines changed: 62 additions & 59 deletions

File tree

types/lib/domutil.d.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1+
import { ElementBuilder } from './element.js'
2+
13
/**
24
* Selects an element as an {@link ElementBuilder}.
35
* @param {string} selector The css selector for an element.
46
* @returns {ElementBuilder} An elementBuilder attached to the dom element associated with the provided selector.
57
*/
6-
export function $(selector: string): ElementBuilder;
8+
export function $(selector: string): ElementBuilder
79
/**
810
*
911
* @param {string} selector The css selector for a collection of elements.
1012
* @returns {Array<ElementBuilder>} An array containing whose are attached to the DOM elements associated with the provided selector.
1113
*/
12-
export function $all(selector: string): Array<ElementBuilder>;
14+
export function $all(selector: string): Array<ElementBuilder>
1315
/**
1416
* Injects css into the current webpage.
1517
* @param {string} css The css to be injected.
1618
* @deprecated
1719
*/
18-
export function $css(css: string): void;
20+
export function $css(css: string): void
1921
/**
2022
* Creates a new dom element.
2123
* @param {string} type The type of element to create.
2224
* @default type A div.
2325
* @returns {ElementBuilder} An elementBuilder attached to a brand-new dom element of the specified type.
2426
*/
25-
export function _(type: string): ElementBuilder;
26-
import { ElementBuilder } from './element.js';
27-
//# sourceMappingURL=domutil.d.ts.map
27+
export function _(type: string): ElementBuilder

types/lib/element.d.ts

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Reactive } from './reactivity.js'
2+
13
/**
24
* A chainable builder class for DOM elements.
35
*/
@@ -7,138 +9,141 @@ export class ElementBuilder {
79
* @see {@link _} for the function to create an instance of this class.
810
* @param {string} type The type of DOM element to create. div by default.
911
*/
10-
constructor(type?: string);
11-
_domEl: HTMLElement;
12+
constructor(type?: string)
13+
_domEl: HTMLElement
1214
/**
1315
* Sets the text content of this element.
1416
* @param {string | Reactive} content The content to be set.
1517
* @returns The same elementBuilder it was called on.
1618
*/
17-
text(content: string | Reactive): this;
19+
text(content: string | Reactive): this
1820
/**
1921
* Inserts another elementBuilder as a child of this element.
2022
* @param {ElementBuilder| Reactive} element The elementBuilder to insert.
2123
* @returns {ElementBuilder} The same elementBuilder it was called on.
2224
*/
23-
insert(element: ElementBuilder | Reactive): ElementBuilder;
25+
insert(element: ElementBuilder | Reactive): ElementBuilder
2426
/**
2527
* Adds an event listener to this element.
2628
* @param {string} type The event to listen for.
2729
* @param {function | Reactive} handler The function to handle the event.
2830
* @returns {ElementBuilder} The same elementBuilder it was called on.
2931
*/
30-
handle(type: string, handler: Function | Reactive): ElementBuilder;
32+
handle(type: string, handler: Function | Reactive): ElementBuilder
3133
/**
3234
* Sets a css style property on this element.
3335
* @param {string} property The css property to set.
3436
* @param {*} value The value to set it to.
3537
* @returns {ElementBuilder} The same elementBuilder it was called on.
3638
*/
37-
style(property: string, value: any): ElementBuilder;
38-
set_cssvar(property: any, value: any): this;
39-
get_cssvar(property: any): string;
39+
style(property: string, value: any): ElementBuilder
40+
set_cssvar(property: any, value: any): this
41+
get_cssvar(property: any): string
4042
/**
4143
* Sets a html attribute on this element.
4244
* @param {string} property The property to set.
4345
* @param {* | Reactive} value The value to set it to.
4446
* @returns {ElementBuilder} The same elementBuilder it was called on.
4547
*/
46-
set_prop(property: string, value: any | Reactive): ElementBuilder;
48+
set_prop(property: string, value: any | Reactive): ElementBuilder
4749
/**
4850
* Gets the value of a html attribute on this element.
4951
* @param {*} property The property of who's value to get.
5052
* @returns The value of the specified property.
5153
*/
52-
get_prop(property: any): string;
53-
bind_prop(property: any, variable: any, event: any): this;
54+
get_prop(property: any): string
55+
bind_prop(property: any, variable: any, event: any): this
5456
/**
5557
* Subscribe to an arbitrary somethingjs reactive value but get this element as an argument to the callback as well.
5658
* @param {*} variable The reactive value to subscribe to.
5759
* @param {*} callback The callback to subscribe with.
5860
* @returns {ElementBuilder} The same elementBuilder it was called on.
5961
*/
60-
sub(variable: any, callback: any): ElementBuilder;
62+
sub(variable: any, callback: any): ElementBuilder
6163
/**
6264
* Sets the id of this element.
6365
* @param {string} id The id to set on the element.
6466
* @returns {ElementBuilder} The same elementBuilder it was called on.
6567
*/
66-
id(id: string): ElementBuilder;
68+
id(id: string): ElementBuilder
6769
/**
6870
* Adds a class to this element.
6971
* @param {string | Reactive} name The classname to add.
7072
* @returns {ElementBuilder} The same elementBuilder it was called on.
7173
*/
72-
add_class(name: string | Reactive): ElementBuilder;
74+
add_class(name: string | Reactive): ElementBuilder
7375
/**
7476
* Removes a class from this element.
7577
* @param {string} name The name of the class to remove.
7678
* @returns {ElementBuilder} The same elementBuilder it was called on.
7779
*/
78-
remove_class(name: string): ElementBuilder;
80+
remove_class(name: string): ElementBuilder
7981
/**
8082
* Replaces a class on this element.
8183
* @param {string} oldClass The class to be replaced.
8284
* @param {string} newClass The class to replace with.
8385
* @returns {ElementBuilder} The same elementBuilder it was called on.
8486
*/
85-
replace_class(oldClass: string, newClass: string): ElementBuilder;
87+
replace_class(oldClass: string, newClass: string): ElementBuilder
8688
/**
8789
* Toggles a class on this element.
8890
* @param {string} name The class to be toggled
8991
* @returns {ElementBuilder} The same elementBuilder it was called on.
9092
*/
91-
toggle_class(name: string): ElementBuilder;
93+
toggle_class(name: string): ElementBuilder
9294
/**
9395
* Runs different code based on whether a class exists on this element.
9496
* @param {string} name The class to check.
9597
* @param {*} yescb Code to run if the class is present.
9698
* @param {*} nocb Code to run if the class is not present.
9799
* @returns {ElementBuilder} The same elementBuilder it was called on.
98100
*/
99-
if_class(name: string, yescb: any, nocb: any): ElementBuilder;
101+
if_class(name: string, yescb: any, nocb: any): ElementBuilder
100102
/**
101103
* Completely clears the contents of this element.
102104
* @returns {ElementBuilder} The same elementBuilder it was called on.
103105
*/
104-
clear(): ElementBuilder;
106+
clear(): ElementBuilder
105107
/**
106108
* Loops over an array and adds children to this element.
107109
* @param {Array<*> | Reactive} list The array to iterate over.
108110
* @param {*} itemcallback A callback to call for each item, which returns an elementBuilder to be inserted.
109111
* @param {*} blankcallback A callback to call in the case of the array having 0 items, which returns an elementBuilder to be inserted.
110112
* @returns {ElementBuilder} The same elementBuilder it was called on.
111113
*/
112-
loop(list: Array<any> | Reactive, itemcallback: any, blankcallback: any, some_wrapper?: boolean): ElementBuilder;
114+
loop(
115+
list: Array<any> | Reactive,
116+
itemcallback: any,
117+
blankcallback: any,
118+
some_wrapper?: boolean
119+
): ElementBuilder
113120
/**
114121
* Checks whether this element has a class.
115122
* @param {string} name The class to check for the presence of.
116123
* @returns {boolean} Whether this element has that class
117124
*/
118-
has_class(name: string): boolean;
125+
has_class(name: string): boolean
119126
/**
120127
* Gets the list of all classes on this element.
121128
* @returns {Array} All the classes on this element.
122129
*/
123-
classes(): any[];
130+
classes(): any[]
124131
/**
125132
* Gets a copy of this element.
126133
* @returns {ElementBuilder} A copy of this element
127134
*/
128-
get(): ElementBuilder;
135+
get(): ElementBuilder
129136
/**
130137
* Attaches this elementBuilder to another dom element.
131138
* @param {*} element The DOM element to attach to.
132139
* @returns {ElementBuilder} The same elementBuilder it was called on.
133140
*/
134-
from_dom(element: any): ElementBuilder;
141+
from_dom(element: any): ElementBuilder
135142
/**
136143
* Gets the underlying DOM element of this elementBuilder.
137144
* @returns The underlying DOM element of this elementBuilder.
138145
*/
139-
to_dom(): HTMLElement;
140-
if(condition: any, handler: any): this;
141-
process(handler: any): this;
146+
to_dom(): HTMLElement
147+
if(condition: any, handler: any): this
148+
process(handler: any): this
142149
}
143-
import { Reactive } from './reactivity.js';
144-
//# sourceMappingURL=element.d.ts.map

types/lib/reactivity.d.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
export class Reactive {
2-
constructor(default_value: any, formatter?: () => void);
3-
set value(new_value: any);
4-
get value(): any;
5-
subscribe(handler: any): void;
6-
update(updater: any): void;
7-
as(formatter: any): Reactive;
8-
#private;
2+
constructor(default_value: any, formatter?: () => void)
3+
set value(new_value: any)
4+
get value(): any
5+
subscribe(handler: any): void
6+
update(updater: any): void
7+
as(formatter: any): Reactive
8+
#private
99
}
10-
//# sourceMappingURL=reactivity.d.ts.map

types/lib/util.d.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1+
import { Reactive } from './reactivity.js'
2+
13
/**
24
* Gets a random item from an Array.
35
* @param {Array} array The array to get random items from.
46
* @returns {*} A random item from the provided array.
57
*/
6-
export function get_random_item(array: any[]): any;
8+
export function get_random_item(array: any[]): any
79
/**
810
* Gets a random number in a range.
911
* @param {number} min The minimum number to generate.
1012
* @param {number} max The maximum number to generate.
1113
* @returns {number} A random number between min and max.
1214
*/
13-
export function get_random_between(min: number, max: number): number;
15+
export function get_random_between(min: number, max: number): number
1416
/**
1517
* Gets a random string.
1618
* @param {number} length How long the string should be.
1719
* @returns A random alphanumeric string.
1820
*/
19-
export function get_random_string(length: number): string;
21+
export function get_random_string(length: number): string
2022
/**
2123
* Generates a tag for use with tagged templates from a function.
2224
* @param {function} handler A function that takes a string and returns something else.
2325
* @returns Whatever the handler returns.
2426
*/
25-
export function Tag(handler: Function): (strings: any, ...values: any[]) => any;
26-
export function Variable(initial_value: any): Reactive;
27-
export function subscribe(maybe_reactive: any, handler: any): any;
28-
export function is_reactive(maybe_reactive: any): maybe_reactive is Reactive;
29-
export function noop(): void;
30-
import { Reactive } from './reactivity.js';
31-
//# sourceMappingURL=util.d.ts.map
27+
export function Tag(handler: Function): (strings: any, ...values: any[]) => any
28+
export function Variable(initial_value: any): Reactive
29+
export function subscribe(maybe_reactive: any, handler: any): any
30+
export function is_reactive(maybe_reactive: any): maybe_reactive is Reactive
31+
export function noop(): void

types/main.d.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
export * from "./lib/util.js";
2-
export * from "./lib/reactivity.js";
3-
export * from "./lib/element.js";
4-
export * from "./lib/domutil.js";
5-
export * from "./lib/bezier.js";
6-
//# sourceMappingURL=main.d.ts.map
1+
export * from './lib/util.js'
2+
export * from './lib/reactivity.js'
3+
export * from './lib/element.js'
4+
export * from './lib/domutil.js'
5+
export * from './lib/bezier.js'

0 commit comments

Comments
 (0)