Add type definitions for searchjs (#43370)

* Added type definitions for searchjs

* Reformatted code

* Applied fixes from linter

* Remove tslint additional rules

* Removed package.json

* Added more types to anotations

* Updated tests
This commit is contained in:
Meru-kun 2020-05-04 19:38:17 +02:00 committed by GitHub
parent 24cc8a2f95
commit e429922c9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 76 additions and 0 deletions

24
types/searchjs/index.d.ts vendored Normal file
View File

@ -0,0 +1,24 @@
// Type definitions for searchjs 1.0
// Project: https://github.com/deitch/searchjs
// Definitions by: Melvin Mupondori <https://github.com/iammerus>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export function setDefaults(options: {
negator: boolean;
joinAnd: string;
text: boolean;
word: boolean;
start: boolean;
end: boolean;
separator: string;
propertySearch: boolean;
propertySearchDepth: number;
}): void;
export function resetDefaults(): void;
export function singleMatch(field: any, s: any, text: boolean, word: boolean, start: boolean, end: boolean): any;
export function matchArray(ary: any[], search: any): any;
export function matchObject(obj: any, search: any): any;

View File

@ -0,0 +1,25 @@
import { resetDefaults, setDefaults, matchArray, matchObject } from 'searchjs';
resetDefaults();
setDefaults({
negator: false,
joinAnd: "AND",
text: false,
word: false,
start: false,
end: false,
separator: ".",
propertySearch: false,
propertySearchDepth: -1
});
matchArray(
[
{ a: '1234', b: 56 },
{ a: 'Hello!', b: 11 },
],
{ a: 'Hello!' },
);
matchObject({ stuff: 'This is some awesome stuff' }, 'some awesome stuff');

View File

@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"searchjs-tests.ts"
]
}

View File

@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}