Skip to content

Commit b7210c6

Browse files
committed
chore(typings): add typings
1 parent 412dc4b commit b7210c6

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"unpkg": "min.js",
66
"main": "cjs/index.js",
77
"module": "esm/index.js",
8+
"types": "types.d.ts",
89
"scripts": {
910
"build": "npm run cjs && npm run bundle && npm run min && npm run test && npm run size",
1011
"bundle": "rollup --config rollup.config.js && npm run cleanup",

types.d.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
export interface IDomDiffNodeMarkerOptions {
2+
before: Node;
3+
}
4+
5+
export interface IDomDiffOptionsGenericComparisonFn {
6+
/**
7+
* A callback to compare between two generic nodes. returns `true` to indicate they are the same
8+
*/
9+
compare: (currentNode: Node, futureNode: Node) => boolean;
10+
}
11+
12+
export interface IDomDiffOPtionsEachNodeCallbackFn {
13+
/**
14+
* The optional `{node: (generic, info) => node}` is invoked per each operation on the DOM.
15+
* This can be useful to represent node through wrappers, whenever that is needed.
16+
* @param info
17+
* `1` when the item/node is being appended
18+
* `0` when the item/node is being used as insert _before_ reference
19+
* `-0` when the item/node is being used as insert _after_ reference
20+
* `-1` when the item/node is being removed
21+
*/
22+
node: (generic: Node, info: -1 | -0 | 0 | 1) => Node;
23+
}
24+
25+
/**
26+
* A vDOM-less implementation of the [petit-dom](https://github.com/yelouafi/petit-dom) diffing logic
27+
* that will mutate child nodes the first argument - parentNode
28+
* @param parentNode Where changes happen
29+
* @param currentNodes Array of current items / nodes
30+
* @param futureNodes Array of future items / nodes
31+
*/
32+
export default function domdiff(
33+
parentNode: Node,
34+
currentNodes: ArrayLike<Node>,
35+
futureNodes: ArrayLike<Node>,
36+
options?: IDomDiffNodeMarkerOptions | IDomDiffOptionsGenericComparisonFn | IDomDiffOPtionsEachNodeCallbackFn
37+
): void;

0 commit comments

Comments
 (0)