feat: refactoring project

This commit is contained in:
Carlos
2024-11-23 14:56:07 -05:00
parent f0c2a50c18
commit 1c6db5818d
2351 changed files with 39323 additions and 60326 deletions

View File

@@ -20,13 +20,26 @@ declare namespace Container {
/**
* An array of property names.
*/
props?: string[]
props?: readonly string[]
}
export interface ContainerProps extends NodeProps {
nodes?: (Node | ChildProps)[]
nodes?: readonly (ChildProps | Node)[]
}
/**
* All types that can be passed into container methods to create or add a new
* child node.
*/
export type NewChild =
| ChildProps
| Node
| readonly ChildProps[]
| readonly Node[]
| readonly string[]
| string
| undefined
// eslint-disable-next-line @typescript-eslint/no-use-before-define
export { Container_ as default }
}
@@ -51,6 +64,26 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
*/
nodes: Child[] | undefined
/**
* An internal method that converts a {@link NewChild} into a list of actual
* child nodes that can then be added to this container.
*
* This ensures that the nodes' parent is set to this container, that they use
* the correct prototype chain, and that they're marked as dirty.
*
* @param mnodes The new node or nodes to add.
* @param sample A node from whose raws the new node's `before` raw should be
* taken.
* @param type This should be set to `'prepend'` if the new nodes will be
* inserted at the beginning of the container.
* @hidden
*/
protected normalize(
nodes: Container.NewChild,
sample: Node | undefined,
type?: 'prepend' | false
): Child[]
/**
* Inserts new nodes to the end of the container.
*
@@ -71,21 +104,11 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
* @param nodes New nodes.
* @return This node for methods chain.
*/
append(
...nodes: (
| ChildProps
| ChildProps[]
| Node
| Node[]
| string
| string[]
| undefined
)[]
): this
append(...nodes: Container.NewChild[]): this
assign(overrides: Container.ContainerProps | object): this
clone(overrides?: Partial<Container.ContainerProps>): this
cloneAfter(overrides?: Partial<Container.ContainerProps>): this
cloneBefore(overrides?: Partial<Container.ContainerProps>): this
/**
@@ -124,7 +147,6 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
each(
callback: (node: Child, index: number) => false | void
): false | undefined
/**
* Returns `true` if callback returns `true`
* for all of the containers children.
@@ -139,6 +161,7 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
every(
condition: (node: Child, index: number, nodes: Child[]) => boolean
): boolean
/**
* Returns a `child`s index within the `Container#nodes` array.
*
@@ -150,7 +173,6 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
* @return Child index.
*/
index(child: Child | number): number
/**
* Insert new node after old node within the container.
*
@@ -158,17 +180,8 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
* @param newNode New node.
* @return This node for methods chain.
*/
insertAfter(
oldNode: Child | number,
newNode:
| Node
| Node[]
| ChildProps
| ChildProps[]
| string
| string[]
| undefined
): this
insertAfter(oldNode: Child | number, newNode: Container.NewChild): this
/**
* Insert new node before old node within the container.
*
@@ -180,17 +193,7 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
* @param newNode New node.
* @return This node for methods chain.
*/
insertBefore(
oldNode: Child | number,
newNode:
| Node
| Node[]
| ChildProps
| ChildProps[]
| string
| string[]
| undefined
): this
insertBefore(oldNode: Child | number, newNode: Container.NewChild): this
/**
* Traverses the containers descendant nodes, calling callback
@@ -229,17 +232,7 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
* @param nodes New nodes.
* @return This node for methods chain.
*/
prepend(
...nodes: (
| ChildProps
| ChildProps[]
| Node
| Node[]
| string
| string[]
| undefined
)[]
): this
prepend(...nodes: Container.NewChild[]): this
/**
* Add child to the end of the node.
*
@@ -301,8 +294,8 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
* ```
*
* @param pattern Replace pattern.
* @param {object} opts Options to speed up the search.
* @param callback String to replace pattern or callback
* @param {object} options Options to speed up the search.
* @param replaced String to replace pattern or callback
* that returns a new value. The callback
* will receive the same arguments
* as those passed to a function parameter