Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TypeScript definition #25

Merged
merged 1 commit into from
Apr 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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