mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
first commit
This commit is contained in:
Vendored
+51
@@ -0,0 +1,51 @@
|
||||
// Type definitions for urlencode 1.1
|
||||
// Project: https://github.com/node-modules/urlencode
|
||||
// Definitions by: My Self <https://github.com/kimcoder>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/*~ If this module is a UMD module that exposes a global variable 'myLib' when
|
||||
*~ loaded outside a module loader environment, declare that global here.
|
||||
*~ Otherwise, delete this declaration.
|
||||
*/
|
||||
export as namespace urlencode;
|
||||
|
||||
/**
|
||||
* Encode string
|
||||
* @param str The string for encoding.
|
||||
*/
|
||||
export function encode(str: string, charset?: string): string;
|
||||
|
||||
/**
|
||||
* Decode string
|
||||
* @param encodedString The encoded string.
|
||||
*/
|
||||
export function decode(encodedString: string, charset?: string): string;
|
||||
|
||||
/**
|
||||
* Parse querystring
|
||||
* @param queryString Querystring
|
||||
* @param charsetParam The charset for parsing
|
||||
*/
|
||||
export function parse(queryString: string, charsetParam: charsetParam): string;
|
||||
export interface charsetParam {
|
||||
charset: string;
|
||||
}
|
||||
/**
|
||||
* Stringify object
|
||||
* @param obj Querystring
|
||||
* @param charsetParam The charset for parsing
|
||||
*/
|
||||
export function stringify(obj: any, prefix?: charsetParam, charsetParam?: charsetParam): any;
|
||||
|
||||
export default encode;
|
||||
|
||||
// export namespace subProp {
|
||||
// /*~ For example, given this definition, someone could write:
|
||||
// *~ import { subProp } from 'yourModule';
|
||||
// *~ subProp.foo();
|
||||
// *~ or
|
||||
// *~ import * as yourMod from 'yourModule';
|
||||
// *~ yourMod.subProp.foo();
|
||||
// */
|
||||
// export function foo(): void;
|
||||
// }
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"urlencode-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,15 @@
|
||||
import urlencode, { decode , parse, stringify } from 'urlencode';
|
||||
|
||||
urlencode('苏千'); // default is utf8
|
||||
urlencode('苏千', 'gbk'); // '%CB%D5%C7%A7'
|
||||
|
||||
// decode gbk
|
||||
decode('%CB%D5%C7%A7', 'gbk'); // '苏千'
|
||||
|
||||
// parse gbk querystring
|
||||
parse('nick=%CB%D5%C7%A7', {charset: 'gbk'}); // {nick: '苏千'}
|
||||
|
||||
// stringify obj with gbk encoding
|
||||
var str = 'x[y][0][v][w]=' + urlencode('雾空', 'gbk'); // x[y][0][v][w]=%CE%ED%BF%D5
|
||||
var obj = {'x' : {'y' : [{'v' : {'w' : '雾空'}}]}};
|
||||
stringify(obj, {charset: 'gbk'})
|
||||
Reference in New Issue
Block a user