Skip to content

Commit

Permalink
chore: add typings (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
smallpath authored and geemo committed Aug 6, 2017
1 parent e156020 commit cd78148
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
36 changes: 36 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
declare const Buffer

type ColorString = string
type ColorArr = number[]
type RGBA = ColorString | ColorArr

declare class NodePnglib {
constructor(
width: number,
height: number,
/** Color depth of the png, default to 8. */
depth?: number,
/** For example: [1, 1, 1, 1], 'blue', 'transparent' or 'rgba(1, 1, 1, 1)', default to [0, 0, 0, 0]. */
backgroundColor?: RGBA
)

index(x: number, y: number): number

color(rgba: RGBA)

setBgColor(rgba: RGBA): number

setPixel(x: number, y: number, rgba: RGBA): void

getBase64(): string

getBuffer(): Buffer

deflate(): Buffer
}

declare namespace NodePnglib {
export type Color = RGBA
}

export = NodePnglib
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"engines": {
"node": ">=4.4.0"
},
"typings": "./index.d.ts",
"scripts": {
"build": "babel src/ -d lib/",
"dev": "babel src/ --watch -d lib/",
Expand Down

0 comments on commit cd78148

Please sign in to comment.