├── .editorconfig ├── .gitattributes ├── .gitignore ├── .jshintrc ├── .travis.yml ├── index.js ├── license ├── package.json ├── readme.md └── test.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | end_of_line = lf 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [{package.json,*.yml}] 11 | indent_style = space 12 | indent_size = 2 13 | 14 | [*.md] 15 | trim_trailing_whitespace = false 16 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "esnext": true, 4 | "bitwise": true, 5 | "curly": true, 6 | "immed": true, 7 | "newcap": true, 8 | "noarg": true, 9 | "undef": true, 10 | "unused": "vars", 11 | "strict": true 12 | } 13 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | node_js: 4 | - 'iojs' 5 | - '0.12' 6 | - '0.10' 7 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = typeof Promise === 'function' ? Promise : require('pinkie'); 4 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Vsevolod Strukchinsky (github.com/floatdrop) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pinkie-promise", 3 | "version": "2.0.1", 4 | "description": "ES2015 Promise ponyfill", 5 | "license": "MIT", 6 | "repository": "floatdrop/pinkie-promise", 7 | "author": { 8 | "name": "Vsevolod Strukchinsky", 9 | "email": "floatdrop@gmail.com", 10 | "url": "github.com/floatdrop" 11 | }, 12 | "engines": { 13 | "node": ">=0.10.0" 14 | }, 15 | "scripts": { 16 | "test": "mocha" 17 | }, 18 | "files": [ 19 | "index.js" 20 | ], 21 | "keywords": [ 22 | "promise", 23 | "promises", 24 | "es2015", 25 | "es6", 26 | "polyfill", 27 | "ponyfill" 28 | ], 29 | "dependencies": { 30 | "pinkie": "^2.0.0" 31 | }, 32 | "devDependencies": { 33 | "mocha": "*" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # pinkie-promise [![Build Status](https://travis-ci.org/floatdrop/pinkie-promise.svg?branch=master)](https://travis-ci.org/floatdrop/pinkie-promise) 2 | 3 | > ES2015 [`Promise`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise) [ponyfill](https://ponyfill.com) 4 | 5 | Module exports global Promise object (if available) or [`pinkie`](https://github.com/floatdrop/pinkie) Promise polyfill. 6 | 7 | ## Install 8 | 9 | ``` 10 | $ npm install --save pinkie-promise 11 | ``` 12 | 13 | ## Usage 14 | 15 | ```js 16 | var Promise = require('pinkie-promise'); 17 | 18 | new Promise(function (resolve) { resolve('unicorns'); }); 19 | //=> Promise { 'unicorns' } 20 | ``` 21 | 22 | ## Related 23 | 24 | - [pify](https://github.com/sindresorhus/pify) - Promisify a callback-style function 25 | 26 | ## License 27 | 28 | MIT © [Vsevolod Strukchinsky](https://github.com/floatdrop) 29 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var assert = require('assert'); 3 | var pinkiePromise = require('./'); 4 | var pinkie = require('pinkie'); 5 | 6 | it('should ponyfill Promise', function () { 7 | if (global.Promise) { 8 | assert.equal(pinkiePromise, global.Promise); 9 | } else { 10 | assert.equal(pinkiePromise, pinkie); 11 | } 12 | }); 13 | --------------------------------------------------------------------------------