Skip to content

Commit

Permalink
Add TypeScript definition (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
BendingBender authored and sindresorhus committed Apr 17, 2019
1 parent 692d85a commit 7fe35b4
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 7 deletions.
81 changes: 81 additions & 0 deletions index.d.ts
@@ -0,0 +1,81 @@
declare const figures: {
/**
Replace unicode symbols depending on the OS.
@param string - String where the unicode symbols will be replaced with fallback symbols depending on the OS.
@returns The input with replaced fallback Unicode symbols on Windows.
@example
```
import figures = require('figures');
console.log(figures('✔︎ check'));
// On real OSes: ✔︎ check
// On Windows: √ check
console.log(figures.tick);
// On real OSes: ✔︎
// On Windows: √
```
*/
(string: string): string;

readonly tick: string;
readonly cross: string;
readonly star: string;
readonly square: string;
readonly squareSmall: string;
readonly squareSmallFilled: string;
readonly play: string;
readonly circle: string;
readonly circleFilled: string;
readonly circleDotted: string;
readonly circleDouble: string;
readonly circleCircle: string;
readonly circleCross: string;
readonly circlePipe: string;
readonly circleQuestionMark: string;
readonly bullet: string;
readonly dot: string;
readonly line: string;
readonly ellipsis: string;
readonly pointer: string;
readonly pointerSmall: string;
readonly info: string;
readonly warning: string;
readonly hamburger: string;
readonly smiley: string;
readonly mustache: string;
readonly heart: string;
readonly arrowUp: string;
readonly arrowDown: string;
readonly arrowLeft: string;
readonly arrowRight: string;
readonly radioOn: string;
readonly radioOff: string;
readonly checkboxOn: string;
readonly checkboxOff: string;
readonly checkboxCircleOn: string;
readonly checkboxCircleOff: string;
readonly questionMarkPrefix: string;
readonly oneHalf: string;
readonly oneThird: string;
readonly oneQuarter: string;
readonly oneFifth: string;
readonly oneSixth: string;
readonly oneSeventh: string;
readonly oneEighth: string;
readonly oneNinth: string;
readonly oneTenth: string;
readonly twoThirds: string;
readonly twoFifths: string;
readonly threeQuarters: string;
readonly threeFifths: string;
readonly threeEighths: string;
readonly fourFifths: string;
readonly fiveSixths: string;
readonly fiveEighths: string;
readonly sevenEighth: string;
};

export = figures;
5 changes: 5 additions & 0 deletions index.test-d.ts
@@ -0,0 +1,5 @@
import {expectType} from 'tsd';
import figures = require('.');

expectType<string>(figures('✔︎ check'));
expectType<string>(figures.tick);
12 changes: 7 additions & 5 deletions package.json
Expand Up @@ -13,11 +13,12 @@
"node": ">=6"
},
"scripts": {
"test": "xo && ava",
"test": "xo && ava && tsd",
"make": "./makefile.js"
},
"files": [
"index.js"
"index.js",
"index.d.ts"
],
"keywords": [
"unicode",
Expand All @@ -36,9 +37,10 @@
"escape-string-regexp": "^1.0.5"
},
"devDependencies": {
"ava": "^1.0.1",
"ava": "^1.4.1",
"import-fresh": "^3.0.0",
"markdown-table": "^1.0.0",
"xo": "^0.23.0"
"markdown-table": "^1.1.2",
"tsd": "^0.7.2",
"xo": "^0.24.0"
}
}
4 changes: 2 additions & 2 deletions readme.md
Expand Up @@ -35,13 +35,13 @@ console.log(figures.tick);

## API

### figures(input)
### figures(string)

Returns the input with replaced fallback Unicode symbols on Windows.

All the below [figures](#figures) are attached to the main export as shown in the example above.

#### input
#### string

Type: `string`

Expand Down

0 comments on commit 7fe35b4

Please sign in to comment.