From 3c59752dcad785c4dbd2e71b6fee4686a5c39bc1 Mon Sep 17 00:00:00 2001 From: Nathan Cahill Date: Sun, 28 Feb 2016 15:57:14 -0700 Subject: [PATCH] add nanoajax --- nanoajax/nanoajax-tests.ts | 13 +++++++++++++ nanoajax/nanoajax.d.ts | 20 ++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 nanoajax/nanoajax-tests.ts create mode 100644 nanoajax/nanoajax.d.ts diff --git a/nanoajax/nanoajax-tests.ts b/nanoajax/nanoajax-tests.ts new file mode 100644 index 0000000000..f02c1c854a --- /dev/null +++ b/nanoajax/nanoajax-tests.ts @@ -0,0 +1,13 @@ +/// + +import * as nanoajax from 'nanoajax'; + +nanoajax.ajax({ + url: '/some-get-url' +}, function (code, responseText) {}) + +nanoajax.ajax({ + url: '/some-post-url', + method: 'POST', + body: 'post=content&args=yaknow' +}, function (code, responseText, request) {}) diff --git a/nanoajax/nanoajax.d.ts b/nanoajax/nanoajax.d.ts new file mode 100644 index 0000000000..49d1e1f47a --- /dev/null +++ b/nanoajax/nanoajax.d.ts @@ -0,0 +1,20 @@ +// Type definitions for nanoajax v0.2.4 +// Project: https://github.com/yanatan16/nanoajax +// Definitions by: Nathan Cahill +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module 'nanoajax' { + interface RequestParameters { + url: string; + headers?: { [key: string]: string; }; + body?: string|FormData; + method?: string; + cors?: boolean; + } + + interface Callback { + (statusCode: number, response: string, request: XMLHttpRequest): any + } + + export function ajax(params: RequestParameters, callback: Callback): XMLHttpRequest +}