pax_global_header00006660000000000000000000000064125445065250014522gustar00rootroot0000000000000052 comment=056f8ac12eed91886ac4f0f7d872a176f6ed698f is-promise-2.1.0/000077500000000000000000000000001254450652500136115ustar00rootroot00000000000000is-promise-2.1.0/.gitignore000066400000000000000000000000361254450652500156000ustar00rootroot00000000000000components build node_modules is-promise-2.1.0/.npmignore000066400000000000000000000000761254450652500156130ustar00rootroot00000000000000component build node_modules test.js component.json .gitignoreis-promise-2.1.0/.travis.yml000066400000000000000000000000451254450652500157210ustar00rootroot00000000000000language: node_js node_js: - "0.10"is-promise-2.1.0/LICENSE000066400000000000000000000020421254450652500146140ustar00rootroot00000000000000Copyright (c) 2014 Forbes Lindesay Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.is-promise-2.1.0/component.json000066400000000000000000000004551254450652500165120ustar00rootroot00000000000000{ "name": "is-promise", "repo": "then/is-promise", "description": "Test whether an object looks like a promises-a+ promise", "version": "2.0.0", "keywords": [], "dependencies": {}, "development": {}, "license": "MIT", "scripts": [ "index.js" ], "twitter": "@ForbesLindesay" }is-promise-2.1.0/index.js000066400000000000000000000002451254450652500152570ustar00rootroot00000000000000module.exports = isPromise; function isPromise(obj) { return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function'; } is-promise-2.1.0/package.json000066400000000000000000000006441254450652500161030ustar00rootroot00000000000000{ "name": "is-promise", "version": "2.1.0", "description": "Test whether an object looks like a promises-a+ promise", "main": "index.js", "scripts": { "test": "mocha -R spec" }, "repository": { "type": "git", "url": "https://github.com/then/is-promise.git" }, "author": "ForbesLindesay", "license": "MIT", "devDependencies": { "better-assert": "~0.1.0", "mocha": "~1.7.4" } } is-promise-2.1.0/readme.md000066400000000000000000000015501254450652500153710ustar00rootroot00000000000000 # is-promise Test whether an object looks like a promises-a+ promise [![Build Status](https://img.shields.io/travis/then/is-promise/master.svg)](https://travis-ci.org/then/is-promise) [![Dependency Status](https://img.shields.io/gemnasium/then/is-promise.svg)](https://gemnasium.com/then/is-promise) [![NPM version](https://img.shields.io/npm/v/is-promise.svg)](https://www.npmjs.org/package/is-promise) ## Installation $ npm install is-promise You can also use it client side via npm. ## API ```javascript var isPromise = require('is-promise'); isPromise({then:function () {...}});//=>true isPromise(null);//=>false isPromise({});//=>false isPromise({then: true})//=>false ``` ## License MIT is-promise-2.1.0/test.js000066400000000000000000000027131254450652500151310ustar00rootroot00000000000000var isPromise = require('./'); var assert = require('better-assert'); // This looks similar enough to a promise // that promises/A+ says we should treat // it as a promise. var promise = {then: function () {}}; describe('calling isPromise', function () { describe('with a promise', function () { it('returns true', function () { assert(isPromise(promise)); }); }); describe('with null', function () { it('returns false', function () { assert(isPromise(null) === false); }); }); describe('with undefined', function () { it('returns false', function () { assert(isPromise(undefined) === false); }); }); describe('with a number', function () { it('returns false', function () { assert(!isPromise(0)); assert(!isPromise(-42)); assert(!isPromise(42)); }); }); describe('with a string', function () { it('returns false', function () { assert(!isPromise('')); assert(!isPromise('then')); }); }); describe('with a bool', function () { it('returns false', function () { assert(!isPromise(false)); assert(!isPromise(true)); }); }); describe('with an object', function () { it('returns false', function () { assert(!isPromise({})); assert(!isPromise({then: true})); }); }); describe('with an array', function () { it('returns false', function () { assert(!isPromise([])); assert(!isPromise([true])); }); }); });