mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
feat(find-duplicated-property-keys): new definition (#47058)
Definition types for JSON utility - definition file - tests https://github.com/SebastianG77/find-duplicated-property-keys https://www.npmjs.com/package/find-duplicated-property-keys Thanks!
This commit is contained in:
parent
226c237a52
commit
042839f349
@ -0,0 +1,14 @@
|
||||
import findDuplicatedPropertyKeys = require('find-duplicated-property-keys');
|
||||
|
||||
const jsonString = '{"name": "Carl", "name": "Carla", "data": 1, "data": [{ "data": 1, "data": 2}]}';
|
||||
|
||||
const result = findDuplicatedPropertyKeys(jsonString); // $ExpectType PropertyInfo[]
|
||||
|
||||
result.forEach(item => {
|
||||
item.isArray; // $ExpectgType boolean
|
||||
item.key; // $ExpecgtType string
|
||||
item.occurrence; // $ExpectType number
|
||||
item.parent; // $ExpectType PropertyInfo
|
||||
item.propertyPath; // $ExpectType () => string[]
|
||||
item.toString(); // $ExpectType string
|
||||
});
|
||||
46
types/find-duplicated-property-keys/index.d.ts
vendored
Normal file
46
types/find-duplicated-property-keys/index.d.ts
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
// Type definitions for find-duplicated-property-keys 1.1
|
||||
// Project: https://github.com/SebastianG77/find-duplicated-property-keys#readme
|
||||
// Definitions by: Piotr Błażejewicz <https://github.com/peterblazejewicz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* A package for detecting all duplicated property keys of a JSON string.
|
||||
* It can either be used as a standalone tool for validating JSON files or as a submodule for other Node.js projects.
|
||||
*/
|
||||
declare function findDuplicatedPropertyKeys(content: string): findDuplicatedPropertyKeys.PropertyInfo[];
|
||||
|
||||
declare namespace findDuplicatedPropertyKeys {
|
||||
interface PropertyInfo {
|
||||
/**
|
||||
* The key name of the duplicated property
|
||||
*/
|
||||
key: string;
|
||||
|
||||
/**
|
||||
* The parent object of a property key
|
||||
*/
|
||||
parent: PropertyInfo;
|
||||
|
||||
/**
|
||||
* The number of property keys having the same key and parent object
|
||||
*/
|
||||
occurrence: number;
|
||||
/**
|
||||
* Is this property an array
|
||||
*/
|
||||
isArray: boolean;
|
||||
|
||||
/**
|
||||
* Returns a list of property keys, which represents the path to the property key of the current object.
|
||||
*/
|
||||
propertyPath(): string[];
|
||||
|
||||
/**
|
||||
* Prints the path to the property key. However, since all necessary raw data are also contained by the object,
|
||||
* the result objects can also be represented in any other way if desired.
|
||||
*/
|
||||
toString(): string;
|
||||
}
|
||||
}
|
||||
|
||||
export = findDuplicatedPropertyKeys;
|
||||
23
types/find-duplicated-property-keys/tsconfig.json
Normal file
23
types/find-duplicated-property-keys/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",
|
||||
"find-duplicated-property-keys-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/find-duplicated-property-keys/tslint.json
Normal file
1
types/find-duplicated-property-keys/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user