diff --git a/notNeededPackages.json b/notNeededPackages.json index f6dc3f972d..220f79c24e 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -318,6 +318,12 @@ "sourceRepoURL": "https://github.com/bjyoungblood/es6-error", "asOfVersion": "4.0.2" }, + { + "libraryName": "es6-promise", + "typingsPackageName": "es6-promise", + "sourceRepoURL": "https://github.com/jakearchibald/ES6-Promise", + "asOfVersion": "3.3.0" + }, { "libraryName": "eventemitter2", "typingsPackageName": "eventemitter2", diff --git a/types/es6-promise/es6-promise-tests.ts b/types/es6-promise/es6-promise-tests.ts deleted file mode 100644 index ac9910df46..0000000000 --- a/types/es6-promise/es6-promise-tests.ts +++ /dev/null @@ -1,193 +0,0 @@ - - - -var promiseString: Promise, - promiseStringArr: Promise, - arrayOfPromise: Promise[], - promiseNumber: Promise, - promiseAny: Promise, - thenable: Thenable; - -// constructor test -var constructResult = new Promise((resolve, reject) => { - resolve('a string'); -}); -promiseString = constructResult; - - -var constructResult1 = new Promise((resolve:(promise: Thenable) => void) => { - resolve(Promise.resolve('a string')); -}); -promiseString = constructResult1; - -//resolve test -var resolveResult = Promise.resolve('a string'); -promiseString = resolveResult; - -var resolveResult1 = Promise.resolve(thenable); -promiseString = resolveResult1; - -//reject test -var rejectResult = Promise.reject('there is an error'); -promiseAny = rejectResult; - -//all test -var allResult = Promise.all(arrayOfPromise); -promiseStringArr = allResult; - -//race test -var raceResult = Promise.race(arrayOfPromise); -promiseString = raceResult; - - -//then test -var thenWithPromiseResult = promiseString.then(word => Promise.resolve(word.length)); -promiseNumber = thenWithPromiseResult; - -var thenWithPromiseResultAndPromiseReject = promiseString.then(word => Promise.resolve(word.length), error => Promise.resolve(10)); -promiseNumber = thenWithPromiseResultAndPromiseReject; - -var thenWithPromiseResultAndSimpleReject = promiseString.then(word => Promise.resolve(word.length), error => 10); -promiseNumber = thenWithPromiseResultAndSimpleReject; - -var thenWithSimpleResult = promiseString.then(word => word.length); -promiseNumber = thenWithSimpleResult; - -var thenWithSimpleResultAndPromiseReject = promiseString.then(word => word.length, error => Promise.resolve(10)); -promiseNumber = thenWithSimpleResultAndPromiseReject; - -var thenWithSimpleResultAndSimpleReject = promiseString.then(word => word.length, error => 10); -promiseNumber = thenWithSimpleResultAndSimpleReject; - -var thenWithUndefinedFullFillAndSimpleReject = promiseString.then(undefined, error => 10); -promiseNumber = thenWithUndefinedFullFillAndSimpleReject; - -var thenWithUndefinedFullFillAndPromiseReject = promiseString.then(undefined, error => Promise.resolve(10)); -promiseNumber = thenWithUndefinedFullFillAndPromiseReject; - -var thenWithNoResultAndNoReject = promiseString.then(); -promiseNumber = thenWithNoResultAndNoReject; - -var catchAfterThen = promiseString.then().catch(); -promiseNumber = catchAfterThen; - -var voidPromise = new Promise(function (resolve) { resolve(); }); - -//catch test -var catchWithSimpleResult = promiseString.catch(error => 10); -promiseNumber = catchWithSimpleResult; - -var catchWithPromiseResult = promiseString.catch(error => Promise.resolve(10)); -promiseNumber = catchWithPromiseResult; - -promiseString = promiseString.catch(function (): string { - throw new Error('Better error msg'); -}); - -//examples coming from http://www.html5rocks.com/en/tutorials/es6/promises/ - -function get(url: string) { - // Return a new promise. - return new Promise(function(resolve, reject) { - // Do the usual XHR stuff - var req = new XMLHttpRequest(); - req.open('GET', url); - - req.onload = function() { - // This is called even on 404 etc - // so check the status - if (req.status == 200) { - // Resolve the promise with the response text - resolve(req.response); - } - else { - // Otherwise reject with the status text - // which will hopefully be a meaningful error - reject(Error(req.statusText)); - } - }; - - // Handle network errors - req.onerror = function() { - reject(Error("Network Error")); - }; - - // Make the request - req.send(); - }); -} - - - -function getJSON(url: string) { - return get(url).then(JSON.parse); -} - -function addHtmlToPage(html: string) { - -} - -function addTextToPage(text: string) { - -} - -interface Story { - heading: string; - chapterUrls: string[] -} - -getJSON('story.json').then(function(story: Story) { - addHtmlToPage(story.heading); - - // Map our array of chapter urls to - // an array of chapter json promises. - // This makes sure they all download parallel. - return story.chapterUrls.map(getJSON) - .reduce(function(sequence, chapterPromise) { - // Use reduce to chain the promises together, - // adding content to the page for each chapter - return sequence.then(function() { - // Wait for everything in the sequence so far, - // then wait for this chapter to arrive. - return chapterPromise; - }).then(function(chapter) { - addHtmlToPage(chapter.html); - }); - }, Promise.resolve()); -}).then(function() { - addTextToPage("All done"); -}).catch(function(err) { - // catch any error that happened along the way - addTextToPage("Argh, broken: " + err.message); -}).then(function() { - (document.querySelector('.spinner')).style.display = 'none'; -}); - -interface T1 { - __t1: string; -} - -interface T2 { - __t2: string; -} - -interface T3 { - __t3: string; -} - -function f1(): Promise { - return Promise.resolve({ __t1: "foo_t1" }); -} - -function f2(x: T1): T2 { - return { __t2: x.__t1 + ":foo_21" }; -} - -var x3 = f1() - .then(f2, (e: Error) => { - console.log("error 1"); - throw e; -}) - .then((x: T2) => { - return { __t3: x.__t2 + "bar" }; -}); \ No newline at end of file diff --git a/types/es6-promise/index.d.ts b/types/es6-promise/index.d.ts deleted file mode 100644 index 56e0682491..0000000000 --- a/types/es6-promise/index.d.ts +++ /dev/null @@ -1,84 +0,0 @@ -// Type definitions for es6-promise -// Project: https://github.com/jakearchibald/ES6-Promise -// Definitions by: François de Campredon , vvakame -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -interface Thenable { - then(onFulfilled?: (value: T) => U | Thenable, onRejected?: (error: any) => U | Thenable): Thenable; - then(onFulfilled?: (value: T) => U | Thenable, onRejected?: (error: any) => void): Thenable; -} - -declare class Promise implements Thenable { - /** - * If you call resolve in the body of the callback passed to the constructor, - * your promise is fulfilled with result object passed to resolve. - * If you call reject your promise is rejected with the object passed to reject. - * For consistency and debugging (eg stack traces), obj should be an instanceof Error. - * Any errors thrown in the constructor callback will be implicitly passed to reject(). - */ - constructor(callback: (resolve : (value?: T | Thenable) => void, reject: (error?: any) => void) => void); - - /** - * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. - * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. - * Both callbacks have a single parameter , the fulfillment value or rejection reason. - * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. - * If an error is thrown in the callback, the returned promise rejects with that error. - * - * @param onFulfilled called when/if "promise" resolves - * @param onRejected called when/if "promise" rejects - */ - then(onFulfilled?: (value: T) => U | Thenable, onRejected?: (error: any) => U | Thenable): Promise; - then(onFulfilled?: (value: T) => U | Thenable, onRejected?: (error: any) => void): Promise; - - /** - * Sugar for promise.then(undefined, onRejected) - * - * @param onRejected called when/if "promise" rejects - */ - catch(onRejected?: (error: any) => U | Thenable): Promise; -} - -declare namespace Promise { - /** - * Make a new promise from the thenable. - * A thenable is promise-like in as far as it has a "then" method. - */ - function resolve(value?: T | Thenable): Promise; - - /** - * Make a promise that rejects to obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error - */ - function reject(error: any): Promise; - function reject(error: T): Promise; - - /** - * Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects. - * the array passed to all can be a mixture of promise-like objects and other objects. - * The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value. - */ - function all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable, T7 | Thenable, T8 | Thenable, T9 | Thenable, T10 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; - function all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable, T7 | Thenable, T8 | Thenable, T9 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; - function all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable, T7 | Thenable, T8 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; - function all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable, T7 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; - function all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6]>; - function all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable]): Promise<[T1, T2, T3, T4, T5]>; - function all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable ]): Promise<[T1, T2, T3, T4]>; - function all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable]): Promise<[T1, T2, T3]>; - function all(values: [T1 | Thenable, T2 | Thenable]): Promise<[T1, T2]>; - function all(values: (T | Thenable)[]): Promise; - - /** - * Make a Promise that fulfills when any item fulfills, and rejects if any item rejects. - */ - function race(promises: (T | Thenable)[]): Promise; -} - -declare module 'es6-promise' { - var foo: typeof Promise; // Temp variable to reference Promise in local context - namespace rsvp { - export var Promise: typeof foo; - export function polyfill(): void; - } - export = rsvp; -} diff --git a/types/es6-promise/tsconfig.json b/types/es6-promise/tsconfig.json deleted file mode 100644 index 8b3cc9da2a..0000000000 --- a/types/es6-promise/tsconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es5", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "es6-promise-tests.ts" - ] -} \ No newline at end of file diff --git a/types/es6-promise/tslint.json b/types/es6-promise/tslint.json deleted file mode 100644 index a41bf5d19a..0000000000 --- a/types/es6-promise/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -}