pax_global_header00006660000000000000000000000064136515754500014525gustar00rootroot0000000000000052 comment=5a240f639ff89f9cb938bbaf3aef59f15ddd0117 is-promise-4.0.0/000077500000000000000000000000001365157545000136155ustar00rootroot00000000000000is-promise-4.0.0/.circleci/000077500000000000000000000000001365157545000154505ustar00rootroot00000000000000is-promise-4.0.0/.circleci/config.yml000066400000000000000000000057571365157545000174560ustar00rootroot00000000000000version: 2.1 refs: - &only_master filters: branches: only: master - ¬_master filters: branches: ignore: master workflows: test: jobs: - unit-tests: <<: *not_master name: node-6 version: '6' - unit-tests: <<: *not_master name: node-8 version: '8' - unit-tests: <<: *not_master name: node-10 version: '10' - unit-tests: <<: *not_master name: node-12 version: '12' - unit-tests: <<: *not_master name: node-14 version: '14' release: jobs: - unit-tests: <<: *only_master name: node-6 version: '6' - unit-tests: <<: *only_master name: node-8 version: '8' - unit-tests: <<: *only_master name: node-10 version: '10' - unit-tests: <<: *only_master name: node-12 version: '12' - unit-tests: <<: *only_master name: node-14 version: '14' - publish-dry-run: <<: *only_master - publish-approval: type: approval requires: - publish-dry-run - publish: <<: *only_master requires: - node-6 - node-8 - node-10 - node-12 - node-14 - publish-approval jobs: unit-tests: parameters: version: type: string docker: - image: circleci/node:<< parameters.version >> steps: - setup - test publish-dry-run: docker: - image: circleci/node:12 steps: - setup - publish-dry-run publish: docker: - image: circleci/node:12 steps: - setup - publish commands: setup: description: 'Checkout and install dependencies' steps: - checkout - run: name: Versions command: node -v && npm -v - run: name: Install Dependencies command: npm i test: steps: - run: name: Test command: npm test - run: name: Pack command: npm pack - run: name: Setup Import Test command: echo $PWD && cd .. && cp -a project/test-import/ test-import/ && cd test-import && npm i && npm i ../project/is-promise-2.2.2.tgz - run: name: Test Import command: cd ../test-import && npm test publish-dry-run: steps: - run: name: NPM Auth command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc - run: name: Release (Dry Run) command: npx rollingversions publish --dry-run publish: steps: - run: name: NPM Auth command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc - run: name: Release command: npx rollingversions publishis-promise-4.0.0/.github/000077500000000000000000000000001365157545000151555ustar00rootroot00000000000000is-promise-4.0.0/.github/FUNDING.yml000066400000000000000000000013471365157545000167770ustar00rootroot00000000000000# These are supported funding model platforms github: [ForbesLindesay] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] patreon: # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username tidelift: npm/is-promise # Replace with a single Tidelift platform-name/package-name e.g., npm/babel community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] is-promise-4.0.0/.gitignore000066400000000000000000000000361365157545000156040ustar00rootroot00000000000000components build node_modules is-promise-4.0.0/LICENSE000066400000000000000000000020421365157545000146200ustar00rootroot00000000000000Copyright (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-4.0.0/component.json000066400000000000000000000004551365157545000165160ustar00rootroot00000000000000{ "name": "is-promise", "repo": "then/is-promise", "description": "Test whether an object looks like a promises-a+ promise", "version": "2.2.2", "keywords": [], "dependencies": {}, "development": {}, "license": "MIT", "scripts": [ "index.js" ], "twitter": "@ForbesLindesay" }is-promise-4.0.0/index.d.ts000066400000000000000000000001541365157545000155160ustar00rootroot00000000000000declare function isPromise(obj: PromiseLike | S): obj is PromiseLike; export default isPromise; is-promise-4.0.0/index.js000066400000000000000000000003111365157545000152550ustar00rootroot00000000000000module.exports = isPromise; module.exports.default = isPromise; function isPromise(obj) { return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function'; } is-promise-4.0.0/index.mjs000066400000000000000000000002271365157545000154400ustar00rootroot00000000000000export default function isPromise(obj) { return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function'; } is-promise-4.0.0/package.json000066400000000000000000000011001365157545000160730ustar00rootroot00000000000000{ "name": "is-promise", "version": "2.2.2", "description": "Test whether an object looks like a promises-a+ promise", "main": "./index.js", "scripts": { "test": "node test" }, "files": [ "index.js", "index.mjs", "index.d.ts" ], "exports": { ".": [ { "import": "./index.mjs", "require": "./index.js", "default": "./index.js" }, "./index.js" ] }, "repository": { "type": "git", "url": "https://github.com/then/is-promise.git" }, "author": "ForbesLindesay", "license": "MIT" } is-promise-4.0.0/readme.md000066400000000000000000000015401365157545000153740ustar00rootroot00000000000000 # 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/david/then/is-promise.svg)](https://david-dm.org/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 ```typescript import isPromise from 'is-promise'; isPromise(Promise.resolve());//=>true isPromise({then:function () {...}});//=>true isPromise(null);//=>false isPromise({});//=>false isPromise({then: true})//=>false ``` ## License MIT is-promise-4.0.0/test-import/000077500000000000000000000000001365157545000161045ustar00rootroot00000000000000is-promise-4.0.0/test-import/index.ts000066400000000000000000000003641365157545000175660ustar00rootroot00000000000000import * as ta from 'type-assertions'; import isPromise from 'is-promise'; declare const x: number | Promise; if (isPromise(x)) { ta.assert>>(); } else { ta.assert>(); }is-promise-4.0.0/test-import/package.json000066400000000000000000000003021365157545000203650ustar00rootroot00000000000000{ "name": "is-promise-test-import", "private": true, "@rollingversions/ignore": true, "scripts": { "test": "node test" }, "dependencies": { "type-assertions": "^1.1.0" } } is-promise-4.0.0/test-import/test.js000066400000000000000000000025421365157545000174240ustar00rootroot00000000000000var assert = require('assert'); var isPromise = require('is-promise'); assert(isPromise(null) === false); assert(isPromise(undefined) === false); assert(isPromise(0) === false); assert(isPromise(-42) === false); assert(isPromise(42) === false); assert(isPromise('') === false); assert(isPromise('then') === false); assert(isPromise(false) === false); assert(isPromise(true) === false); assert(isPromise({}) === false); assert(isPromise({then: true}) === false); assert(isPromise([]) === false); assert(isPromise([true]) === false); assert(isPromise(() => {}) === false); // This looks similar enough to a promise // that promises/A+ says we should treat // it as a promise. var promise = {then: function () {}}; assert(isPromise(promise) === true); const fn = () => {}; fn.then = () => {}; assert(isPromise(fn) === true); console.log('CommonJS tests passed') if(parseInt(process.version.split('.')[0].substr(1), 10) >= 14) { const result = require('child_process').spawnSync('node', ['test.mjs'], {cwd: __dirname, stdio: 'inherit'}); if (result.status) process.exit(result.status); } if(parseInt(process.version.split('.')[0].substr(1), 10) >= 12) { const result = require('child_process').spawnSync('npx', ['typescript', 'index.ts'], {cwd: __dirname, stdio: 'inherit'}); if (result.status) process.exit(result.status); console.log('TypeScript tests passed'); }is-promise-4.0.0/test-import/test.mjs000066400000000000000000000015341365157545000176010ustar00rootroot00000000000000import assert from 'assert'; import isPromise from 'is-promise'; assert(isPromise(null) === false); assert(isPromise(undefined) === false); assert(isPromise(0) === false); assert(isPromise(-42) === false); assert(isPromise(42) === false); assert(isPromise('') === false); assert(isPromise('then') === false); assert(isPromise(false) === false); assert(isPromise(true) === false); assert(isPromise({}) === false); assert(isPromise({then: true}) === false); assert(isPromise([]) === false); assert(isPromise([true]) === false); assert(isPromise(() => {}) === false); // This looks similar enough to a promise // that promises/A+ says we should treat // it as a promise. var promise = {then: function () {}}; assert(isPromise(promise) === true); const fn = () => {}; fn.then = () => {}; assert(isPromise(fn) === true); console.log('ES Modules tests passed') is-promise-4.0.0/test-import/tsconfig.json000066400000000000000000000001471365157545000206150ustar00rootroot00000000000000{ "compilerOptions": { "noImplicitAny": true, "skipLibCheck": false, "strict": true } }is-promise-4.0.0/test.js000066400000000000000000000020061365157545000151300ustar00rootroot00000000000000var assert = require('assert'); var isPromise = require('./'); // `.then` methods on primative types should // not make them count as promises String.prototype.then = () => {}; Number.prototype.then = () => {}; Boolean.prototype.then = () => {}; assert(isPromise(null) === false); assert(isPromise(undefined) === false); assert(isPromise(0) === false); assert(isPromise(-42) === false); assert(isPromise(42) === false); assert(isPromise('') === false); assert(isPromise('then') === false); assert(isPromise(false) === false); assert(isPromise(true) === false); assert(isPromise({}) === false); assert(isPromise({then: true}) === false); assert(isPromise([]) === false); assert(isPromise([true]) === false); assert(isPromise(() => {}) === false); // This looks similar enough to a promise // that promises/A+ says we should treat // it as a promise. var promise = {then: function () {}}; assert(isPromise(promise) === true); const fn = () => {}; fn.then = () => {}; assert(isPromise(fn) === true); console.log('tests passed')