mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
feat(github-slugger): new type definition (#45647)
- definition file - tests https://www.npmjs.com/package/github-slugger https://github.com/Flet/github-slugger#readme Thanks!
This commit is contained in:
parent
25348af784
commit
4abecf3200
26
types/github-slugger/github-slugger-tests.ts
Normal file
26
types/github-slugger/github-slugger-tests.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import GithubSlugger = require('github-slugger');
|
||||
|
||||
const slugger = new GithubSlugger();
|
||||
const slug = GithubSlugger.slug;
|
||||
|
||||
slugger.slug('foo'); // $ExpectType string
|
||||
// returns 'foo'
|
||||
|
||||
slugger.slug('foo'); // $ExpectType string
|
||||
// returns 'foo-1'
|
||||
|
||||
slugger.slug('bar'); // $ExpectType string
|
||||
// returns 'bar'
|
||||
|
||||
slugger.slug('foo'); // $ExpectType string
|
||||
// returns 'foo-2'
|
||||
|
||||
slugger.reset(); // $ExpectType void
|
||||
|
||||
slugger.slug('foo'); // $ExpectType string
|
||||
// returns 'foo'
|
||||
slug('foo bar baz'); // $ExpectType string
|
||||
// returns 'foo-bar-baz'
|
||||
|
||||
slug('foo bar baz'); // $ExpectType string
|
||||
// returns the same slug 'foo-bar-baz' because it does not keep track
|
||||
30
types/github-slugger/index.d.ts
vendored
Normal file
30
types/github-slugger/index.d.ts
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
// Type definitions for github-slugger 1.3
|
||||
// Project: https://github.com/Flet/github-slugger
|
||||
// Definitions by: Piotr Błażejewicz <https://github.com/peterblazejewicz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* Generate a slug just like GitHub does for markdown headings.
|
||||
* It also ensures slugs are unique in the same way GitHub does it. The overall goal of this package is to emulate the way GitHub handles generating markdown heading anchors as close as possible
|
||||
*/
|
||||
declare class BananaSlug {
|
||||
/**
|
||||
*
|
||||
* @param value string of text to slugify
|
||||
* @param [maintainCase=false] Keep the current case, otherwise make all lowercase
|
||||
*/
|
||||
static slug(value: string | unknown, maintainCase?: boolean): string;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param value string of text to slugify
|
||||
* @param [maintainCase=false] Keep the current case, otherwise make all lowercase
|
||||
*/
|
||||
slug(value: string, maintainCase?: boolean): string;
|
||||
/**
|
||||
* Forget all previous slugs
|
||||
*/
|
||||
reset(): void;
|
||||
}
|
||||
|
||||
export = BananaSlug;
|
||||
23
types/github-slugger/tsconfig.json
Normal file
23
types/github-slugger/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"github-slugger-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/github-slugger/tslint.json
Normal file
1
types/github-slugger/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user