aboutsummaryrefslogtreecommitdiff
path: root/node_modules/call-me-maybe
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2019-10-06 21:37:45 +0200
committerDimitri Staessens <dimitri@ouroboros.rocks>2019-10-06 21:37:45 +0200
commit3c51c3be85bb0d1bdb87ea0d6632f1c256912f27 (patch)
treec7ccc8279b12c4f7bdbbb4270d617e48f51722e4 /node_modules/call-me-maybe
parent412c104bebc507bea9c94fd53b5bdc4b64cbfe31 (diff)
downloadwebsite-3c51c3be85bb0d1bdb87ea0d6632f1c256912f27.tar.gz
website-3c51c3be85bb0d1bdb87ea0d6632f1c256912f27.zip
build: Add some required modules for node
Diffstat (limited to 'node_modules/call-me-maybe')
-rw-r--r--node_modules/call-me-maybe/.npmignore27
-rw-r--r--node_modules/call-me-maybe/.travis.yml6
-rw-r--r--node_modules/call-me-maybe/.zuul.yml16
-rw-r--r--node_modules/call-me-maybe/LICENSE22
-rw-r--r--node_modules/call-me-maybe/README.md26
-rw-r--r--node_modules/call-me-maybe/index.js20
-rw-r--r--node_modules/call-me-maybe/package.json65
-rw-r--r--node_modules/call-me-maybe/test/maybeTest.js137
8 files changed, 319 insertions, 0 deletions
diff --git a/node_modules/call-me-maybe/.npmignore b/node_modules/call-me-maybe/.npmignore
new file mode 100644
index 0000000..123ae94
--- /dev/null
+++ b/node_modules/call-me-maybe/.npmignore
@@ -0,0 +1,27 @@
+# Logs
+logs
+*.log
+
+# Runtime data
+pids
+*.pid
+*.seed
+
+# Directory for instrumented libs generated by jscoverage/JSCover
+lib-cov
+
+# Coverage directory used by tools like istanbul
+coverage
+
+# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
+.grunt
+
+# node-waf configuration
+.lock-wscript
+
+# Compiled binary addons (http://nodejs.org/api/addons.html)
+build/Release
+
+# Dependency directory
+# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
+node_modules
diff --git a/node_modules/call-me-maybe/.travis.yml b/node_modules/call-me-maybe/.travis.yml
new file mode 100644
index 0000000..2bb2a34
--- /dev/null
+++ b/node_modules/call-me-maybe/.travis.yml
@@ -0,0 +1,6 @@
+language: node_js
+node_js:
+ - "node"
+ - "0.12"
+ - "0.10"
+ - "iojs"
diff --git a/node_modules/call-me-maybe/.zuul.yml b/node_modules/call-me-maybe/.zuul.yml
new file mode 100644
index 0000000..2aaea19
--- /dev/null
+++ b/node_modules/call-me-maybe/.zuul.yml
@@ -0,0 +1,16 @@
+ui: mocha-bdd
+browsers:
+ - name: chrome
+ version: -2..latest
+ - name: ie
+ version: -2..latest
+ - name: iphone
+ version: -3..latest
+ - name: safari
+ version: -4..latest
+ - name: firefox
+ version: -2..latest
+ - name: android
+ version: -3..latest
+ - name: opera
+ version: latest
diff --git a/node_modules/call-me-maybe/LICENSE b/node_modules/call-me-maybe/LICENSE
new file mode 100644
index 0000000..8447d84
--- /dev/null
+++ b/node_modules/call-me-maybe/LICENSE
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 Eric McCarthy
+
+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.
+
diff --git a/node_modules/call-me-maybe/README.md b/node_modules/call-me-maybe/README.md
new file mode 100644
index 0000000..ac74451
--- /dev/null
+++ b/node_modules/call-me-maybe/README.md
@@ -0,0 +1,26 @@
+# call-me-maybe [![Build Status](https://travis-ci.org/limulus/call-me-maybe.svg?branch=master)](https://travis-ci.org/limulus/call-me-maybe)
+
+Let your JS API users either give you a callback or receive a promise.
+
+## Usage
+
+```javascript
+var maybe = require("call-me-maybe")
+
+module.exports = function asyncFunc (cb) {
+ return maybe(cb, new Promise(function(resolve, reject) {
+ // ...
+ }))
+}
+```
+
+## API
+
+### maybe(cb, promise)
+
+If the callback `cb` is truthy, returns `undefined` and will call `cb` when `promise` is settled. The parameters passed to `cb` are standard error-first:
+
+ - If `promise` is fulfilled, then it is called with the result of the promise: `cb(null, result)`
+ - If `promise` is rejected, then it is called with the rejection error: `cb(err)`
+
+If `cb` is falsey, then `promise` is retuned.
diff --git a/node_modules/call-me-maybe/index.js b/node_modules/call-me-maybe/index.js
new file mode 100644
index 0000000..b3c5d44
--- /dev/null
+++ b/node_modules/call-me-maybe/index.js
@@ -0,0 +1,20 @@
+"use strict"
+
+var next = (global.process && process.nextTick) || global.setImmediate || function (f) {
+ setTimeout(f, 0)
+}
+
+module.exports = function maybe (cb, promise) {
+ if (cb) {
+ promise
+ .then(function (result) {
+ next(function () { cb(null, result) })
+ }, function (err) {
+ next(function () { cb(err) })
+ })
+ return undefined
+ }
+ else {
+ return promise
+ }
+}
diff --git a/node_modules/call-me-maybe/package.json b/node_modules/call-me-maybe/package.json
new file mode 100644
index 0000000..6ae0ce5
--- /dev/null
+++ b/node_modules/call-me-maybe/package.json
@@ -0,0 +1,65 @@
+{
+ "_args": [
+ [
+ "call-me-maybe@1.0.1",
+ "/home/dstaesse/git/website"
+ ]
+ ],
+ "_development": true,
+ "_from": "call-me-maybe@1.0.1",
+ "_id": "call-me-maybe@1.0.1",
+ "_inBundle": false,
+ "_integrity": "sha1-JtII6onje1y95gJQoV8DHBak1ms=",
+ "_location": "/call-me-maybe",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "version",
+ "registry": true,
+ "raw": "call-me-maybe@1.0.1",
+ "name": "call-me-maybe",
+ "escapedName": "call-me-maybe",
+ "rawSpec": "1.0.1",
+ "saveSpec": null,
+ "fetchSpec": "1.0.1"
+ },
+ "_requiredBy": [
+ "/@mrmlnc/readdir-enhanced"
+ ],
+ "_resolved": "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.1.tgz",
+ "_spec": "1.0.1",
+ "_where": "/home/dstaesse/git/website",
+ "author": {
+ "name": "Eric McCarthy",
+ "email": "eric@limulus.net",
+ "url": "http://www.limulus.net/"
+ },
+ "bugs": {
+ "url": "https://github.com/limulus/call-me-maybe/issues"
+ },
+ "dependencies": {},
+ "description": "Let your JS API users either give you a callback or receive a promise",
+ "devDependencies": {
+ "mocha": "^2.3.2",
+ "promise": "^7.0.4",
+ "zuul": "^3.4.0"
+ },
+ "homepage": "https://github.com/limulus/call-me-maybe#readme",
+ "keywords": [
+ "promise",
+ "callback",
+ "denodeify",
+ "promisify",
+ "carlyraejepsen"
+ ],
+ "license": "MIT",
+ "main": "index.js",
+ "name": "call-me-maybe",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/limulus/call-me-maybe.git"
+ },
+ "scripts": {
+ "test": "mocha"
+ },
+ "version": "1.0.1"
+}
diff --git a/node_modules/call-me-maybe/test/maybeTest.js b/node_modules/call-me-maybe/test/maybeTest.js
new file mode 100644
index 0000000..5ce3017
--- /dev/null
+++ b/node_modules/call-me-maybe/test/maybeTest.js
@@ -0,0 +1,137 @@
+"use strict"
+
+var maybe = require("../")
+var assert = require("assert")
+var Promise = global.Promise || require("promise")
+
+describe("maybe", function () {
+ it("should call the callback with result the promise is resolved to", function (done) {
+ var f = function f (cb) {
+ return maybe(cb, new Promise(function (resolve, reject) {
+ process.nextTick(function () {
+ return resolve("hi")
+ })
+ }))
+ }
+
+ f(function (err, result) {
+ assert.ifError(err, "no error")
+ assert.strictEqual(result, "hi")
+ return done()
+ })
+ })
+
+ it("should call the callback with the error the promise is rejected with", function (done) {
+ var f = function f (cb) {
+ return maybe(cb, new Promise(function (resolve, reject) {
+ process.nextTick(function () {
+ return reject(new Error("boom"))
+ })
+ }))
+ }
+
+ f(function (err, result) {
+ assert(err, "we got an error")
+ assert.strictEqual(result, undefined, "we got undefined result")
+ assert(err instanceof Error, "error is an Error")
+ assert.strictEqual(err.message, "boom", "error message is boom")
+ return done()
+ })
+ })
+
+ it("should return undefined when called with a callback", function () {
+ var f = function f (cb) {
+ return maybe(cb, new Promise(function (resolve, reject) {
+ //...
+ }))
+ }
+
+ var returnVal = f(function (err, result) {})
+ assert.strictEqual(returnVal, undefined, "returned val is undefined")
+ })
+
+ it("should return the same promise when no callback is provided", function () {
+ var p
+
+ var f = function f (cb) {
+ p = new Promise(function (resolve, reject) {
+ process.nextTick(function () {
+ return resolve("hi")
+ })
+ })
+ return maybe(cb, p)
+ }
+
+ var returnVal = f()
+ assert(p instanceof Promise, "returned val is a Promise")
+ assert.strictEqual(returnVal, p, "returned val is same obj (not a new Promise)")
+ })
+
+ it("should allow errors thrown in the callback to be uncaught", function (done) {
+ var mochaHandler
+
+ // Temporarily remove Mocha's global error handling so we can
+ // verify error is indeed uncaught by installing our own
+ // global error handler.
+ if (process.browser) {
+ mochaHandler = global.onerror
+ global.onerror = handleUncaughtException
+ }
+ else {
+ mochaHandler = process.listeners("uncaughtException").pop()
+ process.removeListener("uncaughtException", mochaHandler)
+ process.once("uncaughtException", handleUncaughtException)
+ }
+
+ var f = function f (cb) {
+ return maybe(cb, new Promise(function (resolve, reject) {
+ process.nextTick(function () {
+ return resolve("hi")
+ })
+ }))
+ }
+
+ f(function (err, result) {
+ throw new Error("yep")
+ })
+
+ function handleUncaughtException (err) {
+ // `err` is either an Error when running under Node, or a
+ // string if running under a browser.
+ var msg = err.message || err
+
+ assert(msg.match(/\byep\b/), "got expected error")
+
+ // Restore Mocha's global error handler.
+ if (process.browser) {
+ global.onerror = mochaHandler
+ }
+ else {
+ process.on("uncaughtException", mochaHandler)
+ }
+
+ done()
+
+ // Don't leak error to browser console
+ return true
+ }
+ })
+
+ it("should not let the callback be called more than once", function (done) {
+ var f = function f (cb) {
+ return maybe(cb, new Promise(function (resolve, reject) {
+ process.nextTick(function () {
+ resolve("foo")
+ })
+ }))
+ }
+
+ var called = 0
+ f(function (err, result) {
+ called++
+ assert(called <= 1, "called only once")
+ setTimeout(function () { done() }, 100)
+ return Promise.reject(new Error("bah"))
+ })
+ })
+})