Skip to content

Commit

Permalink
fix(index): export default function and add Comment to index.d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Oct 15, 2023
1 parent 6c278b8 commit 07d7c98
Showing 1 changed file with 32 additions and 25 deletions.
57 changes: 32 additions & 25 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,44 @@
* Parses inline style to object.
*
* @example
* import StyleToObject from 'style-to-object';
* StyleToObject('line-height: 42;');
*
* ```ts
* import parse from 'style-to-object';
* parse('line-height: 42;'); // { 'line-height': '42' }
* ```
*/
declare function StyleToObject(
export default function StyleToObject(
style: string,
iterator?: StyleToObject.Iterator
iterator?: Iterator
): { [name: string]: string } | null;

export = StyleToObject;

declare namespace StyleToObject {
interface DeclarationPos {
interface Position {
start: {
line: number;
column: number;
};
end: {
line: number;
column: number;
}
};
source?: string;
}

// declaration is an object from module `inline-style-parser`
interface Declaration {
type: string;
property: string;
value: string;
position: {
start: DeclarationPos;
end: DeclarationPos;
source: any;
};
}
export interface Declaration {
type: 'declaration';
property: string;
value: string;
position: Position;
}

type Iterator = (
property: string,
value: string,
declaration: Declaration
) => void;
export interface Comment {
type: 'comment';
comment: string;
position: Position;
}

type Iterator = (
property: string,
value: string,
declaration: Declaration | Comment
) => void;

0 comments on commit 07d7c98

Please sign in to comment.