mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Add types for php-serialize (#40869)
* Add type definitions for 'php-serialize' * Modifying tscconfig.json to the guidelines * Add missing type definitions header * Add test file into tsconfig * Fix typing and remove unused variable declaration * Fix optional function parameters * Add empty line for linter * Update types/php-serialize/index.d.ts Co-Authored-By: Dmitry Demensky <10235949+demensky@users.noreply.github.com> * Update types/php-serialize/index.d.ts Co-Authored-By: Dmitry Demensky <10235949+demensky@users.noreply.github.com> * Update types/php-serialize/index.d.ts Co-Authored-By: Dmitry Demensky <10235949+demensky@users.noreply.github.com> * Update index.d.ts * Update tsconfig.json * Revert tsconfig.json chnages * Add reference types header for node Co-authored-by: Dmitry Demensky <10235949+demensky@users.noreply.github.com>
This commit is contained in:
parent
b6a418b05f
commit
e665d7c49f
25
types/php-serialize/index.d.ts
vendored
Normal file
25
types/php-serialize/index.d.ts
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
// Type definitions for php-serialize 3.0
|
||||
// Project: https://github.com/steelbrain/php-serialize
|
||||
// Definitions by: Changhui Lee <https://github.com/blurfx>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.7
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
export interface SerializeOptions {
|
||||
/** @default 'utf8' */
|
||||
readonly encoding?: 'utf8' | 'binary';
|
||||
}
|
||||
|
||||
export interface UnserializeOptions {
|
||||
/** @default true' */
|
||||
readonly strict?: boolean;
|
||||
/** @default 'utf8' */
|
||||
readonly encoding?: 'utf8' | 'binary';
|
||||
}
|
||||
|
||||
export function isSerialized(givenItem: any, strict?: boolean): boolean;
|
||||
|
||||
export function serialize(item: any, scope?: any, givenOptions?: SerializeOptions): string;
|
||||
|
||||
export function unserialize(item: string | Buffer, scope?: any, givenOptions?: UnserializeOptions): any;
|
||||
8
types/php-serialize/php-serialize-tests.ts
Normal file
8
types/php-serialize/php-serialize-tests.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import PhpSerialize = require('php-serialize');
|
||||
|
||||
const testObject = {
|
||||
user_id: 399,
|
||||
parent_user_id: 399,
|
||||
};
|
||||
const serialized = PhpSerialize.serialize(testObject);
|
||||
PhpSerialize.unserialize(serialized);
|
||||
24
types/php-serialize/tsconfig.json
Normal file
24
types/php-serialize/tsconfig.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"php-serialize-tests.ts"
|
||||
]
|
||||
}
|
||||
3
types/php-serialize/tslint.json
Normal file
3
types/php-serialize/tslint.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user