[Pkg-javascript-commits] [node-is-promise] 01/05: Import Upstream version 2.1.0

Paolo Greppi paolog-guest at moszumanska.debian.org
Mon Dec 19 11:45:37 UTC 2016


This is an automated email from the git hooks/post-receive script.

paolog-guest pushed a commit to branch master
in repository node-is-promise.

commit 5b500ca4b8395dee78949c23ba41b95074d91b8b
Author: Paolo Greppi <paolo.greppi at libpf.com>
Date:   Fri Dec 16 18:08:29 2016 +0000

    Import Upstream version 2.1.0
---
 .gitignore     |  3 +++
 .npmignore     |  6 ++++++
 .travis.yml    |  3 +++
 LICENSE        | 19 +++++++++++++++++++
 component.json | 14 ++++++++++++++
 index.js       |  5 +++++
 package.json   | 19 +++++++++++++++++++
 readme.md      | 29 +++++++++++++++++++++++++++++
 test.js        | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 9 files changed, 154 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..665aa21
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+components
+build
+node_modules
diff --git a/.npmignore b/.npmignore
new file mode 100644
index 0000000..aeb7b45
--- /dev/null
+++ b/.npmignore
@@ -0,0 +1,6 @@
+component
+build
+node_modules
+test.js
+component.json
+.gitignore
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..87f8cd9
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,3 @@
+language: node_js
+node_js:
+  - "0.10"
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..27cc9f3
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,19 @@
+Copyright (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.
\ No newline at end of file
diff --git a/component.json b/component.json
new file mode 100644
index 0000000..c5870eb
--- /dev/null
+++ b/component.json
@@ -0,0 +1,14 @@
+{
+  "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"
+}
\ No newline at end of file
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..ca2444c
--- /dev/null
+++ b/index.js
@@ -0,0 +1,5 @@
+module.exports = isPromise;
+
+function isPromise(obj) {
+  return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
+}
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..cd8dae9
--- /dev/null
+++ b/package.json
@@ -0,0 +1,19 @@
+{
+  "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"
+  }
+}
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..50d5d98
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,29 @@
+<a href="http://promises-aplus.github.com/promises-spec"><img src="http://promises-aplus.github.com/promises-spec/assets/logo-small.png" align="right" /></a>
+# 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
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..d971c28
--- /dev/null
+++ b/test.js
@@ -0,0 +1,56 @@
+var 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]));
+    });
+  });
+});

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-is-promise.git



More information about the Pkg-javascript-commits mailing list