diff --git a/types/php-serialize/index.d.ts b/types/php-serialize/index.d.ts new file mode 100644 index 0000000000..b4acbe4167 --- /dev/null +++ b/types/php-serialize/index.d.ts @@ -0,0 +1,25 @@ +// Type definitions for php-serialize 3.0 +// Project: https://github.com/steelbrain/php-serialize +// Definitions by: Changhui Lee +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.7 + +/// + +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; diff --git a/types/php-serialize/php-serialize-tests.ts b/types/php-serialize/php-serialize-tests.ts new file mode 100644 index 0000000000..84d81b5305 --- /dev/null +++ b/types/php-serialize/php-serialize-tests.ts @@ -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); diff --git a/types/php-serialize/tsconfig.json b/types/php-serialize/tsconfig.json new file mode 100644 index 0000000000..a711f45262 --- /dev/null +++ b/types/php-serialize/tsconfig.json @@ -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" + ] +} diff --git a/types/php-serialize/tslint.json b/types/php-serialize/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/php-serialize/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}