diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..4966b33 --- /dev/null +++ b/.babelrc @@ -0,0 +1,4 @@ +{ + "presets": ["es2015"], + "plugins": ["transform-es2015-modules-commonjs"] +} \ No newline at end of file diff --git a/README.md b/README.md index 8d93b13..8296c42 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# promise-ts -A 150 loc Promises/A+ implementation in TypeScript +# promised +A 150 loc Promises/A+ implementation. ``` npm install diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 3947715..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './src/promise'; diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index dca2afe..0000000 --- a/dist/index.js +++ /dev/null @@ -1,6 +0,0 @@ -"use strict"; -function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; -} -Object.defineProperty(exports, "__esModule", { value: true }); -__export(require("./src/promise")); diff --git a/dist/promise.d.ts b/dist/promise.d.ts deleted file mode 100644 index 741471c..0000000 --- a/dist/promise.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -export declare class Promise { - private _state; - private _value; - private _handlers; - constructor(executor: (resovle: any, reject: any) => void); - private _resolve(x); - private _fulfill(result); - private _reject(error); - private _isPending(); - private _isFulfilled(); - private _isRejected(); - private _addHandler(onFulfilled, onRejected); - private _callHandler(handler); - then(onFulfilled: any, onRejected?: any): Promise; -} diff --git a/dist/promise.js b/dist/promise.js deleted file mode 100644 index 9403a0b..0000000 --- a/dist/promise.js +++ /dev/null @@ -1,164 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var State; -(function (State) { - State[State["Pending"] = 0] = "Pending"; - State[State["Fulfilled"] = 1] = "Fulfilled"; - State[State["Rejected"] = 2] = "Rejected"; -})(State || (State = {})); -class Util { - static isFunction(val) { - return val && typeof val === "function"; - } - static isObject(val) { - return val && typeof val === "object"; - } -} -class Promise { - constructor(executor) { - this._handlers = []; - this._state = State.Pending; - executor(this._resolve.bind(this), this._reject.bind(this)); - } - _resolve(x) { - if (x === this) { - throw new TypeError("Resolving object can not be the same object"); - } - else if (x instanceof Promise) { - x.then(this._resolve.bind(this), this._reject.bind(this)); - } - else if (Util.isObject(x) || Util.isFunction(x)) { - let called = false; - try { - const thenable = x.then; - if (Util.isFunction(thenable)) { - thenable.call(x, (result) => { - if (!called) - this._resolve(result); - called = true; - }, (error) => { - if (!called) - this._reject(error); - called = true; - }); - } - else { - this._fulfill(x); - } - } - catch (ex) { - if (!called) { - this._reject(ex); - } - } - } - else { - this._fulfill(x); - } - } - _fulfill(result) { - this._state = State.Fulfilled; - this._value = result; - this._handlers.forEach(handler => this._callHandler(handler)); - } - _reject(error) { - this._state = State.Rejected; - this._value = error; - this._handlers.forEach(handler => this._callHandler(handler)); - } - _isPending() { - return this._state === State.Pending; - } - _isFulfilled() { - return this._state === State.Fulfilled; - } - _isRejected() { - return this._state === State.Rejected; - } - _addHandler(onFulfilled, onRejected) { - this._handlers.push({ - onFulfilled, - onRejected - }); - } - _callHandler(handler) { - if (this._isFulfilled() && Util.isFunction(handler.onFulfilled)) { - handler.onFulfilled(this._value); - } - else if (this._isRejected() && Util.isFunction(handler.onRejected)) { - handler.onRejected(this._value); - } - } - then(onFulfilled, onRejected) { - switch (this._state) { - case State.Pending: { - return new Promise((resolve, reject) => { - this._addHandler((value) => { - setTimeout(() => { - try { - if (Util.isFunction(onFulfilled)) { - resolve(onFulfilled(value)); - } - else { - resolve(value); - } - } - catch (ex) { - reject(ex); - } - }, 0); - }, (error) => { - setTimeout(() => { - try { - if (Util.isFunction(onRejected)) { - resolve(onRejected(error)); - } - else { - reject(error); - } - } - catch (ex) { - reject(ex); - } - }, 0); - }); - }); - } - case State.Fulfilled: { - return new Promise((resolve, reject) => { - setTimeout(() => { - try { - if (Util.isFunction(onFulfilled)) { - resolve(onFulfilled(this._value)); - } - else { - resolve(this._value); - } - } - catch (ex) { - reject(ex); - } - }, 0); - }); - } - case State.Rejected: { - return new Promise((resolve, reject) => { - setTimeout(() => { - try { - if (Util.isFunction(onRejected)) { - resolve(onRejected(this._value)); - } - else { - reject(this._value); - } - } - catch (ex) { - reject(ex); - } - }, 0); - }); - } - } - } -} -exports.Promise = Promise; diff --git a/dist/src/promise.d.ts b/dist/src/promise.d.ts deleted file mode 100644 index 741471c..0000000 --- a/dist/src/promise.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -export declare class Promise { - private _state; - private _value; - private _handlers; - constructor(executor: (resovle: any, reject: any) => void); - private _resolve(x); - private _fulfill(result); - private _reject(error); - private _isPending(); - private _isFulfilled(); - private _isRejected(); - private _addHandler(onFulfilled, onRejected); - private _callHandler(handler); - then(onFulfilled: any, onRejected?: any): Promise; -} diff --git a/dist/src/promise.js b/dist/src/promise.js index 9403a0b..656cb02 100644 --- a/dist/src/promise.js +++ b/dist/src/promise.js @@ -1,164 +1,200 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var State; -(function (State) { - State[State["Pending"] = 0] = "Pending"; - State[State["Fulfilled"] = 1] = "Fulfilled"; - State[State["Rejected"] = 2] = "Rejected"; -})(State || (State = {})); -class Util { - static isFunction(val) { - return val && typeof val === "function"; - } - static isObject(val) { - return val && typeof val === "object"; - } -} -class Promise { - constructor(executor) { - this._handlers = []; - this._state = State.Pending; - executor(this._resolve.bind(this), this._reject.bind(this)); - } - _resolve(x) { - if (x === this) { - throw new TypeError("Resolving object can not be the same object"); - } - else if (x instanceof Promise) { - x.then(this._resolve.bind(this), this._reject.bind(this)); - } - else if (Util.isObject(x) || Util.isFunction(x)) { - let called = false; - try { - const thenable = x.then; - if (Util.isFunction(thenable)) { - thenable.call(x, (result) => { - if (!called) - this._resolve(result); - called = true; - }, (error) => { - if (!called) - this._reject(error); - called = true; - }); - } - else { - this._fulfill(x); - } - } - catch (ex) { - if (!called) { - this._reject(ex); - } - } - } - else { +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var State = { + Pending: 'Pending', + Fulfilled: 'Fulfilled', + Rejected: 'Rejected' +}; + +var Util = { + isFunction: function isFunction(val) { + return val && typeof val === "function"; + }, + isObject: function isObject(val) { + return val && (typeof val === 'undefined' ? 'undefined' : _typeof(val)) === "object"; + } +}; + +var Promise = exports.Promise = function () { + function Promise(executor) { + _classCallCheck(this, Promise); + + this._state = State.Pending; + this._handlers = []; + this._value = null; + executor(this._resolve.bind(this), this._reject.bind(this)); + } + + _createClass(Promise, [{ + key: '_resolve', + value: function _resolve(x) { + var _this = this; + + if (x === this) { + throw new TypeError("Resolving object can not be the same object"); + } else if (x instanceof Promise) { + x.then(this._resolve.bind(this), this._reject.bind(this)); + } else if (Util.isObject(x) || Util.isFunction(x)) { + var called = false; + try { + var thenable = x.then; + if (Util.isFunction(thenable)) { + thenable.call(x, function (result) { + if (!called) _this._resolve(result); + called = true; + }, function (error) { + if (!called) _this._reject(error); + called = true; + }); + } else { this._fulfill(x); + } + } catch (ex) { + if (!called) { + this._reject(ex); + } } + } else { + this._fulfill(x); + } } - _fulfill(result) { - this._state = State.Fulfilled; - this._value = result; - this._handlers.forEach(handler => this._callHandler(handler)); + }, { + key: '_fulfill', + value: function _fulfill(result) { + var _this2 = this; + + this._state = State.Fulfilled; + this._value = result; + this._handlers.forEach(function (handler) { + return _this2._callHandler(handler); + }); } - _reject(error) { - this._state = State.Rejected; - this._value = error; - this._handlers.forEach(handler => this._callHandler(handler)); + }, { + key: '_reject', + value: function _reject(error) { + var _this3 = this; + + this._state = State.Rejected; + this._value = error; + this._handlers.forEach(function (handler) { + return _this3._callHandler(handler); + }); } - _isPending() { - return this._state === State.Pending; + }, { + key: '_isPending', + value: function _isPending() { + return this._state === State.Pending; } - _isFulfilled() { - return this._state === State.Fulfilled; + }, { + key: '_isFulfilled', + value: function _isFulfilled() { + return this._state === State.Fulfilled; } - _isRejected() { - return this._state === State.Rejected; + }, { + key: '_isRejected', + value: function _isRejected() { + return this._state === State.Rejected; } - _addHandler(onFulfilled, onRejected) { - this._handlers.push({ - onFulfilled, - onRejected - }); + }, { + key: '_addHandler', + value: function _addHandler(onFulfilled, onRejected) { + this._handlers.push({ + onFulfilled: onFulfilled, + onRejected: onRejected + }); } - _callHandler(handler) { - if (this._isFulfilled() && Util.isFunction(handler.onFulfilled)) { - handler.onFulfilled(this._value); - } - else if (this._isRejected() && Util.isFunction(handler.onRejected)) { - handler.onRejected(this._value); - } + }, { + key: '_callHandler', + value: function _callHandler(handler) { + if (this._isFulfilled() && Util.isFunction(handler.onFulfilled)) { + handler.onFulfilled(this._value); + } else if (this._isRejected() && Util.isFunction(handler.onRejected)) { + handler.onRejected(this._value); + } } - then(onFulfilled, onRejected) { - switch (this._state) { - case State.Pending: { - return new Promise((resolve, reject) => { - this._addHandler((value) => { - setTimeout(() => { - try { - if (Util.isFunction(onFulfilled)) { - resolve(onFulfilled(value)); - } - else { - resolve(value); - } - } - catch (ex) { - reject(ex); - } - }, 0); - }, (error) => { - setTimeout(() => { - try { - if (Util.isFunction(onRejected)) { - resolve(onRejected(error)); - } - else { - reject(error); - } - } - catch (ex) { - reject(ex); - } - }, 0); - }); - }); - } - case State.Fulfilled: { - return new Promise((resolve, reject) => { - setTimeout(() => { - try { - if (Util.isFunction(onFulfilled)) { - resolve(onFulfilled(this._value)); - } - else { - resolve(this._value); - } - } - catch (ex) { - reject(ex); - } - }, 0); - }); - } - case State.Rejected: { - return new Promise((resolve, reject) => { - setTimeout(() => { - try { - if (Util.isFunction(onRejected)) { - resolve(onRejected(this._value)); - } - else { - reject(this._value); - } - } - catch (ex) { - reject(ex); - } - }, 0); - }); - } - } + }, { + key: 'then', + value: function then(onFulfilled, onRejected) { + var _this4 = this; + + switch (this._state) { + case State.Pending: + { + return new Promise(function (resolve, reject) { + _this4._addHandler(function (value) { + setTimeout(function () { + try { + if (Util.isFunction(onFulfilled)) { + resolve(onFulfilled(value)); + } else { + resolve(value); + } + } catch (ex) { + reject(ex); + } + }, 0); + }, function (error) { + setTimeout(function () { + try { + if (Util.isFunction(onRejected)) { + resolve(onRejected(error)); + } else { + reject(error); + } + } catch (ex) { + reject(ex); + } + }, 0); + }); + }); + } + + case State.Fulfilled: + { + return new Promise(function (resolve, reject) { + setTimeout(function () { + try { + if (Util.isFunction(onFulfilled)) { + resolve(onFulfilled(_this4._value)); + } else { + resolve(_this4._value); + } + } catch (ex) { + reject(ex); + } + }, 0); + }); + } + + case State.Rejected: + { + return new Promise(function (resolve, reject) { + setTimeout(function () { + try { + if (Util.isFunction(onRejected)) { + resolve(onRejected(_this4._value)); + } else { + reject(_this4._value); + } + } catch (ex) { + reject(ex); + } + }, 0); + }); + } + } } -} -exports.Promise = Promise; + }]); + + return Promise; +}(); \ No newline at end of file diff --git a/dist/test/aplus_test.d.ts b/dist/test/aplus_test.d.ts deleted file mode 100644 index e69de29..0000000 diff --git a/dist/test/aplus_test.js b/dist/test/aplus_test.js index cf0e998..ce5e59b 100644 --- a/dist/test/aplus_test.js +++ b/dist/test/aplus_test.js @@ -1,11 +1,13 @@ "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const promise_1 = require("../src/promise"); + +var _promise = require("../src/promise"); + var promisesAplusTests = require("promises-aplus-tests"); -const adapter = { - deferred() { - const pending = {}; - pending.promise = new promise_1.Promise((resolver, reject) => { + +var adapter = { + deferred: function deferred() { + var pending = {}; + pending.promise = new _promise.Promise(function (resolver, reject) { pending.resolve = resolver; pending.reject = reject; }); @@ -14,4 +16,4 @@ const adapter = { }; promisesAplusTests(adapter, function (err) { // All done; output is in the console. Or check `err` for number of failures. -}); +}); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 9f647d9..30ca1e8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,657 @@ { - "name": "promise-ts", + "name": "promised", "version": "1.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "babel-code-frame": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", + "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", + "dev": true, + "requires": { + "chalk": "1.1.3", + "esutils": "2.0.2", + "js-tokens": "3.0.2" + } + }, + "babel-core": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-core/-/babel-core-6.26.0.tgz", + "integrity": "sha1-rzL3izGm/O8RnIew/Y2XU/A6C7g=", + "dev": true, + "requires": { + "babel-code-frame": "6.26.0", + "babel-generator": "6.26.0", + "babel-helpers": "6.24.1", + "babel-messages": "6.23.0", + "babel-register": "6.26.0", + "babel-runtime": "6.26.0", + "babel-template": "6.26.0", + "babel-traverse": "6.26.0", + "babel-types": "6.26.0", + "babylon": "6.18.0", + "convert-source-map": "1.5.1", + "debug": "2.6.9", + "json5": "0.5.1", + "lodash": "4.17.4", + "minimatch": "3.0.4", + "path-is-absolute": "1.0.1", + "private": "0.1.8", + "slash": "1.0.0", + "source-map": "0.5.7" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "1.1.8" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, + "babel-generator": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.26.0.tgz", + "integrity": "sha1-rBriAHC3n248odMmlhMFN3TyDcU=", + "dev": true, + "requires": { + "babel-messages": "6.23.0", + "babel-runtime": "6.26.0", + "babel-types": "6.26.0", + "detect-indent": "4.0.0", + "jsesc": "1.3.0", + "lodash": "4.17.4", + "source-map": "0.5.7", + "trim-right": "1.0.1" + } + }, + "babel-helper-call-delegate": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-call-delegate/-/babel-helper-call-delegate-6.24.1.tgz", + "integrity": "sha1-7Oaqzdx25Bw0YfiL/Fdb0Nqi340=", + "dev": true, + "requires": { + "babel-helper-hoist-variables": "6.24.1", + "babel-runtime": "6.26.0", + "babel-traverse": "6.26.0", + "babel-types": "6.26.0" + } + }, + "babel-helper-define-map": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-helper-define-map/-/babel-helper-define-map-6.26.0.tgz", + "integrity": "sha1-pfVtq0GiX5fstJjH66ypgZ+Vvl8=", + "dev": true, + "requires": { + "babel-helper-function-name": "6.24.1", + "babel-runtime": "6.26.0", + "babel-types": "6.26.0", + "lodash": "4.17.4" + } + }, + "babel-helper-function-name": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz", + "integrity": "sha1-00dbjAPtmCQqJbSDUasYOZ01gKk=", + "dev": true, + "requires": { + "babel-helper-get-function-arity": "6.24.1", + "babel-runtime": "6.26.0", + "babel-template": "6.26.0", + "babel-traverse": "6.26.0", + "babel-types": "6.26.0" + } + }, + "babel-helper-get-function-arity": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.24.1.tgz", + "integrity": "sha1-j3eCqpNAfEHTqlCQj4mwMbG2hT0=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "babel-types": "6.26.0" + } + }, + "babel-helper-hoist-variables": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.24.1.tgz", + "integrity": "sha1-HssnaJydJVE+rbyZFKc/VAi+enY=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "babel-types": "6.26.0" + } + }, + "babel-helper-optimise-call-expression": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.24.1.tgz", + "integrity": "sha1-96E0J7qfc/j0+pk8VKl4gtEkQlc=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "babel-types": "6.26.0" + } + }, + "babel-helper-regex": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-helper-regex/-/babel-helper-regex-6.26.0.tgz", + "integrity": "sha1-MlxZ+QL4LyS3T6zu0DY5VPZJXnI=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "babel-types": "6.26.0", + "lodash": "4.17.4" + } + }, + "babel-helper-replace-supers": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-replace-supers/-/babel-helper-replace-supers-6.24.1.tgz", + "integrity": "sha1-v22/5Dk40XNpohPKiov3S2qQqxo=", + "dev": true, + "requires": { + "babel-helper-optimise-call-expression": "6.24.1", + "babel-messages": "6.23.0", + "babel-runtime": "6.26.0", + "babel-template": "6.26.0", + "babel-traverse": "6.26.0", + "babel-types": "6.26.0" + } + }, + "babel-helpers": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helpers/-/babel-helpers-6.24.1.tgz", + "integrity": "sha1-NHHenK7DiOXIUOWX5Yom3fN2ArI=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "babel-template": "6.26.0" + } + }, + "babel-messages": { + "version": "6.23.0", + "resolved": "https://registry.npmjs.org/babel-messages/-/babel-messages-6.23.0.tgz", + "integrity": "sha1-8830cDhYA1sqKVHG7F7fbGLyYw4=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0" + } + }, + "babel-plugin-check-es2015-constants": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz", + "integrity": "sha1-NRV7EBQm/S/9PaP3XH0ekYNbv4o=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0" + } + }, + "babel-plugin-transform-es2015-arrow-functions": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz", + "integrity": "sha1-RSaSy3EdX3ncf4XkQM5BufJE0iE=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0" + } + }, + "babel-plugin-transform-es2015-block-scoped-functions": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-block-scoped-functions/-/babel-plugin-transform-es2015-block-scoped-functions-6.22.0.tgz", + "integrity": "sha1-u8UbSflk1wy42OC5ToICRs46YUE=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0" + } + }, + "babel-plugin-transform-es2015-block-scoping": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.26.0.tgz", + "integrity": "sha1-1w9SmcEwjQXBL0Y4E7CgnnOxiV8=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "babel-template": "6.26.0", + "babel-traverse": "6.26.0", + "babel-types": "6.26.0", + "lodash": "4.17.4" + } + }, + "babel-plugin-transform-es2015-classes": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.24.1.tgz", + "integrity": "sha1-WkxYpQyclGHlZLSyo7+ryXolhNs=", + "dev": true, + "requires": { + "babel-helper-define-map": "6.26.0", + "babel-helper-function-name": "6.24.1", + "babel-helper-optimise-call-expression": "6.24.1", + "babel-helper-replace-supers": "6.24.1", + "babel-messages": "6.23.0", + "babel-runtime": "6.26.0", + "babel-template": "6.26.0", + "babel-traverse": "6.26.0", + "babel-types": "6.26.0" + } + }, + "babel-plugin-transform-es2015-computed-properties": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.24.1.tgz", + "integrity": "sha1-b+Ko0WiV1WNPTNmZttNICjCBWbM=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "babel-template": "6.26.0" + } + }, + "babel-plugin-transform-es2015-destructuring": { + "version": "6.23.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-destructuring/-/babel-plugin-transform-es2015-destructuring-6.23.0.tgz", + "integrity": "sha1-mXux8auWf2gtKwh2/jWNYOdlxW0=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0" + } + }, + "babel-plugin-transform-es2015-duplicate-keys": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.24.1.tgz", + "integrity": "sha1-c+s9MQypaePvnskcU3QabxV2Qj4=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "babel-types": "6.26.0" + } + }, + "babel-plugin-transform-es2015-for-of": { + "version": "6.23.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-for-of/-/babel-plugin-transform-es2015-for-of-6.23.0.tgz", + "integrity": "sha1-9HyVsrYT3x0+zC/bdXNiPHUkhpE=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0" + } + }, + "babel-plugin-transform-es2015-function-name": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.24.1.tgz", + "integrity": "sha1-g0yJhTvDaxrw86TF26qU/Y6sqos=", + "dev": true, + "requires": { + "babel-helper-function-name": "6.24.1", + "babel-runtime": "6.26.0", + "babel-types": "6.26.0" + } + }, + "babel-plugin-transform-es2015-literals": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-literals/-/babel-plugin-transform-es2015-literals-6.22.0.tgz", + "integrity": "sha1-T1SgLWzWbPkVKAAZox0xklN3yi4=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0" + } + }, + "babel-plugin-transform-es2015-modules-amd": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.24.1.tgz", + "integrity": "sha1-Oz5UAXI5hC1tGcMBHEvS8AoA0VQ=", + "dev": true, + "requires": { + "babel-plugin-transform-es2015-modules-commonjs": "6.26.0", + "babel-runtime": "6.26.0", + "babel-template": "6.26.0" + } + }, + "babel-plugin-transform-es2015-modules-commonjs": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.0.tgz", + "integrity": "sha1-DYOUApt9xqvhqX7xgeAHWN0uXYo=", + "dev": true, + "requires": { + "babel-plugin-transform-strict-mode": "6.24.1", + "babel-runtime": "6.26.0", + "babel-template": "6.26.0", + "babel-types": "6.26.0" + } + }, + "babel-plugin-transform-es2015-modules-systemjs": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.24.1.tgz", + "integrity": "sha1-/4mhQrkRmpBhlfXxBuzzBdlAfSM=", + "dev": true, + "requires": { + "babel-helper-hoist-variables": "6.24.1", + "babel-runtime": "6.26.0", + "babel-template": "6.26.0" + } + }, + "babel-plugin-transform-es2015-modules-umd": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.24.1.tgz", + "integrity": "sha1-rJl+YoXNGO1hdq22B9YCNErThGg=", + "dev": true, + "requires": { + "babel-plugin-transform-es2015-modules-amd": "6.24.1", + "babel-runtime": "6.26.0", + "babel-template": "6.26.0" + } + }, + "babel-plugin-transform-es2015-object-super": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.24.1.tgz", + "integrity": "sha1-JM72muIcuDp/hgPa0CH1cusnj40=", + "dev": true, + "requires": { + "babel-helper-replace-supers": "6.24.1", + "babel-runtime": "6.26.0" + } + }, + "babel-plugin-transform-es2015-parameters": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.24.1.tgz", + "integrity": "sha1-V6w1GrScrxSpfNE7CfZv3wpiXys=", + "dev": true, + "requires": { + "babel-helper-call-delegate": "6.24.1", + "babel-helper-get-function-arity": "6.24.1", + "babel-runtime": "6.26.0", + "babel-template": "6.26.0", + "babel-traverse": "6.26.0", + "babel-types": "6.26.0" + } + }, + "babel-plugin-transform-es2015-shorthand-properties": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.24.1.tgz", + "integrity": "sha1-JPh11nIch2YbvZmkYi5R8U3jiqA=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "babel-types": "6.26.0" + } + }, + "babel-plugin-transform-es2015-spread": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-spread/-/babel-plugin-transform-es2015-spread-6.22.0.tgz", + "integrity": "sha1-1taKmfia7cRTbIGlQujdnxdG+NE=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0" + } + }, + "babel-plugin-transform-es2015-sticky-regex": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.24.1.tgz", + "integrity": "sha1-AMHNsaynERLN8M9hJsLta0V8zbw=", + "dev": true, + "requires": { + "babel-helper-regex": "6.26.0", + "babel-runtime": "6.26.0", + "babel-types": "6.26.0" + } + }, + "babel-plugin-transform-es2015-template-literals": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-template-literals/-/babel-plugin-transform-es2015-template-literals-6.22.0.tgz", + "integrity": "sha1-qEs0UPfp+PH2g51taH2oS7EjbY0=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0" + } + }, + "babel-plugin-transform-es2015-typeof-symbol": { + "version": "6.23.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-typeof-symbol/-/babel-plugin-transform-es2015-typeof-symbol-6.23.0.tgz", + "integrity": "sha1-3sCfHN3/lLUqxz1QXITfWdzOs3I=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0" + } + }, + "babel-plugin-transform-es2015-unicode-regex": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.24.1.tgz", + "integrity": "sha1-04sS9C6nMj9yk4fxinxa4frrNek=", + "dev": true, + "requires": { + "babel-helper-regex": "6.26.0", + "babel-runtime": "6.26.0", + "regexpu-core": "2.0.0" + } + }, + "babel-plugin-transform-regenerator": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.26.0.tgz", + "integrity": "sha1-4HA2lvveJ/Cj78rPi03KL3s6jy8=", + "dev": true, + "requires": { + "regenerator-transform": "0.10.1" + } + }, + "babel-plugin-transform-strict-mode": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.24.1.tgz", + "integrity": "sha1-1fr3qleKZbvlkc9e2uBKDGcCB1g=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "babel-types": "6.26.0" + } + }, + "babel-preset-es2015": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-preset-es2015/-/babel-preset-es2015-6.24.1.tgz", + "integrity": "sha1-1EBQ1rwsn+6nAqrzjXJ6AhBTiTk=", + "dev": true, + "requires": { + "babel-plugin-check-es2015-constants": "6.22.0", + "babel-plugin-transform-es2015-arrow-functions": "6.22.0", + "babel-plugin-transform-es2015-block-scoped-functions": "6.22.0", + "babel-plugin-transform-es2015-block-scoping": "6.26.0", + "babel-plugin-transform-es2015-classes": "6.24.1", + "babel-plugin-transform-es2015-computed-properties": "6.24.1", + "babel-plugin-transform-es2015-destructuring": "6.23.0", + "babel-plugin-transform-es2015-duplicate-keys": "6.24.1", + "babel-plugin-transform-es2015-for-of": "6.23.0", + "babel-plugin-transform-es2015-function-name": "6.24.1", + "babel-plugin-transform-es2015-literals": "6.22.0", + "babel-plugin-transform-es2015-modules-amd": "6.24.1", + "babel-plugin-transform-es2015-modules-commonjs": "6.26.0", + "babel-plugin-transform-es2015-modules-systemjs": "6.24.1", + "babel-plugin-transform-es2015-modules-umd": "6.24.1", + "babel-plugin-transform-es2015-object-super": "6.24.1", + "babel-plugin-transform-es2015-parameters": "6.24.1", + "babel-plugin-transform-es2015-shorthand-properties": "6.24.1", + "babel-plugin-transform-es2015-spread": "6.22.0", + "babel-plugin-transform-es2015-sticky-regex": "6.24.1", + "babel-plugin-transform-es2015-template-literals": "6.22.0", + "babel-plugin-transform-es2015-typeof-symbol": "6.23.0", + "babel-plugin-transform-es2015-unicode-regex": "6.24.1", + "babel-plugin-transform-regenerator": "6.26.0" + } + }, + "babel-register": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-register/-/babel-register-6.26.0.tgz", + "integrity": "sha1-btAhFz4vy0htestFxgCahW9kcHE=", + "dev": true, + "requires": { + "babel-core": "6.26.0", + "babel-runtime": "6.26.0", + "core-js": "2.5.3", + "home-or-tmp": "2.0.0", + "lodash": "4.17.4", + "mkdirp": "0.5.1", + "source-map-support": "0.4.18" + } + }, + "babel-runtime": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", + "dev": true, + "requires": { + "core-js": "2.5.3", + "regenerator-runtime": "0.11.1" + } + }, + "babel-template": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-template/-/babel-template-6.26.0.tgz", + "integrity": "sha1-3gPi0WOWsGn0bdn/+FIfsaDjXgI=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "babel-traverse": "6.26.0", + "babel-types": "6.26.0", + "babylon": "6.18.0", + "lodash": "4.17.4" + } + }, + "babel-traverse": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-traverse/-/babel-traverse-6.26.0.tgz", + "integrity": "sha1-RqnL1+3MYsjlwGTi0tjQ9ANXZu4=", + "dev": true, + "requires": { + "babel-code-frame": "6.26.0", + "babel-messages": "6.23.0", + "babel-runtime": "6.26.0", + "babel-types": "6.26.0", + "babylon": "6.18.0", + "debug": "2.6.9", + "globals": "9.18.0", + "invariant": "2.2.2", + "lodash": "4.17.4" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, + "babel-types": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.26.0.tgz", + "integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "esutils": "2.0.2", + "lodash": "4.17.4", + "to-fast-properties": "1.0.3" + } + }, + "babylon": { + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz", + "integrity": "sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ==", + "dev": true + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "brace-expansion": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", + "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", + "dev": true, + "requires": { + "balanced-match": "1.0.0", + "concat-map": "0.0.1" + } + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "2.2.1", + "escape-string-regexp": "1.0.2", + "has-ansi": "2.0.0", + "strip-ansi": "3.0.1", + "supports-color": "2.0.0" + }, + "dependencies": { + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + } + } + }, "commander": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/commander/-/commander-2.3.0.tgz", "integrity": "sha1-/UMOiJgy7DU7ms0d4hfBHLPu+HM=", "dev": true }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "convert-source-map": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.5.1.tgz", + "integrity": "sha1-uCeAl7m8IpNl3lxiz1/K7YtVmeU=", + "dev": true + }, + "core-js": { + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.3.tgz", + "integrity": "sha1-isw4NFgk8W2DZbfJtCWRaOjtYD4=", + "dev": true + }, "debug": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", @@ -19,6 +661,15 @@ "ms": "0.7.1" } }, + "detect-indent": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-4.0.0.tgz", + "integrity": "sha1-920GQ1LN9Docts5hnE7jqUdd4gg=", + "dev": true, + "requires": { + "repeating": "2.0.1" + } + }, "diff": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/diff/-/diff-1.4.0.tgz", @@ -31,6 +682,12 @@ "integrity": "sha1-Tbwv5nTnGUnK8/smlc5/LcHZqNE=", "dev": true }, + "esutils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", + "dev": true + }, "formatio": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/formatio/-/formatio-1.1.1.tgz", @@ -50,18 +707,61 @@ "minimatch": "0.3.0" } }, + "globals": { + "version": "9.18.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz", + "integrity": "sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ==", + "dev": true + }, "growl": { "version": "1.9.2", "resolved": "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz", "integrity": "sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8=", "dev": true }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, + "home-or-tmp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/home-or-tmp/-/home-or-tmp-2.0.0.tgz", + "integrity": "sha1-42w/LSyufXRqhX440Y1fMqeILbg=", + "dev": true, + "requires": { + "os-homedir": "1.0.2", + "os-tmpdir": "1.0.2" + } + }, "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, + "invariant": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.2.tgz", + "integrity": "sha1-nh9WrArNtr8wMwbzOL47IErmA2A=", + "dev": true, + "requires": { + "loose-envify": "1.3.1" + } + }, + "is-finite": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", + "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", + "dev": true, + "requires": { + "number-is-nan": "1.0.1" + } + }, "jade": { "version": "0.26.3", "resolved": "https://registry.npmjs.org/jade/-/jade-0.26.3.tgz", @@ -86,12 +786,45 @@ } } }, + "js-tokens": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", + "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", + "dev": true + }, + "jsesc": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz", + "integrity": "sha1-RsP+yMGJKxKwgz25vHYiF226s0s=", + "dev": true + }, + "json5": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", + "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=", + "dev": true + }, + "lodash": { + "version": "4.17.4", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", + "dev": true + }, "lolex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-1.3.2.tgz", "integrity": "sha1-fD2mL/yzDw9agKJWbKJORdigHzE=", "dev": true }, + "loose-envify": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.3.1.tgz", + "integrity": "sha1-0aitM/qc4OcT1l/dCsi3SNR4yEg=", + "dev": true, + "requires": { + "js-tokens": "3.0.2" + } + }, "lru-cache": { "version": "2.7.3", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", @@ -147,6 +880,36 @@ "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=", "dev": true }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "dev": true + }, + "os-homedir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", + "dev": true + }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "private": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", + "integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==", + "dev": true + }, "promises-aplus-tests": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/promises-aplus-tests/-/promises-aplus-tests-2.1.2.tgz", @@ -158,6 +921,72 @@ "underscore": "1.8.3" } }, + "regenerate": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.3.3.tgz", + "integrity": "sha512-jVpo1GadrDAK59t/0jRx5VxYWQEDkkEKi6+HjE3joFVLfDOh9Xrdh0dF1eSq+BI/SwvTQ44gSscJ8N5zYL61sg==", + "dev": true + }, + "regenerator-runtime": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==", + "dev": true + }, + "regenerator-transform": { + "version": "0.10.1", + "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.10.1.tgz", + "integrity": "sha512-PJepbvDbuK1xgIgnau7Y90cwaAmO/LCLMI2mPvaXq2heGMR3aWW5/BQvYrhJ8jgmQjXewXvBjzfqKcVOmhjZ6Q==", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "babel-types": "6.26.0", + "private": "0.1.8" + } + }, + "regexpu-core": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-2.0.0.tgz", + "integrity": "sha1-SdA4g3uNz4v6W5pCE5k45uoq4kA=", + "dev": true, + "requires": { + "regenerate": "1.3.3", + "regjsgen": "0.2.0", + "regjsparser": "0.1.5" + } + }, + "regjsgen": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.2.0.tgz", + "integrity": "sha1-bAFq3qxVT3WCP+N6wFuS1aTtsfc=", + "dev": true + }, + "regjsparser": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.1.5.tgz", + "integrity": "sha1-fuj4Tcb6eS0/0K4ijSS9lJ6tIFw=", + "dev": true, + "requires": { + "jsesc": "0.5.0" + }, + "dependencies": { + "jsesc": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", + "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", + "dev": true + } + } + }, + "repeating": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", + "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", + "dev": true, + "requires": { + "is-finite": "1.0.2" + } + }, "samsam": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.1.2.tgz", @@ -182,18 +1011,60 @@ "util": "0.10.3" } }, + "slash": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz", + "integrity": "sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU=", + "dev": true + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + }, + "source-map-support": { + "version": "0.4.18", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.18.tgz", + "integrity": "sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==", + "dev": true, + "requires": { + "source-map": "0.5.7" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, "supports-color": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-1.2.0.tgz", "integrity": "sha1-/x7R5hFp0Gs88tWI4YixjYhH4X4=", "dev": true }, + "to-fast-properties": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz", + "integrity": "sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=", + "dev": true + }, "to-iso-string": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/to-iso-string/-/to-iso-string-0.0.2.tgz", "integrity": "sha1-TcGeZk38y+Jb2NtQiwDG2hWCVdE=", "dev": true }, + "trim-right": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz", + "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=", + "dev": true + }, "typescript": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.6.2.tgz", diff --git a/package.json b/package.json index c0dacae..76de7e1 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,19 @@ { - "name": "promise-ts", + "name": "promised", "version": "1.0.0", - "description": "A promise implementation in TypeScript", - "main": "index.js", - "types": "index.d.ts", + "description": "A 150 loc Promises/A+ implementation", + "main": "src/promise.js", "scripts": { - "build": "tsc", + "build": "babel src/** test/** -d dist", "test": "node dist/test/aplus_test.js" }, "author": "yanguango", "license": "MIT", "devDependencies": { - "typescript": "^2.6.2", - "promises-aplus-tests": "*" + "babel-core": "^6.26.0", + "babel-plugin-transform-es2015-modules-commonjs": "^6.26.0", + "babel-preset-es2015": "^6.24.1", + "promises-aplus-tests": "*", + "typescript": "^2.6.2" } } diff --git a/src/promise.ts b/src/promise.js similarity index 81% rename from src/promise.ts rename to src/promise.js index e8b9ea9..774e0c8 100644 --- a/src/promise.ts +++ b/src/promise.js @@ -1,31 +1,28 @@ -enum State { - Pending, - Fulfilled, - Rejected +const State = { + Pending: 'Pending', + Fulfilled: 'Fulfilled', + Rejected: 'Rejected' } -class Util { - static isFunction(val: any): boolean { +const Util = { + isFunction(val) { return val && typeof val === "function"; - } + }, - static isObject(val: any): boolean { + isObject(val) { return val && typeof val === "object"; } } export class Promise { - private _state: State; - private _value: any; - private _handlers: any[] = []; - - constructor(executor: (resovle: any, reject: any) => void) { + constructor(executor) { this._state = State.Pending; - + this._handlers = []; + this._value = null; executor(this._resolve.bind(this), this._reject.bind(this)); } - private _resolve(x: any) { + _resolve(x) { if (x === this) { throw new TypeError("Resolving object can not be the same object"); } else if (x instanceof Promise) { @@ -37,11 +34,11 @@ export class Promise { if (Util.isFunction(thenable)) { thenable.call( x, - (result: any) => { + (result) => { if (!called) this._resolve(result); called = true; }, - (error: any) => { + (error) => { if (!called) this._reject(error); called = true; } @@ -59,38 +56,38 @@ export class Promise { } } - private _fulfill(result: any) { + _fulfill(result) { this._state = State.Fulfilled; this._value = result; this._handlers.forEach(handler => this._callHandler(handler)); } - private _reject(error: any) { + _reject(error) { this._state = State.Rejected; this._value = error; this._handlers.forEach(handler => this._callHandler(handler)); } - private _isPending(): boolean { + _isPending() { return this._state === State.Pending; } - private _isFulfilled(): boolean { + _isFulfilled() { return this._state === State.Fulfilled; } - private _isRejected(): boolean { + _isRejected() { return this._state === State.Rejected; } - private _addHandler(onFulfilled: any, onRejected: any) { + _addHandler(onFulfilled, onRejected) { this._handlers.push({ onFulfilled, onRejected }); } - private _callHandler(handler: { onFulfilled: any; onRejected: any }) { + _callHandler(handler) { if (this._isFulfilled() && Util.isFunction(handler.onFulfilled)) { handler.onFulfilled(this._value); } else if (this._isRejected() && Util.isFunction(handler.onRejected)) { @@ -98,12 +95,12 @@ export class Promise { } } - then(onFulfilled: any, onRejected?: any) { + then(onFulfilled, onRejected) { switch (this._state) { case State.Pending: { return new Promise((resolve, reject) => { this._addHandler( - (value: any) => { + (value) => { setTimeout(() => { try { if (Util.isFunction(onFulfilled)) { @@ -116,7 +113,7 @@ export class Promise { } }, 0); }, - (error: any) => { + (error) => { setTimeout(() => { try { if (Util.isFunction(onRejected)) { diff --git a/test/aplus_test.ts b/test/aplus_test.js similarity index 75% rename from test/aplus_test.ts rename to test/aplus_test.js index 87f686e..ba5df2b 100644 --- a/test/aplus_test.ts +++ b/test/aplus_test.js @@ -1,10 +1,10 @@ import { Promise } from "../src/promise"; -declare var require:(moduleId:string) => any; + var promisesAplusTests = require("promises-aplus-tests"); const adapter = { deferred() { - const pending: any = {}; + const pending = {}; pending.promise = new Promise((resolver, reject) => { pending.resolve = resolver; pending.reject = reject; @@ -12,6 +12,6 @@ const adapter = { return pending; } }; -promisesAplusTests(adapter, function (err: any) { +promisesAplusTests(adapter, function (err) { // All done; output is in the console. Or check `err` for number of failures. }); diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index a786c21..0000000 --- a/tsconfig.json +++ /dev/null @@ -1,12 +0,0 @@ -{ -  "compilerOptions": { -    "target": "ES6", -    "module": "commonjs", -    "declaration": true, -    "outDir": "./dist", -    "strict": true, - "typeRoots": [ - "./node_modules/@types" - ] -  } -} \ No newline at end of file