From 3e73251fea6dcc7cad04fdc6d799e43e634a8f60 Mon Sep 17 00:00:00 2001 From: James Messinger Date: Mon, 14 Dec 2015 13:46:33 -0600 Subject: [PATCH] "release v2.0.0" --- README.md | 4 +- dist/ono.js | 96 +- dist/ono.js.map | 16 +- dist/ono.min.js | 6 +- dist/ono.min.js.map | 16 +- lib/index.js | 91 +- package.json | 44 +- tests/bower_components/chai/.bower.json | 8 +- tests/bower_components/chai/CONTRIBUTING.md | 17 +- tests/bower_components/chai/README.md | 2 +- tests/bower_components/chai/chai.js | 529 +++++- tests/bower_components/chai/package.json | 2 +- tests/bower_components/mocha/.bower.json | 8 +- tests/bower_components/mocha/HISTORY.md | 51 +- tests/bower_components/mocha/mocha.js | 1545 ++++------------- .../mocha/scripts/ensure-compatible-npm.sh | 3 +- tests/fixtures/helper.js | 9 + tests/specs/ono.spec.js | 69 +- 18 files changed, 1115 insertions(+), 1401 deletions(-) diff --git a/README.md b/README.md index 2edf783..7d62b1e 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ ono (Oh No!) Features -------------------------- * Formatted error messages, using Node's [`util.format()`](https://nodejs.org/api/util.html#util_util_format_format) or your own custom formatter -* Wrap and re-throw an error _without_ losing the original error's message and stack trace +* Wrap and re-throw an error _without_ losing the original error's message, stack trace, and properties * Add custom properties to your errors — great for error codes, support numbers, help URLs, etc. * Errors can be serialized as JSON, including all native and custom properties * [Tested](http://bigstickcarpet.github.io/ono/tests/index.html) in Node, IO.js, and all modern web browsers on Mac, Windows, Linux, iOS, and Android @@ -87,7 +87,7 @@ API ### `ono([err], [props], [message, ...])` Creates an [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object with the given properties. -* `err` - _(optional)_ An existing error object. This error's message and stack trace will be appended to the new error. +* `err` - _(optional)_ An existing error object. This error's message, stack trace, and properties will be appended to the new error. * `props` - _(optional)_ An object whose properties will be added to the new error. Properties can be anything, including objects and functions. diff --git a/dist/ono.js b/dist/ono.js index 2658805..0ba592c 100644 --- a/dist/ono.js +++ b/dist/ono.js @@ -1,6 +1,6 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ono = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o= 0) { + continue; + } + + try { + target[key] = source[key]; + } + catch (e) { + // This property is read-only, so it can't be copied + } } } - - error.toJSON = errorToJSON; } /** @@ -97,18 +137,13 @@ function extendError(error, stack, props) { */ function errorToJSON() { // jshint -W040 + var json = {}; - // All Errors have "name" and "message" - var json = { - name: this.name, - message: this.message - }; - - // Append any custom properties that were added + // Get all the properties of this error var keys = Object.keys(this); - // Also include any vendor-specific Error properties - keys = keys.concat(['description', 'number', 'fileName', 'lineNumber', 'columnNumber', 'stack']); + // Also include vendor-specific properties from the prototype + keys = keys.concat(vendorSpecificErrorProperties); for (var i = 0; i < keys.length; i++) { var key = keys[i]; @@ -179,7 +214,9 @@ function drainQueue() { currentQueue = queue; queue = []; while (++queueIndex < len) { - currentQueue[queueIndex].run(); + if (currentQueue) { + currentQueue[queueIndex].run(); + } } queueIndex = -1; len = queue.length; @@ -231,7 +268,6 @@ process.binding = function (name) { throw new Error('process.binding is not supported'); }; -// TODO(shtylman) process.cwd = function () { return '/' }; process.chdir = function (dir) { throw new Error('process.chdir is not supported'); diff --git a/dist/ono.js.map b/dist/ono.js.map index 53fe2e1..e84e65b 100644 --- a/dist/ono.js.map +++ b/dist/ono.js.map @@ -1,22 +1,22 @@ { "version": 3, "sources": [ - "../node_modules/simplifyify/node_modules/browserify/node_modules/browser-pack/_prelude.js", + "../node_modules/browser-pack/_prelude.js", "../lib/index.js", - "../node_modules/simplifyify/node_modules/browserify/node_modules/inherits/inherits_browser.js", - "../node_modules/simplifyify/node_modules/browserify/node_modules/process/browser.js", - "../node_modules/simplifyify/node_modules/browserify/node_modules/util/support/isBufferBrowser.js", - "../node_modules/simplifyify/node_modules/browserify/node_modules/util/util.js" + "../node_modules/inherits/inherits_browser.js", + "../node_modules/process/browser.js", + "../node_modules/util/support/isBufferBrowser.js", + "../node_modules/util/util.js" ], "names": [], - "mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACzHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACvBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC1FA;AACA;AACA;AACA;AACA;AACA;;;ACLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA", + "mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC5JA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACvBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC3FA;AACA;AACA;AACA;AACA;AACA;;;ACLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA", "file": "generated.js", "sourceRoot": "", "sourcesContent": [ "(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o= 0) {\n continue;\n }\n\n try {\n target[key] = source[key];\n }\n catch (e) {\n // This property is read-only, so it can't be copied\n }\n }\n }\n}\n\n/**\n * Custom JSON serializer for Error objects.\n * Returns all built-in error properties, as well as extended properties.\n *\n * @returns {object}\n */\nfunction errorToJSON() {\n // jshint -W040\n var json = {};\n\n // Get all the properties of this error\n var keys = Object.keys(this);\n\n // Also include vendor-specific properties from the prototype\n keys = keys.concat(vendorSpecificErrorProperties);\n\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n var value = this[key];\n if (value !== undefined) {\n json[key] = value;\n }\n }\n\n return json;\n}\n", "if (typeof Object.create === 'function') {\n // implementation from standard node.js 'util' module\n module.exports = function inherits(ctor, superCtor) {\n ctor.super_ = superCtor\n ctor.prototype = Object.create(superCtor.prototype, {\n constructor: {\n value: ctor,\n enumerable: false,\n writable: true,\n configurable: true\n }\n });\n };\n} else {\n // old school shim for old browsers\n module.exports = function inherits(ctor, superCtor) {\n ctor.super_ = superCtor\n var TempCtor = function () {}\n TempCtor.prototype = superCtor.prototype\n ctor.prototype = new TempCtor()\n ctor.prototype.constructor = ctor\n }\n}\n", - "// shim for using process in browser\n\nvar process = module.exports = {};\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = setTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n currentQueue[queueIndex].run();\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n clearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n setTimeout(drainQueue, 0);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\n// TODO(shtylman)\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n", + "// shim for using process in browser\n\nvar process = module.exports = {};\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = setTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n clearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n setTimeout(drainQueue, 0);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n", "module.exports = function isBuffer(arg) {\n return arg && typeof arg === 'object'\n && typeof arg.copy === 'function'\n && typeof arg.fill === 'function'\n && typeof arg.readUInt8 === 'function';\n}", "// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nvar formatRegExp = /%[sdj%]/g;\nexports.format = function(f) {\n if (!isString(f)) {\n var objects = [];\n for (var i = 0; i < arguments.length; i++) {\n objects.push(inspect(arguments[i]));\n }\n return objects.join(' ');\n }\n\n var i = 1;\n var args = arguments;\n var len = args.length;\n var str = String(f).replace(formatRegExp, function(x) {\n if (x === '%%') return '%';\n if (i >= len) return x;\n switch (x) {\n case '%s': return String(args[i++]);\n case '%d': return Number(args[i++]);\n case '%j':\n try {\n return JSON.stringify(args[i++]);\n } catch (_) {\n return '[Circular]';\n }\n default:\n return x;\n }\n });\n for (var x = args[i]; i < len; x = args[++i]) {\n if (isNull(x) || !isObject(x)) {\n str += ' ' + x;\n } else {\n str += ' ' + inspect(x);\n }\n }\n return str;\n};\n\n\n// Mark that a method should not be used.\n// Returns a modified function which warns once by default.\n// If --no-deprecation is set, then it is a no-op.\nexports.deprecate = function(fn, msg) {\n // Allow for deprecating things in the process of starting up.\n if (isUndefined(global.process)) {\n return function() {\n return exports.deprecate(fn, msg).apply(this, arguments);\n };\n }\n\n if (process.noDeprecation === true) {\n return fn;\n }\n\n var warned = false;\n function deprecated() {\n if (!warned) {\n if (process.throwDeprecation) {\n throw new Error(msg);\n } else if (process.traceDeprecation) {\n console.trace(msg);\n } else {\n console.error(msg);\n }\n warned = true;\n }\n return fn.apply(this, arguments);\n }\n\n return deprecated;\n};\n\n\nvar debugs = {};\nvar debugEnviron;\nexports.debuglog = function(set) {\n if (isUndefined(debugEnviron))\n debugEnviron = process.env.NODE_DEBUG || '';\n set = set.toUpperCase();\n if (!debugs[set]) {\n if (new RegExp('\\\\b' + set + '\\\\b', 'i').test(debugEnviron)) {\n var pid = process.pid;\n debugs[set] = function() {\n var msg = exports.format.apply(exports, arguments);\n console.error('%s %d: %s', set, pid, msg);\n };\n } else {\n debugs[set] = function() {};\n }\n }\n return debugs[set];\n};\n\n\n/**\n * Echos the value of a value. Trys to print the value out\n * in the best way possible given the different types.\n *\n * @param {Object} obj The object to print out.\n * @param {Object} opts Optional options object that alters the output.\n */\n/* legacy: obj, showHidden, depth, colors*/\nfunction inspect(obj, opts) {\n // default options\n var ctx = {\n seen: [],\n stylize: stylizeNoColor\n };\n // legacy...\n if (arguments.length >= 3) ctx.depth = arguments[2];\n if (arguments.length >= 4) ctx.colors = arguments[3];\n if (isBoolean(opts)) {\n // legacy...\n ctx.showHidden = opts;\n } else if (opts) {\n // got an \"options\" object\n exports._extend(ctx, opts);\n }\n // set default options\n if (isUndefined(ctx.showHidden)) ctx.showHidden = false;\n if (isUndefined(ctx.depth)) ctx.depth = 2;\n if (isUndefined(ctx.colors)) ctx.colors = false;\n if (isUndefined(ctx.customInspect)) ctx.customInspect = true;\n if (ctx.colors) ctx.stylize = stylizeWithColor;\n return formatValue(ctx, obj, ctx.depth);\n}\nexports.inspect = inspect;\n\n\n// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics\ninspect.colors = {\n 'bold' : [1, 22],\n 'italic' : [3, 23],\n 'underline' : [4, 24],\n 'inverse' : [7, 27],\n 'white' : [37, 39],\n 'grey' : [90, 39],\n 'black' : [30, 39],\n 'blue' : [34, 39],\n 'cyan' : [36, 39],\n 'green' : [32, 39],\n 'magenta' : [35, 39],\n 'red' : [31, 39],\n 'yellow' : [33, 39]\n};\n\n// Don't use 'blue' not visible on cmd.exe\ninspect.styles = {\n 'special': 'cyan',\n 'number': 'yellow',\n 'boolean': 'yellow',\n 'undefined': 'grey',\n 'null': 'bold',\n 'string': 'green',\n 'date': 'magenta',\n // \"name\": intentionally not styling\n 'regexp': 'red'\n};\n\n\nfunction stylizeWithColor(str, styleType) {\n var style = inspect.styles[styleType];\n\n if (style) {\n return '\\u001b[' + inspect.colors[style][0] + 'm' + str +\n '\\u001b[' + inspect.colors[style][1] + 'm';\n } else {\n return str;\n }\n}\n\n\nfunction stylizeNoColor(str, styleType) {\n return str;\n}\n\n\nfunction arrayToHash(array) {\n var hash = {};\n\n array.forEach(function(val, idx) {\n hash[val] = true;\n });\n\n return hash;\n}\n\n\nfunction formatValue(ctx, value, recurseTimes) {\n // Provide a hook for user-specified inspect functions.\n // Check that value is an object with an inspect function on it\n if (ctx.customInspect &&\n value &&\n isFunction(value.inspect) &&\n // Filter out the util module, it's inspect function is special\n value.inspect !== exports.inspect &&\n // Also filter out any prototype objects using the circular check.\n !(value.constructor && value.constructor.prototype === value)) {\n var ret = value.inspect(recurseTimes, ctx);\n if (!isString(ret)) {\n ret = formatValue(ctx, ret, recurseTimes);\n }\n return ret;\n }\n\n // Primitive types cannot have properties\n var primitive = formatPrimitive(ctx, value);\n if (primitive) {\n return primitive;\n }\n\n // Look up the keys of the object.\n var keys = Object.keys(value);\n var visibleKeys = arrayToHash(keys);\n\n if (ctx.showHidden) {\n keys = Object.getOwnPropertyNames(value);\n }\n\n // IE doesn't make error fields non-enumerable\n // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx\n if (isError(value)\n && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {\n return formatError(value);\n }\n\n // Some type of object without properties can be shortcutted.\n if (keys.length === 0) {\n if (isFunction(value)) {\n var name = value.name ? ': ' + value.name : '';\n return ctx.stylize('[Function' + name + ']', 'special');\n }\n if (isRegExp(value)) {\n return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');\n }\n if (isDate(value)) {\n return ctx.stylize(Date.prototype.toString.call(value), 'date');\n }\n if (isError(value)) {\n return formatError(value);\n }\n }\n\n var base = '', array = false, braces = ['{', '}'];\n\n // Make Array say that they are Array\n if (isArray(value)) {\n array = true;\n braces = ['[', ']'];\n }\n\n // Make functions say that they are functions\n if (isFunction(value)) {\n var n = value.name ? ': ' + value.name : '';\n base = ' [Function' + n + ']';\n }\n\n // Make RegExps say that they are RegExps\n if (isRegExp(value)) {\n base = ' ' + RegExp.prototype.toString.call(value);\n }\n\n // Make dates with properties first say the date\n if (isDate(value)) {\n base = ' ' + Date.prototype.toUTCString.call(value);\n }\n\n // Make error with message first say the error\n if (isError(value)) {\n base = ' ' + formatError(value);\n }\n\n if (keys.length === 0 && (!array || value.length == 0)) {\n return braces[0] + base + braces[1];\n }\n\n if (recurseTimes < 0) {\n if (isRegExp(value)) {\n return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');\n } else {\n return ctx.stylize('[Object]', 'special');\n }\n }\n\n ctx.seen.push(value);\n\n var output;\n if (array) {\n output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);\n } else {\n output = keys.map(function(key) {\n return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);\n });\n }\n\n ctx.seen.pop();\n\n return reduceToSingleString(output, base, braces);\n}\n\n\nfunction formatPrimitive(ctx, value) {\n if (isUndefined(value))\n return ctx.stylize('undefined', 'undefined');\n if (isString(value)) {\n var simple = '\\'' + JSON.stringify(value).replace(/^\"|\"$/g, '')\n .replace(/'/g, \"\\\\'\")\n .replace(/\\\\\"/g, '\"') + '\\'';\n return ctx.stylize(simple, 'string');\n }\n if (isNumber(value))\n return ctx.stylize('' + value, 'number');\n if (isBoolean(value))\n return ctx.stylize('' + value, 'boolean');\n // For some reason typeof null is \"object\", so special case here.\n if (isNull(value))\n return ctx.stylize('null', 'null');\n}\n\n\nfunction formatError(value) {\n return '[' + Error.prototype.toString.call(value) + ']';\n}\n\n\nfunction formatArray(ctx, value, recurseTimes, visibleKeys, keys) {\n var output = [];\n for (var i = 0, l = value.length; i < l; ++i) {\n if (hasOwnProperty(value, String(i))) {\n output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,\n String(i), true));\n } else {\n output.push('');\n }\n }\n keys.forEach(function(key) {\n if (!key.match(/^\\d+$/)) {\n output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,\n key, true));\n }\n });\n return output;\n}\n\n\nfunction formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {\n var name, str, desc;\n desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };\n if (desc.get) {\n if (desc.set) {\n str = ctx.stylize('[Getter/Setter]', 'special');\n } else {\n str = ctx.stylize('[Getter]', 'special');\n }\n } else {\n if (desc.set) {\n str = ctx.stylize('[Setter]', 'special');\n }\n }\n if (!hasOwnProperty(visibleKeys, key)) {\n name = '[' + key + ']';\n }\n if (!str) {\n if (ctx.seen.indexOf(desc.value) < 0) {\n if (isNull(recurseTimes)) {\n str = formatValue(ctx, desc.value, null);\n } else {\n str = formatValue(ctx, desc.value, recurseTimes - 1);\n }\n if (str.indexOf('\\n') > -1) {\n if (array) {\n str = str.split('\\n').map(function(line) {\n return ' ' + line;\n }).join('\\n').substr(2);\n } else {\n str = '\\n' + str.split('\\n').map(function(line) {\n return ' ' + line;\n }).join('\\n');\n }\n }\n } else {\n str = ctx.stylize('[Circular]', 'special');\n }\n }\n if (isUndefined(name)) {\n if (array && key.match(/^\\d+$/)) {\n return str;\n }\n name = JSON.stringify('' + key);\n if (name.match(/^\"([a-zA-Z_][a-zA-Z_0-9]*)\"$/)) {\n name = name.substr(1, name.length - 2);\n name = ctx.stylize(name, 'name');\n } else {\n name = name.replace(/'/g, \"\\\\'\")\n .replace(/\\\\\"/g, '\"')\n .replace(/(^\"|\"$)/g, \"'\");\n name = ctx.stylize(name, 'string');\n }\n }\n\n return name + ': ' + str;\n}\n\n\nfunction reduceToSingleString(output, base, braces) {\n var numLinesEst = 0;\n var length = output.reduce(function(prev, cur) {\n numLinesEst++;\n if (cur.indexOf('\\n') >= 0) numLinesEst++;\n return prev + cur.replace(/\\u001b\\[\\d\\d?m/g, '').length + 1;\n }, 0);\n\n if (length > 60) {\n return braces[0] +\n (base === '' ? '' : base + '\\n ') +\n ' ' +\n output.join(',\\n ') +\n ' ' +\n braces[1];\n }\n\n return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];\n}\n\n\n// NOTE: These type checking functions intentionally don't use `instanceof`\n// because it is fragile and can be easily faked with `Object.create()`.\nfunction isArray(ar) {\n return Array.isArray(ar);\n}\nexports.isArray = isArray;\n\nfunction isBoolean(arg) {\n return typeof arg === 'boolean';\n}\nexports.isBoolean = isBoolean;\n\nfunction isNull(arg) {\n return arg === null;\n}\nexports.isNull = isNull;\n\nfunction isNullOrUndefined(arg) {\n return arg == null;\n}\nexports.isNullOrUndefined = isNullOrUndefined;\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\nexports.isNumber = isNumber;\n\nfunction isString(arg) {\n return typeof arg === 'string';\n}\nexports.isString = isString;\n\nfunction isSymbol(arg) {\n return typeof arg === 'symbol';\n}\nexports.isSymbol = isSymbol;\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\nexports.isUndefined = isUndefined;\n\nfunction isRegExp(re) {\n return isObject(re) && objectToString(re) === '[object RegExp]';\n}\nexports.isRegExp = isRegExp;\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\nexports.isObject = isObject;\n\nfunction isDate(d) {\n return isObject(d) && objectToString(d) === '[object Date]';\n}\nexports.isDate = isDate;\n\nfunction isError(e) {\n return isObject(e) &&\n (objectToString(e) === '[object Error]' || e instanceof Error);\n}\nexports.isError = isError;\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\nexports.isFunction = isFunction;\n\nfunction isPrimitive(arg) {\n return arg === null ||\n typeof arg === 'boolean' ||\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'symbol' || // ES6 symbol\n typeof arg === 'undefined';\n}\nexports.isPrimitive = isPrimitive;\n\nexports.isBuffer = require('./support/isBuffer');\n\nfunction objectToString(o) {\n return Object.prototype.toString.call(o);\n}\n\n\nfunction pad(n) {\n return n < 10 ? '0' + n.toString(10) : n.toString(10);\n}\n\n\nvar months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',\n 'Oct', 'Nov', 'Dec'];\n\n// 26 Feb 16:19:34\nfunction timestamp() {\n var d = new Date();\n var time = [pad(d.getHours()),\n pad(d.getMinutes()),\n pad(d.getSeconds())].join(':');\n return [d.getDate(), months[d.getMonth()], time].join(' ');\n}\n\n\n// log is just a thin wrapper to console.log that prepends a timestamp\nexports.log = function() {\n console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));\n};\n\n\n/**\n * Inherit the prototype methods from one constructor into another.\n *\n * The Function.prototype.inherits from lang.js rewritten as a standalone\n * function (not on Function.prototype). NOTE: If this file is to be loaded\n * during bootstrapping this function needs to be rewritten using some native\n * functions as prototype setup using normal JavaScript does not work as\n * expected during bootstrapping (see mirror.js in r114903).\n *\n * @param {function} ctor Constructor function which needs to inherit the\n * prototype.\n * @param {function} superCtor Constructor function to inherit prototype from.\n */\nexports.inherits = require('inherits');\n\nexports._extend = function(origin, add) {\n // Don't do anything if add isn't an object\n if (!add || !isObject(add)) return origin;\n\n var keys = Object.keys(add);\n var i = keys.length;\n while (i--) {\n origin[keys[i]] = add[keys[i]];\n }\n return origin;\n};\n\nfunction hasOwnProperty(obj, prop) {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n" ] diff --git a/dist/ono.min.js b/dist/ono.min.js index ade6735..c32e8ea 100644 --- a/dist/ono.min.js +++ b/dist/ono.min.js @@ -1,17 +1,17 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ono = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o=0))try{e[c]=r[c]}catch(a){}}}function errorToJSON(){var e={},r=Object.keys(this);r=r.concat(vendorSpecificErrorProperties);for(var t=0;t1)for(var r=1;r1)for(var r=1;r= 0) {\n continue;\n }\n\n try {\n target[key] = source[key];\n }\n catch (e) {\n // This property is read-only, so it can't be copied\n }\n }\n }\n}\n\n/**\n * Custom JSON serializer for Error objects.\n * Returns all built-in error properties, as well as extended properties.\n *\n * @returns {object}\n */\nfunction errorToJSON() {\n // jshint -W040\n var json = {};\n\n // Get all the properties of this error\n var keys = Object.keys(this);\n\n // Also include vendor-specific properties from the prototype\n keys = keys.concat(vendorSpecificErrorProperties);\n\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n var value = this[key];\n if (value !== undefined) {\n json[key] = value;\n }\n }\n\n return json;\n}\n", "if (typeof Object.create === 'function') {\n // implementation from standard node.js 'util' module\n module.exports = function inherits(ctor, superCtor) {\n ctor.super_ = superCtor\n ctor.prototype = Object.create(superCtor.prototype, {\n constructor: {\n value: ctor,\n enumerable: false,\n writable: true,\n configurable: true\n }\n });\n };\n} else {\n // old school shim for old browsers\n module.exports = function inherits(ctor, superCtor) {\n ctor.super_ = superCtor\n var TempCtor = function () {}\n TempCtor.prototype = superCtor.prototype\n ctor.prototype = new TempCtor()\n ctor.prototype.constructor = ctor\n }\n}\n", - "// shim for using process in browser\n\nvar process = module.exports = {};\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = setTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n currentQueue[queueIndex].run();\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n clearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n setTimeout(drainQueue, 0);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\n// TODO(shtylman)\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n", + "// shim for using process in browser\n\nvar process = module.exports = {};\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = setTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n clearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n setTimeout(drainQueue, 0);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n", "module.exports = function isBuffer(arg) {\n return arg && typeof arg === 'object'\n && typeof arg.copy === 'function'\n && typeof arg.fill === 'function'\n && typeof arg.readUInt8 === 'function';\n}", "// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nvar formatRegExp = /%[sdj%]/g;\nexports.format = function(f) {\n if (!isString(f)) {\n var objects = [];\n for (var i = 0; i < arguments.length; i++) {\n objects.push(inspect(arguments[i]));\n }\n return objects.join(' ');\n }\n\n var i = 1;\n var args = arguments;\n var len = args.length;\n var str = String(f).replace(formatRegExp, function(x) {\n if (x === '%%') return '%';\n if (i >= len) return x;\n switch (x) {\n case '%s': return String(args[i++]);\n case '%d': return Number(args[i++]);\n case '%j':\n try {\n return JSON.stringify(args[i++]);\n } catch (_) {\n return '[Circular]';\n }\n default:\n return x;\n }\n });\n for (var x = args[i]; i < len; x = args[++i]) {\n if (isNull(x) || !isObject(x)) {\n str += ' ' + x;\n } else {\n str += ' ' + inspect(x);\n }\n }\n return str;\n};\n\n\n// Mark that a method should not be used.\n// Returns a modified function which warns once by default.\n// If --no-deprecation is set, then it is a no-op.\nexports.deprecate = function(fn, msg) {\n // Allow for deprecating things in the process of starting up.\n if (isUndefined(global.process)) {\n return function() {\n return exports.deprecate(fn, msg).apply(this, arguments);\n };\n }\n\n if (process.noDeprecation === true) {\n return fn;\n }\n\n var warned = false;\n function deprecated() {\n if (!warned) {\n if (process.throwDeprecation) {\n throw new Error(msg);\n } else if (process.traceDeprecation) {\n console.trace(msg);\n } else {\n console.error(msg);\n }\n warned = true;\n }\n return fn.apply(this, arguments);\n }\n\n return deprecated;\n};\n\n\nvar debugs = {};\nvar debugEnviron;\nexports.debuglog = function(set) {\n if (isUndefined(debugEnviron))\n debugEnviron = process.env.NODE_DEBUG || '';\n set = set.toUpperCase();\n if (!debugs[set]) {\n if (new RegExp('\\\\b' + set + '\\\\b', 'i').test(debugEnviron)) {\n var pid = process.pid;\n debugs[set] = function() {\n var msg = exports.format.apply(exports, arguments);\n console.error('%s %d: %s', set, pid, msg);\n };\n } else {\n debugs[set] = function() {};\n }\n }\n return debugs[set];\n};\n\n\n/**\n * Echos the value of a value. Trys to print the value out\n * in the best way possible given the different types.\n *\n * @param {Object} obj The object to print out.\n * @param {Object} opts Optional options object that alters the output.\n */\n/* legacy: obj, showHidden, depth, colors*/\nfunction inspect(obj, opts) {\n // default options\n var ctx = {\n seen: [],\n stylize: stylizeNoColor\n };\n // legacy...\n if (arguments.length >= 3) ctx.depth = arguments[2];\n if (arguments.length >= 4) ctx.colors = arguments[3];\n if (isBoolean(opts)) {\n // legacy...\n ctx.showHidden = opts;\n } else if (opts) {\n // got an \"options\" object\n exports._extend(ctx, opts);\n }\n // set default options\n if (isUndefined(ctx.showHidden)) ctx.showHidden = false;\n if (isUndefined(ctx.depth)) ctx.depth = 2;\n if (isUndefined(ctx.colors)) ctx.colors = false;\n if (isUndefined(ctx.customInspect)) ctx.customInspect = true;\n if (ctx.colors) ctx.stylize = stylizeWithColor;\n return formatValue(ctx, obj, ctx.depth);\n}\nexports.inspect = inspect;\n\n\n// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics\ninspect.colors = {\n 'bold' : [1, 22],\n 'italic' : [3, 23],\n 'underline' : [4, 24],\n 'inverse' : [7, 27],\n 'white' : [37, 39],\n 'grey' : [90, 39],\n 'black' : [30, 39],\n 'blue' : [34, 39],\n 'cyan' : [36, 39],\n 'green' : [32, 39],\n 'magenta' : [35, 39],\n 'red' : [31, 39],\n 'yellow' : [33, 39]\n};\n\n// Don't use 'blue' not visible on cmd.exe\ninspect.styles = {\n 'special': 'cyan',\n 'number': 'yellow',\n 'boolean': 'yellow',\n 'undefined': 'grey',\n 'null': 'bold',\n 'string': 'green',\n 'date': 'magenta',\n // \"name\": intentionally not styling\n 'regexp': 'red'\n};\n\n\nfunction stylizeWithColor(str, styleType) {\n var style = inspect.styles[styleType];\n\n if (style) {\n return '\\u001b[' + inspect.colors[style][0] + 'm' + str +\n '\\u001b[' + inspect.colors[style][1] + 'm';\n } else {\n return str;\n }\n}\n\n\nfunction stylizeNoColor(str, styleType) {\n return str;\n}\n\n\nfunction arrayToHash(array) {\n var hash = {};\n\n array.forEach(function(val, idx) {\n hash[val] = true;\n });\n\n return hash;\n}\n\n\nfunction formatValue(ctx, value, recurseTimes) {\n // Provide a hook for user-specified inspect functions.\n // Check that value is an object with an inspect function on it\n if (ctx.customInspect &&\n value &&\n isFunction(value.inspect) &&\n // Filter out the util module, it's inspect function is special\n value.inspect !== exports.inspect &&\n // Also filter out any prototype objects using the circular check.\n !(value.constructor && value.constructor.prototype === value)) {\n var ret = value.inspect(recurseTimes, ctx);\n if (!isString(ret)) {\n ret = formatValue(ctx, ret, recurseTimes);\n }\n return ret;\n }\n\n // Primitive types cannot have properties\n var primitive = formatPrimitive(ctx, value);\n if (primitive) {\n return primitive;\n }\n\n // Look up the keys of the object.\n var keys = Object.keys(value);\n var visibleKeys = arrayToHash(keys);\n\n if (ctx.showHidden) {\n keys = Object.getOwnPropertyNames(value);\n }\n\n // IE doesn't make error fields non-enumerable\n // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx\n if (isError(value)\n && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {\n return formatError(value);\n }\n\n // Some type of object without properties can be shortcutted.\n if (keys.length === 0) {\n if (isFunction(value)) {\n var name = value.name ? ': ' + value.name : '';\n return ctx.stylize('[Function' + name + ']', 'special');\n }\n if (isRegExp(value)) {\n return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');\n }\n if (isDate(value)) {\n return ctx.stylize(Date.prototype.toString.call(value), 'date');\n }\n if (isError(value)) {\n return formatError(value);\n }\n }\n\n var base = '', array = false, braces = ['{', '}'];\n\n // Make Array say that they are Array\n if (isArray(value)) {\n array = true;\n braces = ['[', ']'];\n }\n\n // Make functions say that they are functions\n if (isFunction(value)) {\n var n = value.name ? ': ' + value.name : '';\n base = ' [Function' + n + ']';\n }\n\n // Make RegExps say that they are RegExps\n if (isRegExp(value)) {\n base = ' ' + RegExp.prototype.toString.call(value);\n }\n\n // Make dates with properties first say the date\n if (isDate(value)) {\n base = ' ' + Date.prototype.toUTCString.call(value);\n }\n\n // Make error with message first say the error\n if (isError(value)) {\n base = ' ' + formatError(value);\n }\n\n if (keys.length === 0 && (!array || value.length == 0)) {\n return braces[0] + base + braces[1];\n }\n\n if (recurseTimes < 0) {\n if (isRegExp(value)) {\n return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');\n } else {\n return ctx.stylize('[Object]', 'special');\n }\n }\n\n ctx.seen.push(value);\n\n var output;\n if (array) {\n output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);\n } else {\n output = keys.map(function(key) {\n return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);\n });\n }\n\n ctx.seen.pop();\n\n return reduceToSingleString(output, base, braces);\n}\n\n\nfunction formatPrimitive(ctx, value) {\n if (isUndefined(value))\n return ctx.stylize('undefined', 'undefined');\n if (isString(value)) {\n var simple = '\\'' + JSON.stringify(value).replace(/^\"|\"$/g, '')\n .replace(/'/g, \"\\\\'\")\n .replace(/\\\\\"/g, '\"') + '\\'';\n return ctx.stylize(simple, 'string');\n }\n if (isNumber(value))\n return ctx.stylize('' + value, 'number');\n if (isBoolean(value))\n return ctx.stylize('' + value, 'boolean');\n // For some reason typeof null is \"object\", so special case here.\n if (isNull(value))\n return ctx.stylize('null', 'null');\n}\n\n\nfunction formatError(value) {\n return '[' + Error.prototype.toString.call(value) + ']';\n}\n\n\nfunction formatArray(ctx, value, recurseTimes, visibleKeys, keys) {\n var output = [];\n for (var i = 0, l = value.length; i < l; ++i) {\n if (hasOwnProperty(value, String(i))) {\n output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,\n String(i), true));\n } else {\n output.push('');\n }\n }\n keys.forEach(function(key) {\n if (!key.match(/^\\d+$/)) {\n output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,\n key, true));\n }\n });\n return output;\n}\n\n\nfunction formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {\n var name, str, desc;\n desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };\n if (desc.get) {\n if (desc.set) {\n str = ctx.stylize('[Getter/Setter]', 'special');\n } else {\n str = ctx.stylize('[Getter]', 'special');\n }\n } else {\n if (desc.set) {\n str = ctx.stylize('[Setter]', 'special');\n }\n }\n if (!hasOwnProperty(visibleKeys, key)) {\n name = '[' + key + ']';\n }\n if (!str) {\n if (ctx.seen.indexOf(desc.value) < 0) {\n if (isNull(recurseTimes)) {\n str = formatValue(ctx, desc.value, null);\n } else {\n str = formatValue(ctx, desc.value, recurseTimes - 1);\n }\n if (str.indexOf('\\n') > -1) {\n if (array) {\n str = str.split('\\n').map(function(line) {\n return ' ' + line;\n }).join('\\n').substr(2);\n } else {\n str = '\\n' + str.split('\\n').map(function(line) {\n return ' ' + line;\n }).join('\\n');\n }\n }\n } else {\n str = ctx.stylize('[Circular]', 'special');\n }\n }\n if (isUndefined(name)) {\n if (array && key.match(/^\\d+$/)) {\n return str;\n }\n name = JSON.stringify('' + key);\n if (name.match(/^\"([a-zA-Z_][a-zA-Z_0-9]*)\"$/)) {\n name = name.substr(1, name.length - 2);\n name = ctx.stylize(name, 'name');\n } else {\n name = name.replace(/'/g, \"\\\\'\")\n .replace(/\\\\\"/g, '\"')\n .replace(/(^\"|\"$)/g, \"'\");\n name = ctx.stylize(name, 'string');\n }\n }\n\n return name + ': ' + str;\n}\n\n\nfunction reduceToSingleString(output, base, braces) {\n var numLinesEst = 0;\n var length = output.reduce(function(prev, cur) {\n numLinesEst++;\n if (cur.indexOf('\\n') >= 0) numLinesEst++;\n return prev + cur.replace(/\\u001b\\[\\d\\d?m/g, '').length + 1;\n }, 0);\n\n if (length > 60) {\n return braces[0] +\n (base === '' ? '' : base + '\\n ') +\n ' ' +\n output.join(',\\n ') +\n ' ' +\n braces[1];\n }\n\n return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];\n}\n\n\n// NOTE: These type checking functions intentionally don't use `instanceof`\n// because it is fragile and can be easily faked with `Object.create()`.\nfunction isArray(ar) {\n return Array.isArray(ar);\n}\nexports.isArray = isArray;\n\nfunction isBoolean(arg) {\n return typeof arg === 'boolean';\n}\nexports.isBoolean = isBoolean;\n\nfunction isNull(arg) {\n return arg === null;\n}\nexports.isNull = isNull;\n\nfunction isNullOrUndefined(arg) {\n return arg == null;\n}\nexports.isNullOrUndefined = isNullOrUndefined;\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\nexports.isNumber = isNumber;\n\nfunction isString(arg) {\n return typeof arg === 'string';\n}\nexports.isString = isString;\n\nfunction isSymbol(arg) {\n return typeof arg === 'symbol';\n}\nexports.isSymbol = isSymbol;\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\nexports.isUndefined = isUndefined;\n\nfunction isRegExp(re) {\n return isObject(re) && objectToString(re) === '[object RegExp]';\n}\nexports.isRegExp = isRegExp;\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\nexports.isObject = isObject;\n\nfunction isDate(d) {\n return isObject(d) && objectToString(d) === '[object Date]';\n}\nexports.isDate = isDate;\n\nfunction isError(e) {\n return isObject(e) &&\n (objectToString(e) === '[object Error]' || e instanceof Error);\n}\nexports.isError = isError;\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\nexports.isFunction = isFunction;\n\nfunction isPrimitive(arg) {\n return arg === null ||\n typeof arg === 'boolean' ||\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'symbol' || // ES6 symbol\n typeof arg === 'undefined';\n}\nexports.isPrimitive = isPrimitive;\n\nexports.isBuffer = require('./support/isBuffer');\n\nfunction objectToString(o) {\n return Object.prototype.toString.call(o);\n}\n\n\nfunction pad(n) {\n return n < 10 ? '0' + n.toString(10) : n.toString(10);\n}\n\n\nvar months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',\n 'Oct', 'Nov', 'Dec'];\n\n// 26 Feb 16:19:34\nfunction timestamp() {\n var d = new Date();\n var time = [pad(d.getHours()),\n pad(d.getMinutes()),\n pad(d.getSeconds())].join(':');\n return [d.getDate(), months[d.getMonth()], time].join(' ');\n}\n\n\n// log is just a thin wrapper to console.log that prepends a timestamp\nexports.log = function() {\n console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));\n};\n\n\n/**\n * Inherit the prototype methods from one constructor into another.\n *\n * The Function.prototype.inherits from lang.js rewritten as a standalone\n * function (not on Function.prototype). NOTE: If this file is to be loaded\n * during bootstrapping this function needs to be rewritten using some native\n * functions as prototype setup using normal JavaScript does not work as\n * expected during bootstrapping (see mirror.js in r114903).\n *\n * @param {function} ctor Constructor function which needs to inherit the\n * prototype.\n * @param {function} superCtor Constructor function to inherit prototype from.\n */\nexports.inherits = require('inherits');\n\nexports._extend = function(origin, add) {\n // Don't do anything if add isn't an object\n if (!add || !isObject(add)) return origin;\n\n var keys = Object.keys(add);\n var i = keys.length;\n while (i--) {\n origin[keys[i]] = add[keys[i]];\n }\n return origin;\n};\n\nfunction hasOwnProperty(obj, prop) {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n" ] diff --git a/lib/index.js b/lib/index.js index 8c91e4e..1332f89 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,5 +1,5 @@ /**! - * Ono v1.0.22 + * Ono v2.0.0 * * @link https://github.com/BigstickCarpet/ono * @license MIT @@ -7,7 +7,11 @@ 'use strict'; var util = require('util'), - slice = Array.prototype.slice; + slice = Array.prototype.slice, + vendorSpecificErrorProperties = [ + 'name', 'message', 'description', 'number', 'fileName', 'lineNumber', 'columnNumber', + 'sourceURL', 'line', 'column', 'stack' + ]; module.exports = create(Error); module.exports.error = create(Error); @@ -54,38 +58,74 @@ function create(Klass) { } if (err) { - // The inner-error's message and stack will be added to the new error + // The inner-error's message will be added to the new message formattedMessage += (formattedMessage ? ' \n' : '') + err.message; - stack = err.stack; } - var error = new Klass(formattedMessage); - extendError(error, stack, props); - return error; + // Create the new error + // NOTE: DON'T move this to a separate function! We don't want to pollute the stack trace + var newError = new Klass(formattedMessage); + + // Extend the new error with the additional properties + extendError(newError, err); // Copy properties of the original error + extendToJSON(newError); // Replace the original toJSON method + extend(newError, props); // Copy custom properties, possibly including a custom toJSON method + + return newError; }; } /** - * Extends the given Error object with the given values + * Extends the targetError with the properties of the source error. * - * @param {Error} error - The error object to extend - * @param {?string} stack - The stack trace from the original error - * @param {?object} props - Properties to add to the error object + * @param {Error} targetError - The error object to extend + * @param {?Error} sourceError - The source error object, if any */ -function extendError(error, stack, props) { - if (stack) { - error.stack += ' \n\n' + stack; +function extendError(targetError, sourceError) { + if (sourceError) { + targetError.stack += ' \n\n' + sourceError.stack; + extend(targetError, sourceError, true); } +} + +/** + * JavaScript engines differ in how errors are serialized to JSON - especially when it comes + * to custom error properties and stack traces. So we add our own toJSON method that ALWAYS + * outputs every property of the error. + */ +function extendToJSON(error) { + error.toJSON = errorToJSON; + + // Also add an inspect() method, for compatibility with Node.js' `util.inspect()` method + error.inspect = errorToJSON; +} - if (props && typeof(props) === 'object') { - var keys = Object.keys(props); +/** + * Extends the target object with the properties of the source object. + * + * @param {object} target - The object to extend + * @param {?source} source - The object whose properties are copied + * @param {boolean} omitVendorSpecificProperties - Skip vendor-specific Error properties + */ +function extend(target, source, omitVendorSpecificProperties) { + if (source && typeof(source) === 'object') { + var keys = Object.keys(source); for (var i = 0; i < keys.length; i++) { var key = keys[i]; - error[key] = props[key]; + + // Don't bother trying to copy read-only vendor-specific Error properties + if (omitVendorSpecificProperties && vendorSpecificErrorProperties.indexOf(key) >= 0) { + continue; + } + + try { + target[key] = source[key]; + } + catch (e) { + // This property is read-only, so it can't be copied + } } } - - error.toJSON = errorToJSON; } /** @@ -96,18 +136,13 @@ function extendError(error, stack, props) { */ function errorToJSON() { // jshint -W040 + var json = {}; - // All Errors have "name" and "message" - var json = { - name: this.name, - message: this.message - }; - - // Append any custom properties that were added + // Get all the properties of this error var keys = Object.keys(this); - // Also include any vendor-specific Error properties - keys = keys.concat(['description', 'number', 'fileName', 'lineNumber', 'columnNumber', 'stack']); + // Also include vendor-specific properties from the prototype + keys = keys.concat(vendorSpecificErrorProperties); for (var i = 0; i < keys.length; i++) { var key = keys[i]; diff --git a/package.json b/package.json index 4ff62b5..d8751f5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ono", - "version": "1.0.22", + "version": "2.0.0", "description": "Throw better errors.", "keywords": [ "throw", @@ -28,6 +28,7 @@ "istanbul": "istanbul cover _mocha --dir coverage/node -- --bail --recursive tests/fixtures tests/specs", "karma": "karma start --single-run", "test": "npm run browserify -- --test && npm run istanbul && npm run karma", + "www": "npm run browserify && http-server -o -c-1", "upgrade": "ncu --upgradeAll && npm update && bower update", "bump": "bump --prompt --grep lib/index.js dist/* --tag --push --all", "release": "npm run upgrade && npm test && npm run bump && npm publish" @@ -37,29 +38,30 @@ "url": "https://github.com/bigstickcarpet/ono.git" }, "devDependencies": { - "simplifyify": "^1.4.1", - "bower": "^1.5.2", - "karma": "^0.13.9", - "karma-chrome-launcher": "^0.2.0", - "karma-cli": "0.1.0", - "karma-coverage": "^0.5.1", - "karma-firefox-launcher": "^0.1.6", + "bower": "^1.7.1", + "chai": "^3.4.1", + "coveralls": "^2.11.6", + "http-server": "^0.8.5", + "istanbul": "^0.4.1", + "jscs": "^2.7.0", + "jshint": "^2.9.1-rc1", + "karma": "^0.13.15", + "karma-chrome-launcher": "^0.2.2", + "karma-cli": "0.1.1", + "karma-coverage": "^0.5.3", + "karma-firefox-launcher": "^0.1.7", "karma-ie-launcher": "^0.2.0", - "karma-mocha": "^0.2.0", - "karma-mocha-reporter": "^1.1.1", + "karma-mocha": "^0.2.1", + "karma-mocha-reporter": "^1.1.3", "karma-phantomjs-launcher": "^0.2.1", "karma-safari-launcher": "^0.1.1", - "karma-sauce-launcher": "^0.2.14", - "istanbul": "^0.3.19", - "coveralls": "^2.11.4", - "mocha": "^2.3.0", - "chai": "^3.2.0", - "sinon": "^1.16.1", - "jscs": "^2.1.1", - "jshint": "^2.8.0", - "npm-check-updates": "^2.2.0", - "version-bump-prompt": "^1.5.1", - "karma-sinon": "^1.0.4" + "karma-sauce-launcher": "^0.3.0", + "karma-sinon": "^1.0.4", + "mocha": "^2.3.4", + "npm-check-updates": "^2.5.4", + "simplifyify": "^1.5.0", + "sinon": "^1.17.2", + "version-bump-prompt": "^1.5.2" }, "dependencies": {} } \ No newline at end of file diff --git a/tests/bower_components/chai/.bower.json b/tests/bower_components/chai/.bower.json index 7f9242b..149263c 100644 --- a/tests/bower_components/chai/.bower.json +++ b/tests/bower_components/chai/.bower.json @@ -24,12 +24,12 @@ "dependencies": {}, "devDependencies": {}, "homepage": "https://github.com/chaijs/chai", - "version": "3.2.0", - "_release": "3.2.0", + "version": "3.4.2", + "_release": "3.4.2", "_resolution": { "type": "version", - "tag": "3.2.0", - "commit": "4e18d2a49394f21f49eaea97f556d6a17ecbcc7e" + "tag": "3.4.2", + "commit": "5fc5114a2420c4a6903e15febbc232a51e8dfb2a" }, "_source": "git://github.com/chaijs/chai.git", "_target": "*", diff --git a/tests/bower_components/chai/CONTRIBUTING.md b/tests/bower_components/chai/CONTRIBUTING.md index 1f6ab84..ba01938 100644 --- a/tests/bower_components/chai/CONTRIBUTING.md +++ b/tests/bower_components/chai/CONTRIBUTING.md @@ -121,19 +121,30 @@ git checkout -b 4. Commit your changes in logical chunks. Use Git's [interactive rebase](https://help.github.com/articles/interactive-rebase) feature to tidy up your commits before making them public. -5. Locally merge (or rebase) the upstream development branch into your topic branch: +5. Run you code to make sure it works. + +```bash +npm i +rm chai.js +make chai.js +npm test +# when finished running tests... +git checkout chai.js +``` + +6. Locally merge (or rebase) the upstream development branch into your topic branch: ```bash git pull [--rebase] upstream ``` -6. Push your topic branch up to your fork: +7. Push your topic branch up to your fork: ```bash git push origin ``` -7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) with a clear title and description. +8. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) with a clear title and description. **IMPORTANT**: By submitting a patch, you agree to allow the project owner to license your work under the same license as that used by the project. diff --git a/tests/bower_components/chai/README.md b/tests/bower_components/chai/README.md index 7e5c272..b3eb178 100644 --- a/tests/bower_components/chai/README.md +++ b/tests/bower_components/chai/README.md @@ -49,7 +49,7 @@ list of contributors. ### Core Contributors -Feel free to reach out to any of the core-contributors with you questions or +Feel free to reach out to any of the core contributors with your questions or concerns. We will do our best to respond in a timely manner. [![Jake Luer](https://avatars3.githubusercontent.com/u/58988?v=3&s=50)](https://github.com/logicalparadox) diff --git a/tests/bower_components/chai/chai.js b/tests/bower_components/chai/chai.js index b7bcdb5..c467073 100644 --- a/tests/bower_components/chai/chai.js +++ b/tests/bower_components/chai/chai.js @@ -15,7 +15,7 @@ var used = [] * Chai version */ -exports.version = '3.2.0'; +exports.version = '3.4.2'; /*! * Assertion Error @@ -96,7 +96,7 @@ exports.use(should); var assert = require('./chai/interface/assert'); exports.use(assert); -},{"./chai/assertion":3,"./chai/config":4,"./chai/core/assertions":5,"./chai/interface/assert":6,"./chai/interface/expect":7,"./chai/interface/should":8,"./chai/utils":21,"assertion-error":29}],3:[function(require,module,exports){ +},{"./chai/assertion":3,"./chai/config":4,"./chai/core/assertions":5,"./chai/interface/assert":6,"./chai/interface/expect":7,"./chai/interface/should":8,"./chai/utils":22,"assertion-error":30}],3:[function(require,module,exports){ /*! * chai * http://chaijs.com @@ -187,8 +187,8 @@ module.exports = function (_chai, util) { * * @name assert * @param {Philosophical} expression to be tested - * @param {String or Function} message or function that returns message to display if expression fails - * @param {String or Function} negatedMessage or function that returns negatedMessage to display if negated expression fails + * @param {String|Function} message or function that returns message to display if expression fails + * @param {String|Function} negatedMessage or function that returns negatedMessage to display if negated expression fails * @param {Mixed} expected value (remember to check for negation) * @param {Mixed} actual (optional) will default to `this.obj` * @param {Boolean} showDiff (optional) when set to `true`, assert will display a diff in addition to the message if expression fails @@ -324,6 +324,7 @@ module.exports = function (chai, _) { * - same * * @name language chains + * @namespace BDD * @api public */ @@ -347,6 +348,7 @@ module.exports = function (chai, _) { * .and.not.equal('bar'); * * @name not + * @namespace BDD * @api public */ @@ -371,6 +373,7 @@ module.exports = function (chai, _) { * expect(deepCss).to.have.deep.property('\\.link.\\[target\\]', 42); * * @name deep + * @namespace BDD * @api public */ @@ -387,6 +390,7 @@ module.exports = function (chai, _) { * expect(foo).to.have.any.keys('bar', 'baz'); * * @name any + * @namespace BDD * @api public */ @@ -405,6 +409,7 @@ module.exports = function (chai, _) { * expect(foo).to.have.all.keys('bar', 'baz'); * * @name all + * @namespace BDD * @api public */ @@ -425,6 +430,7 @@ module.exports = function (chai, _) { * expect({ foo: 'bar' }).to.be.an('object'); * expect(null).to.be.a('null'); * expect(undefined).to.be.an('undefined'); + * expect(new Error).to.be.an('error'); * expect(new Promise).to.be.a('promise'); * expect(new Float32Array()).to.be.a('float32array'); * expect(Symbol()).to.be.a('symbol'); @@ -439,6 +445,7 @@ module.exports = function (chai, _) { * @alias an * @param {String} type * @param {String} message _optional_ + * @namespace BDD * @api public */ @@ -476,6 +483,7 @@ module.exports = function (chai, _) { * @alias contains * @param {Object|String|Number} obj * @param {String} message _optional_ + * @namespace BDD * @api public */ @@ -484,9 +492,12 @@ module.exports = function (chai, _) { } function include (val, msg) { + _.expectTypes(this, ['array', 'object', 'string']); + if (msg) flag(this, 'message', msg); var obj = flag(this, 'object'); var expected = false; + if (_.type(obj) === 'array' && _.type(val) === 'object') { for (var i in obj) { if (_.eql(obj[i], val)) { @@ -503,7 +514,7 @@ module.exports = function (chai, _) { for (var k in val) subset[k] = obj[k]; expected = _.eql(subset, val); } else { - expected = obj && ~obj.indexOf(val); + expected = (obj != undefined) && ~obj.indexOf(val); } this.assert( expected @@ -521,13 +532,14 @@ module.exports = function (chai, _) { * * Asserts that the target is truthy. * - * expect('everthing').to.be.ok; + * expect('everything').to.be.ok; * expect(1).to.be.ok; * expect(false).to.not.be.ok; * expect(undefined).to.not.be.ok; * expect(null).to.not.be.ok; * * @name ok + * @namespace BDD * @api public */ @@ -547,6 +559,7 @@ module.exports = function (chai, _) { * expect(1).to.not.be.true; * * @name true + * @namespace BDD * @api public */ @@ -568,6 +581,7 @@ module.exports = function (chai, _) { * expect(0).to.not.be.false; * * @name false + * @namespace BDD * @api public */ @@ -589,6 +603,7 @@ module.exports = function (chai, _) { * expect(undefined).to.not.be.null; * * @name null + * @namespace BDD * @api public */ @@ -609,6 +624,7 @@ module.exports = function (chai, _) { * expect(null).to.not.be.undefined; * * @name undefined + * @namespace BDD * @api public */ @@ -628,6 +644,7 @@ module.exports = function (chai, _) { * expect(4).not.to.be.NaN; * * @name NaN + * @namespace BDD * @api public */ @@ -653,6 +670,7 @@ module.exports = function (chai, _) { * expect(baz).to.not.exist; * * @name exist + * @namespace BDD * @api public */ @@ -677,6 +695,7 @@ module.exports = function (chai, _) { * expect({}).to.be.empty; * * @name empty + * @namespace BDD * @api public */ @@ -708,6 +727,7 @@ module.exports = function (chai, _) { * * @name arguments * @alias Arguments + * @namespace BDD * @api public */ @@ -743,6 +763,7 @@ module.exports = function (chai, _) { * @alias deep.equal * @param {Mixed} value * @param {String} message _optional_ + * @namespace BDD * @api public */ @@ -779,6 +800,7 @@ module.exports = function (chai, _) { * @alias eqls * @param {Mixed} value * @param {String} message _optional_ + * @namespace BDD * @api public */ @@ -817,6 +839,7 @@ module.exports = function (chai, _) { * @alias greaterThan * @param {Number} value * @param {String} message _optional_ + * @namespace BDD * @api public */ @@ -865,6 +888,7 @@ module.exports = function (chai, _) { * @alias gte * @param {Number} value * @param {String} message _optional_ + * @namespace BDD * @api public */ @@ -913,6 +937,7 @@ module.exports = function (chai, _) { * @alias lessThan * @param {Number} value * @param {String} message _optional_ + * @namespace BDD * @api public */ @@ -961,6 +986,7 @@ module.exports = function (chai, _) { * @alias lte * @param {Number} value * @param {String} message _optional_ + * @namespace BDD * @api public */ @@ -1008,6 +1034,7 @@ module.exports = function (chai, _) { * @param {Number} start lowerbound inclusive * @param {Number} finish upperbound inclusive * @param {String} message _optional_ + * @namespace BDD * @api public */ @@ -1047,6 +1074,7 @@ module.exports = function (chai, _) { * @param {Constructor} constructor * @param {String} message _optional_ * @alias instanceOf + * @namespace BDD * @api public */ @@ -1131,6 +1159,7 @@ module.exports = function (chai, _) { * @param {Mixed} value (optional) * @param {String} message _optional_ * @returns value of property for chaining + * @namespace BDD * @api public */ @@ -1186,6 +1215,7 @@ module.exports = function (chai, _) { * @alias haveOwnProperty * @param {String} name * @param {String} message _optional_ + * @namespace BDD * @api public */ @@ -1218,6 +1248,7 @@ module.exports = function (chai, _) { * @param {String} name * @param {Object} descriptor _optional_ * @param {String} message _optional_ + * @namespace BDD * @api public */ @@ -1270,6 +1301,7 @@ module.exports = function (chai, _) { * switched to use `lengthOf(value)` instead. * * @name length + * @namespace BDD * @api public */ @@ -1285,6 +1317,7 @@ module.exports = function (chai, _) { * @name lengthOf * @param {Number} length * @param {String} message _optional_ + * @namespace BDD * @api public */ @@ -1321,6 +1354,7 @@ module.exports = function (chai, _) { * @alias matches * @param {RegExp} RegularExpression * @param {String} message _optional_ + * @namespace BDD * @api public */ function assertMatch(re, msg) { @@ -1346,6 +1380,7 @@ module.exports = function (chai, _) { * @name string * @param {String} string * @param {String} message _optional_ + * @namespace BDD * @api public */ @@ -1396,7 +1431,8 @@ module.exports = function (chai, _) { * * @name keys * @alias key - * @param {String...|Array|Object} keys + * @param {...String|Array|Object} keys + * @namespace BDD * @api public */ @@ -1499,7 +1535,6 @@ module.exports = function (chai, _) { * expect(fn).to.not.throw('good function'); * expect(fn).to.throw(ReferenceError, /bad function/); * expect(fn).to.throw(err); - * expect(fn).to.not.throw(new RangeError('Out of range.')); * * Please note that when a throw expectation is negated, it will check each * parameter independently, starting with error constructor type. The appropriate way @@ -1517,6 +1552,7 @@ module.exports = function (chai, _) { * @param {String} message _optional_ * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types * @returns error for chaining (null if no error) + * @namespace BDD * @api public */ @@ -1541,9 +1577,9 @@ module.exports = function (chai, _) { constructor = null; errMsg = null; } else if (typeof constructor === 'function') { - name = constructor.prototype.name || constructor.name; - if (name === 'Error' && constructor !== Error) { - name = (new constructor()).name; + name = constructor.prototype.name; + if (!name || (name === 'Error' && constructor !== Error)) { + name = constructor.name || (new constructor()).name; } } else { constructor = null; @@ -1660,6 +1696,7 @@ module.exports = function (chai, _) { * @alias respondsTo * @param {String} method * @param {String} message _optional_ + * @namespace BDD * @api public */ @@ -1694,6 +1731,7 @@ module.exports = function (chai, _) { * expect(Foo).itself.not.to.respondTo('baz'); * * @name itself + * @namespace BDD * @api public */ @@ -1712,6 +1750,7 @@ module.exports = function (chai, _) { * @alias satisfies * @param {Function} matcher * @param {String} message _optional_ + * @namespace BDD * @api public */ @@ -1727,7 +1766,7 @@ module.exports = function (chai, _) { , result ); } - + Assertion.addMethod('satisfy', satisfy); Assertion.addMethod('satisfies', satisfy); @@ -1739,19 +1778,21 @@ module.exports = function (chai, _) { * expect(1.5).to.be.closeTo(1, 0.5); * * @name closeTo + * @alias approximately * @param {Number} expected * @param {Number} delta * @param {String} message _optional_ + * @namespace BDD * @api public */ - Assertion.addMethod('closeTo', function (expected, delta, msg) { + function closeTo(expected, delta, msg) { if (msg) flag(this, 'message', msg); var obj = flag(this, 'object'); new Assertion(obj, msg).is.a('number'); if (_.type(expected) !== 'number' || _.type(delta) !== 'number') { - throw new Error('the arguments to closeTo must be numbers'); + throw new Error('the arguments to closeTo or approximately must be numbers'); } this.assert( @@ -1759,7 +1800,10 @@ module.exports = function (chai, _) { , 'expected #{this} to be close to ' + expected + ' +/- ' + delta , 'expected #{this} not to be close to ' + expected + ' +/- ' + delta ); - }); + } + + Assertion.addMethod('closeTo', closeTo); + Assertion.addMethod('approximately', closeTo); function isSubsetOf(subset, superset, cmp) { return subset.every(function(elem) { @@ -1790,6 +1834,7 @@ module.exports = function (chai, _) { * @name members * @param {Array} set * @param {String} message _optional_ + * @namespace BDD * @api public */ @@ -1821,6 +1866,45 @@ module.exports = function (chai, _) { ); }); + /** + * ### .oneOf(list) + * + * Assert that a value appears somewhere in the top level of array `list`. + * + * expect('a').to.be.oneOf(['a', 'b', 'c']); + * expect(9).to.not.be.oneOf(['z']); + * expect([3]).to.not.be.oneOf([1, 2, [3]]); + * + * var three = [3]; + * // for object-types, contents are not compared + * expect(three).to.not.be.oneOf([1, 2, [3]]); + * // comparing references works + * expect(three).to.be.oneOf([1, 2, three]); + * + * @name oneOf + * @param {Array<*>} list + * @param {String} message _optional_ + * @namespace BDD + * @api public + */ + + function oneOf (list, msg) { + if (msg) flag(this, 'message', msg); + var expected = flag(this, 'object'); + new Assertion(list).to.be.an('array'); + + this.assert( + list.indexOf(expected) > -1 + , 'expected #{this} to be one of #{exp}' + , 'expected #{this} to not be one of #{exp}' + , list + , expected + ); + } + + Assertion.addMethod('oneOf', oneOf); + + /** * ### .change(function) * @@ -1838,6 +1922,7 @@ module.exports = function (chai, _) { * @param {String} object * @param {String} property name * @param {String} message _optional_ + * @namespace BDD * @api public */ @@ -1875,6 +1960,7 @@ module.exports = function (chai, _) { * @param {String} object * @param {String} property name * @param {String} message _optional_ + * @namespace BDD * @api public */ @@ -1912,6 +1998,7 @@ module.exports = function (chai, _) { * @param {String} object * @param {String} property name * @param {String} message _optional_ + * @namespace BDD * @api public */ @@ -1937,7 +2024,7 @@ module.exports = function (chai, _) { /** * ### .extensible * - * Asserts that the target is extensible (can have new properties added to + * Asserts that the target is extensible (can have new properties added to * it). * * var nonExtensibleObject = Object.preventExtensions({}); @@ -1950,14 +2037,29 @@ module.exports = function (chai, _) { * expect(frozenObject).to.not.be.extensible; * * @name extensible + * @namespace BDD * @api public */ Assertion.addProperty('extensible', function() { var obj = flag(this, 'object'); + // In ES5, if the argument to this method is not an object (a primitive), then it will cause a TypeError. + // In ES6, a non-object argument will be treated as if it was a non-extensible ordinary object, simply return false. + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible + // The following provides ES6 behavior when a TypeError is thrown under ES5. + + var isExtensible; + + try { + isExtensible = Object.isExtensible(obj); + } catch (err) { + if (err instanceof TypeError) isExtensible = false; + else throw err; + } + this.assert( - Object.isExtensible(obj) + isExtensible , 'expected #{this} to be extensible' , 'expected #{this} to not be extensible' ); @@ -1977,14 +2079,29 @@ module.exports = function (chai, _) { * expect({}).to.not.be.sealed; * * @name sealed + * @namespace BDD * @api public */ Assertion.addProperty('sealed', function() { var obj = flag(this, 'object'); + // In ES5, if the argument to this method is not an object (a primitive), then it will cause a TypeError. + // In ES6, a non-object argument will be treated as if it was a sealed ordinary object, simply return true. + // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isSealed + // The following provides ES6 behavior when a TypeError is thrown under ES5. + + var isSealed; + + try { + isSealed = Object.isSealed(obj); + } catch (err) { + if (err instanceof TypeError) isSealed = true; + else throw err; + } + this.assert( - Object.isSealed(obj) + isSealed , 'expected #{this} to be sealed' , 'expected #{this} to not be sealed' ); @@ -2002,19 +2119,33 @@ module.exports = function (chai, _) { * expect({}).to.not.be.frozen; * * @name frozen + * @namespace BDD * @api public */ Assertion.addProperty('frozen', function() { var obj = flag(this, 'object'); + // In ES5, if the argument to this method is not an object (a primitive), then it will cause a TypeError. + // In ES6, a non-object argument will be treated as if it was a frozen ordinary object, simply return true. + // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen + // The following provides ES6 behavior when a TypeError is thrown under ES5. + + var isFrozen; + + try { + isFrozen = Object.isFrozen(obj); + } catch (err) { + if (err instanceof TypeError) isFrozen = true; + else throw err; + } + this.assert( - Object.isFrozen(obj) + isFrozen , 'expected #{this} to be frozen' , 'expected #{this} to not be frozen' ); }); - }; },{}],6:[function(require,module,exports){ @@ -2049,6 +2180,7 @@ module.exports = function (chai, util) { * @param {Mixed} expression to test for truthiness * @param {String} message to display on error * @name assert + * @namespace Assert * @api public */ @@ -2071,6 +2203,7 @@ module.exports = function (chai, util) { * @param {Mixed} expected * @param {String} message * @param {String} operator + * @namespace Assert * @api public */ @@ -2095,6 +2228,7 @@ module.exports = function (chai, util) { * @alias ok * @param {Mixed} object to test * @param {String} message + * @namespace Assert * @api public */ @@ -2114,6 +2248,7 @@ module.exports = function (chai, util) { * @alias notOk * @param {Mixed} object to test * @param {String} message + * @namespace Assert * @api public */ @@ -2132,6 +2267,7 @@ module.exports = function (chai, util) { * @param {Mixed} actual * @param {Mixed} expected * @param {String} message + * @namespace Assert * @api public */ @@ -2158,6 +2294,7 @@ module.exports = function (chai, util) { * @param {Mixed} actual * @param {Mixed} expected * @param {String} message + * @namespace Assert * @api public */ @@ -2184,6 +2321,7 @@ module.exports = function (chai, util) { * @param {Mixed} actual * @param {Mixed} expected * @param {String} message + * @namespace Assert * @api public */ @@ -2202,6 +2340,7 @@ module.exports = function (chai, util) { * @param {Mixed} actual * @param {Mixed} expected * @param {String} message + * @namespace Assert * @api public */ @@ -2220,6 +2359,7 @@ module.exports = function (chai, util) { * @param {Mixed} actual * @param {Mixed} expected * @param {String} message + * @namespace Assert * @api public */ @@ -2238,6 +2378,7 @@ module.exports = function (chai, util) { * @param {Mixed} actual * @param {Mixed} expected * @param {String} message + * @namespace Assert * @api public */ @@ -2245,17 +2386,18 @@ module.exports = function (chai, util) { new Assertion(act, msg).to.not.eql(exp); }; - /** - * ### .isTrue(value, [message]) + /** + * ### .isAbove(valueToCheck, valueToBeAbove, [message]) * - * Asserts that `value` is true. + * Asserts `valueToCheck` is strictly greater than (>) `valueToBeAbove` * - * var teaServed = true; - * assert.isTrue(teaServed, 'the tea has been served'); + * assert.isAbove(5, 2, '5 is strictly greater than 2'); * - * @name isTrue - * @param {Mixed} value + * @name isAbove + * @param {Mixed} valueToCheck + * @param {Mixed} valueToBeAbove * @param {String} message + * @namespace Assert * @api public */ @@ -2264,21 +2406,23 @@ module.exports = function (chai, util) { }; /** - * ### .isAbove(valueToCheck, valueToBeAbove, [message]) + * ### .isAtLeast(valueToCheck, valueToBeAtLeast, [message]) * - * Asserts `valueToCheck` is strictly greater than (>) `valueToBeAbove` + * Asserts `valueToCheck` is greater than or equal to (>=) `valueToBeAtLeast` * - * assert.isAbove(5, 2, '5 is strictly greater than 2'); + * assert.isAtLeast(5, 2, '5 is greater or equal to 2'); + * assert.isAtLeast(3, 3, '3 is greater or equal to 3'); * - * @name isAbove + * @name isAtLeast * @param {Mixed} valueToCheck - * @param {Mixed} valueToBeAbove + * @param {Mixed} valueToBeAtLeast * @param {String} message + * @namespace Assert * @api public */ - assert.isBelow = function (val, blw, msg) { - new Assertion(val, msg).to.be.below(blw); + assert.isAtLeast = function (val, atlst, msg) { + new Assertion(val, msg).to.be.least(atlst); }; /** @@ -2292,6 +2436,46 @@ module.exports = function (chai, util) { * @param {Mixed} valueToCheck * @param {Mixed} valueToBeBelow * @param {String} message + * @namespace Assert + * @api public + */ + + assert.isBelow = function (val, blw, msg) { + new Assertion(val, msg).to.be.below(blw); + }; + + /** + * ### .isAtMost(valueToCheck, valueToBeAtMost, [message]) + * + * Asserts `valueToCheck` is less than or equal to (<=) `valueToBeAtMost` + * + * assert.isAtMost(3, 6, '3 is less than or equal to 6'); + * assert.isAtMost(4, 4, '4 is less than or equal to 4'); + * + * @name isAtMost + * @param {Mixed} valueToCheck + * @param {Mixed} valueToBeAtMost + * @param {String} message + * @namespace Assert + * @api public + */ + + assert.isAtMost = function (val, atmst, msg) { + new Assertion(val, msg).to.be.most(atmst); + }; + + /** + * ### .isTrue(value, [message]) + * + * Asserts that `value` is true. + * + * var teaServed = true; + * assert.isTrue(teaServed, 'the tea has been served'); + * + * @name isTrue + * @param {Mixed} value + * @param {String} message + * @namespace Assert * @api public */ @@ -2299,6 +2483,25 @@ module.exports = function (chai, util) { new Assertion(val, msg).is['true']; }; + /** + * ### .isNotTrue(value, [message]) + * + * Asserts that `value` is not true. + * + * var tea = 'tasty chai'; + * assert.isNotTrue(tea, 'great, time for tea!'); + * + * @name isNotTrue + * @param {Mixed} value + * @param {String} message + * @namespace Assert + * @api public + */ + + assert.isNotTrue = function (val, msg) { + new Assertion(val, msg).to.not.equal(true); + }; + /** * ### .isFalse(value, [message]) * @@ -2310,6 +2513,7 @@ module.exports = function (chai, util) { * @name isFalse * @param {Mixed} value * @param {String} message + * @namespace Assert * @api public */ @@ -2317,6 +2521,25 @@ module.exports = function (chai, util) { new Assertion(val, msg).is['false']; }; + /** + * ### .isNotFalse(value, [message]) + * + * Asserts that `value` is not false. + * + * var tea = 'tasty chai'; + * assert.isNotFalse(tea, 'great, time for tea!'); + * + * @name isNotFalse + * @param {Mixed} value + * @param {String} message + * @namespace Assert + * @api public + */ + + assert.isNotFalse = function (val, msg) { + new Assertion(val, msg).to.not.equal(false); + }; + /** * ### .isNull(value, [message]) * @@ -2327,6 +2550,7 @@ module.exports = function (chai, util) { * @name isNull * @param {Mixed} value * @param {String} message + * @namespace Assert * @api public */ @@ -2345,6 +2569,7 @@ module.exports = function (chai, util) { * @name isNotNull * @param {Mixed} value * @param {String} message + * @namespace Assert * @api public */ @@ -2361,6 +2586,7 @@ module.exports = function (chai, util) { * @name isNaN * @param {Mixed} value * @param {String} message + * @namespace Assert * @api public */ @@ -2377,6 +2603,7 @@ module.exports = function (chai, util) { * @name isNotNaN * @param {Mixed} value * @param {String} message + * @namespace Assert * @api public */ assert.isNotNaN = function (val, msg) { @@ -2394,6 +2621,7 @@ module.exports = function (chai, util) { * @name isUndefined * @param {Mixed} value * @param {String} message + * @namespace Assert * @api public */ @@ -2412,6 +2640,7 @@ module.exports = function (chai, util) { * @name isDefined * @param {Mixed} value * @param {String} message + * @namespace Assert * @api public */ @@ -2430,6 +2659,7 @@ module.exports = function (chai, util) { * @name isFunction * @param {Mixed} value * @param {String} message + * @namespace Assert * @api public */ @@ -2448,6 +2678,7 @@ module.exports = function (chai, util) { * @name isNotFunction * @param {Mixed} value * @param {String} message + * @namespace Assert * @api public */ @@ -2467,6 +2698,7 @@ module.exports = function (chai, util) { * @name isObject * @param {Mixed} value * @param {String} message + * @namespace Assert * @api public */ @@ -2486,6 +2718,7 @@ module.exports = function (chai, util) { * @name isNotObject * @param {Mixed} value * @param {String} message + * @namespace Assert * @api public */ @@ -2504,6 +2737,7 @@ module.exports = function (chai, util) { * @name isArray * @param {Mixed} value * @param {String} message + * @namespace Assert * @api public */ @@ -2522,6 +2756,7 @@ module.exports = function (chai, util) { * @name isNotArray * @param {Mixed} value * @param {String} message + * @namespace Assert * @api public */ @@ -2540,6 +2775,7 @@ module.exports = function (chai, util) { * @name isString * @param {Mixed} value * @param {String} message + * @namespace Assert * @api public */ @@ -2558,6 +2794,7 @@ module.exports = function (chai, util) { * @name isNotString * @param {Mixed} value * @param {String} message + * @namespace Assert * @api public */ @@ -2576,6 +2813,7 @@ module.exports = function (chai, util) { * @name isNumber * @param {Number} value * @param {String} message + * @namespace Assert * @api public */ @@ -2594,6 +2832,7 @@ module.exports = function (chai, util) { * @name isNotNumber * @param {Mixed} value * @param {String} message + * @namespace Assert * @api public */ @@ -2615,6 +2854,7 @@ module.exports = function (chai, util) { * @name isBoolean * @param {Mixed} value * @param {String} message + * @namespace Assert * @api public */ @@ -2636,6 +2876,7 @@ module.exports = function (chai, util) { * @name isNotBoolean * @param {Mixed} value * @param {String} message + * @namespace Assert * @api public */ @@ -2660,6 +2901,7 @@ module.exports = function (chai, util) { * @param {Mixed} value * @param {String} name * @param {String} message + * @namespace Assert * @api public */ @@ -2679,6 +2921,7 @@ module.exports = function (chai, util) { * @param {Mixed} value * @param {String} typeof name * @param {String} message + * @namespace Assert * @api public */ @@ -2700,6 +2943,7 @@ module.exports = function (chai, util) { * @param {Object} object * @param {Constructor} constructor * @param {String} message + * @namespace Assert * @api public */ @@ -2721,6 +2965,7 @@ module.exports = function (chai, util) { * @param {Object} object * @param {Constructor} constructor * @param {String} message + * @namespace Assert * @api public */ @@ -2741,6 +2986,7 @@ module.exports = function (chai, util) { * @param {Array|String} haystack * @param {Mixed} needle * @param {String} message + * @namespace Assert * @api public */ @@ -2761,6 +3007,7 @@ module.exports = function (chai, util) { * @param {Array|String} haystack * @param {Mixed} needle * @param {String} message + * @namespace Assert * @api public */ @@ -2779,6 +3026,7 @@ module.exports = function (chai, util) { * @param {Mixed} value * @param {RegExp} regexp * @param {String} message + * @namespace Assert * @api public */ @@ -2797,6 +3045,7 @@ module.exports = function (chai, util) { * @param {Mixed} value * @param {RegExp} regexp * @param {String} message + * @namespace Assert * @api public */ @@ -2815,6 +3064,7 @@ module.exports = function (chai, util) { * @param {Object} object * @param {String} property * @param {String} message + * @namespace Assert * @api public */ @@ -2833,6 +3083,7 @@ module.exports = function (chai, util) { * @param {Object} object * @param {String} property * @param {String} message + * @namespace Assert * @api public */ @@ -2852,6 +3103,7 @@ module.exports = function (chai, util) { * @param {Object} object * @param {String} property * @param {String} message + * @namespace Assert * @api public */ @@ -2871,6 +3123,7 @@ module.exports = function (chai, util) { * @param {Object} object * @param {String} property * @param {String} message + * @namespace Assert * @api public */ @@ -2891,6 +3144,7 @@ module.exports = function (chai, util) { * @param {String} property * @param {Mixed} value * @param {String} message + * @namespace Assert * @api public */ @@ -2911,6 +3165,7 @@ module.exports = function (chai, util) { * @param {String} property * @param {Mixed} value * @param {String} message + * @namespace Assert * @api public */ @@ -2932,6 +3187,7 @@ module.exports = function (chai, util) { * @param {String} property * @param {Mixed} value * @param {String} message + * @namespace Assert * @api public */ @@ -2953,6 +3209,7 @@ module.exports = function (chai, util) { * @param {String} property * @param {Mixed} value * @param {String} message + * @namespace Assert * @api public */ @@ -2966,12 +3223,13 @@ module.exports = function (chai, util) { * Asserts that `object` has a `length` property with the expected value. * * assert.lengthOf([1,2,3], 3, 'array has length of 3'); - * assert.lengthOf('foobar', 5, 'string has length of 6'); + * assert.lengthOf('foobar', 6, 'string has length of 6'); * * @name lengthOf * @param {Mixed} object * @param {Number} length * @param {String} message + * @namespace Assert * @api public */ @@ -3000,6 +3258,7 @@ module.exports = function (chai, util) { * @param {RegExp} regexp * @param {String} message * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types + * @namespace Assert * @api public */ @@ -3028,6 +3287,7 @@ module.exports = function (chai, util) { * @param {RegExp} regexp * @param {String} message * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types + * @namespace Assert * @api public */ @@ -3053,6 +3313,7 @@ module.exports = function (chai, util) { * @param {String} operator * @param {Mixed} val2 * @param {String} message + * @namespace Assert * @api public */ @@ -3105,6 +3366,7 @@ module.exports = function (chai, util) { * @param {Number} expected * @param {Number} delta * @param {String} message + * @namespace Assert * @api public */ @@ -3112,6 +3374,26 @@ module.exports = function (chai, util) { new Assertion(act, msg).to.be.closeTo(exp, delta); }; + /** + * ### .approximately(actual, expected, delta, [message]) + * + * Asserts that the target is equal `expected`, to within a +/- `delta` range. + * + * assert.approximately(1.5, 1, 0.5, 'numbers are close'); + * + * @name approximately + * @param {Number} actual + * @param {Number} expected + * @param {Number} delta + * @param {String} message + * @namespace Assert + * @api public + */ + + assert.approximately = function (act, exp, delta, msg) { + new Assertion(act, msg).to.be.approximately(exp, delta); + }; + /** * ### .sameMembers(set1, set2, [message]) * @@ -3124,6 +3406,7 @@ module.exports = function (chai, util) { * @param {Array} set1 * @param {Array} set2 * @param {String} message + * @namespace Assert * @api public */ @@ -3143,6 +3426,7 @@ module.exports = function (chai, util) { * @param {Array} set1 * @param {Array} set2 * @param {String} message + * @namespace Assert * @api public */ @@ -3162,6 +3446,7 @@ module.exports = function (chai, util) { * @param {Array} superset * @param {Array} subset * @param {String} message + * @namespace Assert * @api public */ @@ -3169,6 +3454,25 @@ module.exports = function (chai, util) { new Assertion(superset, msg).to.include.members(subset); } + /** + * ### .oneOf(inList, list, [message]) + * + * Asserts that non-object, non-array value `inList` appears in the flat array `list`. + * + * assert.oneOf(1, [ 2, 1 ], 'Not found in list'); + * + * @name oneOf + * @param {*} inList + * @param {Array<*>} list + * @param {String} message + * @namespace Assert + * @api public + */ + + assert.oneOf = function (inList, list, msg) { + new Assertion(inList, msg).to.be.oneOf(list); + } + /** * ### .changes(function, object, property) * @@ -3183,6 +3487,7 @@ module.exports = function (chai, util) { * @param {Object} object * @param {String} property name * @param {String} message _optional_ + * @namespace Assert * @api public */ @@ -3204,6 +3509,7 @@ module.exports = function (chai, util) { * @param {Object} object * @param {String} property name * @param {String} message _optional_ + * @namespace Assert * @api public */ @@ -3225,6 +3531,7 @@ module.exports = function (chai, util) { * @param {Object} object * @param {String} property name * @param {String} message _optional_ + * @namespace Assert * @api public */ @@ -3246,6 +3553,7 @@ module.exports = function (chai, util) { * @param {Object} object * @param {String} property name * @param {String} message _optional_ + * @namespace Assert * @api public */ @@ -3267,6 +3575,7 @@ module.exports = function (chai, util) { * @param {Object} object * @param {String} property name * @param {String} message _optional_ + * @namespace Assert * @api public */ @@ -3288,6 +3597,7 @@ module.exports = function (chai, util) { * @param {Object} object * @param {String} property name * @param {String} message _optional_ + * @namespace Assert * @api public */ @@ -3307,6 +3617,7 @@ module.exports = function (chai, util) { * * @name ifError * @param {Object} object + * @namespace Assert * @api public */ @@ -3327,6 +3638,7 @@ module.exports = function (chai, util) { * @alias extensible * @param {Object} object * @param {String} message _optional_ + * @namespace Assert * @api public */ @@ -3351,6 +3663,7 @@ module.exports = function (chai, util) { * @alias notExtensible * @param {Object} object * @param {String} message _optional_ + * @namespace Assert * @api public */ @@ -3374,6 +3687,7 @@ module.exports = function (chai, util) { * @alias sealed * @param {Object} object * @param {String} message _optional_ + * @namespace Assert * @api public */ @@ -3392,6 +3706,7 @@ module.exports = function (chai, util) { * @alias notSealed * @param {Object} object * @param {String} message _optional_ + * @namespace Assert * @api public */ @@ -3412,6 +3727,7 @@ module.exports = function (chai, util) { * @alias frozen * @param {Object} object * @param {String} message _optional_ + * @namespace Assert * @api public */ @@ -3430,6 +3746,7 @@ module.exports = function (chai, util) { * @alias notFrozen * @param {Object} object * @param {String} message _optional_ + * @namespace Assert * @api public */ @@ -3479,6 +3796,7 @@ module.exports = function (chai, util) { * @param {Mixed} expected * @param {String} message * @param {String} operator + * @namespace Expect * @api public */ @@ -3543,6 +3861,7 @@ module.exports = function (chai, util) { * @param {Mixed} expected * @param {String} message * @param {String} operator + * @namespace Should * @api public */ @@ -3647,6 +3966,7 @@ var call = Function.prototype.call, * @param {String} name of method to add * @param {Function} method function to be used for `name`, when called * @param {Function} chainingBehavior function to be called every time the property is accessed + * @namespace Utils * @name addChainableMethod * @api public */ @@ -3705,7 +4025,7 @@ module.exports = function (ctx, name, method, chainingBehavior) { }); }; -},{"../config":4,"./flag":12,"./transferFlags":28}],10:[function(require,module,exports){ +},{"../config":4,"./flag":13,"./transferFlags":29}],10:[function(require,module,exports){ /*! * Chai - addMethod utility * Copyright(c) 2012-2014 Jake Luer @@ -3735,6 +4055,7 @@ var config = require('../config'); * @param {Object} ctx object to which the method is added * @param {String} name of method to add * @param {Function} method function to be used for name + * @namespace Utils * @name addMethod * @api public */ @@ -3750,13 +4071,16 @@ module.exports = function (ctx, name, method) { }; }; -},{"../config":4,"./flag":12}],11:[function(require,module,exports){ +},{"../config":4,"./flag":13}],11:[function(require,module,exports){ /*! * Chai - addProperty utility * Copyright(c) 2012-2014 Jake Luer * MIT Licensed */ +var config = require('../config'); +var flag = require('./flag'); + /** * ### addProperty (ctx, name, getter) * @@ -3778,13 +4102,18 @@ module.exports = function (ctx, name, method) { * @param {Object} ctx object to which the property is added * @param {String} name of property to add * @param {Function} getter function to be used for name + * @namespace Utils * @name addProperty * @api public */ module.exports = function (ctx, name, getter) { Object.defineProperty(ctx, name, - { get: function () { + { get: function addProperty() { + var old_ssfi = flag(this, 'ssfi'); + if (old_ssfi && config.includeStack === false) + flag(this, 'ssfi', addProperty); + var result = getter.call(this); return result === undefined ? this : result; } @@ -3792,7 +4121,51 @@ module.exports = function (ctx, name, getter) { }); }; -},{}],12:[function(require,module,exports){ +},{"../config":4,"./flag":13}],12:[function(require,module,exports){ +/*! + * Chai - expectTypes utility + * Copyright(c) 2012-2014 Jake Luer + * MIT Licensed + */ + +/** + * ### expectTypes(obj, types) + * + * Ensures that the object being tested against is of a valid type. + * + * utils.expectTypes(this, ['array', 'object', 'string']); + * + * @param {Mixed} obj constructed Assertion + * @param {Array} type A list of allowed types for this assertion + * @namespace Utils + * @name expectTypes + * @api public + */ + +var AssertionError = require('assertion-error'); +var flag = require('./flag'); +var type = require('type-detect'); + +module.exports = function (obj, types) { + var obj = flag(obj, 'object'); + types = types.map(function (t) { return t.toLowerCase(); }); + types.sort(); + + // Transforms ['lorem', 'ipsum'] into 'a lirum, or an ipsum' + var str = types.map(function (t, index) { + var art = ~[ 'a', 'e', 'i', 'o', 'u' ].indexOf(t.charAt(0)) ? 'an' : 'a'; + var or = types.length > 1 && index === types.length - 1 ? 'or ' : ''; + return or + art + ' ' + t; + }).join(', '); + + if (!types.some(function (expected) { return type(obj) === expected; })) { + throw new AssertionError( + 'object tested must be ' + str + ', but ' + type(obj) + ' given' + ); + } +}; + +},{"./flag":13,"assertion-error":30,"type-detect":35}],13:[function(require,module,exports){ /*! * Chai - flag utility * Copyright(c) 2012-2014 Jake Luer @@ -3813,6 +4186,7 @@ module.exports = function (ctx, name, getter) { * @param {Object} object constructed Assertion * @param {String} key * @param {Mixed} value (optional) + * @namespace Utils * @name flag * @api private */ @@ -3826,7 +4200,7 @@ module.exports = function (obj, key, value) { } }; -},{}],13:[function(require,module,exports){ +},{}],14:[function(require,module,exports){ /*! * Chai - getActual utility * Copyright(c) 2012-2014 Jake Luer @@ -3840,13 +4214,15 @@ module.exports = function (obj, key, value) { * * @param {Object} object (constructed Assertion) * @param {Arguments} chai.Assertion.prototype.assert arguments + * @namespace Utils + * @name getActual */ module.exports = function (obj, args) { return args.length > 4 ? args[4] : obj._obj; }; -},{}],14:[function(require,module,exports){ +},{}],15:[function(require,module,exports){ /*! * Chai - getEnumerableProperties utility * Copyright(c) 2012-2014 Jake Luer @@ -3861,6 +4237,7 @@ module.exports = function (obj, args) { * * @param {Object} object * @returns {Array} + * @namespace Utils * @name getEnumerableProperties * @api public */ @@ -3873,7 +4250,7 @@ module.exports = function getEnumerableProperties(object) { return result; }; -},{}],15:[function(require,module,exports){ +},{}],16:[function(require,module,exports){ /*! * Chai - message composition utility * Copyright(c) 2012-2014 Jake Luer @@ -3903,6 +4280,7 @@ var flag = require('./flag') * * @param {Object} object (constructed Assertion) * @param {Arguments} chai.Assertion.prototype.assert arguments + * @namespace Utils * @name getMessage * @api public */ @@ -3925,7 +4303,7 @@ module.exports = function (obj, args) { return flagMsg ? flagMsg + ': ' + msg : msg; }; -},{"./flag":12,"./getActual":13,"./inspect":22,"./objDisplay":23}],16:[function(require,module,exports){ +},{"./flag":13,"./getActual":14,"./inspect":23,"./objDisplay":24}],17:[function(require,module,exports){ /*! * Chai - getName utility * Copyright(c) 2012-2014 Jake Luer @@ -3938,6 +4316,8 @@ module.exports = function (obj, args) { * Gets the name of a function, in a cross-browser way. * * @param {Function} a function (usually a constructor) + * @namespace Utils + * @name getName */ module.exports = function (func) { @@ -3947,7 +4327,7 @@ module.exports = function (func) { return match && match[1] ? match[1] : ""; }; -},{}],17:[function(require,module,exports){ +},{}],18:[function(require,module,exports){ /*! * Chai - getPathInfo utility * Copyright(c) 2012-2014 Jake Luer @@ -3973,6 +4353,7 @@ var hasProperty = require('./hasProperty'); * @param {String} path * @param {Object} object * @returns {Object} info + * @namespace Utils * @name getPathInfo * @api public */ @@ -4059,7 +4440,7 @@ function _getPathValue (parsed, obj, index) { return res; } -},{"./hasProperty":20}],18:[function(require,module,exports){ +},{"./hasProperty":21}],19:[function(require,module,exports){ /*! * Chai - getPathValue utility * Copyright(c) 2012-2014 Jake Luer @@ -4095,15 +4476,16 @@ var getPathInfo = require('./getPathInfo'); * @param {String} path * @param {Object} object * @returns {Object} value or `undefined` + * @namespace Utils * @name getPathValue * @api public */ module.exports = function(path, obj) { var info = getPathInfo(path, obj); return info.value; -}; +}; -},{"./getPathInfo":17}],19:[function(require,module,exports){ +},{"./getPathInfo":18}],20:[function(require,module,exports){ /*! * Chai - getProperties utility * Copyright(c) 2012-2014 Jake Luer @@ -4118,6 +4500,7 @@ module.exports = function(path, obj) { * * @param {Object} object * @returns {Array} + * @namespace Utils * @name getProperties * @api public */ @@ -4140,7 +4523,7 @@ module.exports = function getProperties(object) { return result; }; -},{}],20:[function(require,module,exports){ +},{}],21:[function(require,module,exports){ /*! * Chai - hasProperty utility * Copyright(c) 2012-2014 Jake Luer @@ -4169,7 +4552,7 @@ var type = require('type-detect'); * hasProperty('str', obj); // true * hasProperty('constructor', obj); // true * hasProperty('bar', obj); // false - * + * * hasProperty('length', obj.str); // true * hasProperty(1, obj.str); // true * hasProperty(5, obj.str); // false @@ -4181,6 +4564,7 @@ var type = require('type-detect'); * @param {Objuect} object * @param {String|Number} name * @returns {Boolean} whether it exists + * @namespace Utils * @name getPathInfo * @api public */ @@ -4205,7 +4589,7 @@ module.exports = function hasProperty(name, obj) { return name in obj; }; -},{"type-detect":34}],21:[function(require,module,exports){ +},{"type-detect":35}],22:[function(require,module,exports){ /*! * chai * Copyright(c) 2011 Jake Luer @@ -4230,6 +4614,11 @@ exports.test = require('./test'); exports.type = require('type-detect'); +/*! + * expectTypes utility + */ +exports.expectTypes = require('./expectTypes'); + /*! * message utility */ @@ -4332,8 +4721,7 @@ exports.addChainableMethod = require('./addChainableMethod'); exports.overwriteChainableMethod = require('./overwriteChainableMethod'); - -},{"./addChainableMethod":9,"./addMethod":10,"./addProperty":11,"./flag":12,"./getActual":13,"./getMessage":15,"./getName":16,"./getPathInfo":17,"./getPathValue":18,"./hasProperty":20,"./inspect":22,"./objDisplay":23,"./overwriteChainableMethod":24,"./overwriteMethod":25,"./overwriteProperty":26,"./test":27,"./transferFlags":28,"deep-eql":30,"type-detect":34}],22:[function(require,module,exports){ +},{"./addChainableMethod":9,"./addMethod":10,"./addProperty":11,"./expectTypes":12,"./flag":13,"./getActual":14,"./getMessage":16,"./getName":17,"./getPathInfo":18,"./getPathValue":19,"./hasProperty":21,"./inspect":23,"./objDisplay":24,"./overwriteChainableMethod":25,"./overwriteMethod":26,"./overwriteProperty":27,"./test":28,"./transferFlags":29,"deep-eql":31,"type-detect":35}],23:[function(require,module,exports){ // This is (almost) directly from Node.js utils // https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/util.js @@ -4353,6 +4741,8 @@ module.exports = inspect; * @param {Number} depth Depth in which to descend in object. Default is 2. * @param {Boolean} colors Flag to turn on ANSI escape codes to color the * output. Default is false (no coloring). + * @namespace Utils + * @name inspect */ function inspect(obj, showHidden, depth, colors) { var ctx = { @@ -4668,7 +5058,7 @@ function objectToString(o) { return Object.prototype.toString.call(o); } -},{"./getEnumerableProperties":14,"./getName":16,"./getProperties":19}],23:[function(require,module,exports){ +},{"./getEnumerableProperties":15,"./getName":17,"./getProperties":20}],24:[function(require,module,exports){ /*! * Chai - flag utility * Copyright(c) 2012-2014 Jake Luer @@ -4691,6 +5081,7 @@ var config = require('../config'); * * @param {Mixed} javascript object to inspect * @name objDisplay + * @namespace Utils * @api public */ @@ -4719,7 +5110,7 @@ module.exports = function (obj) { } }; -},{"../config":4,"./inspect":22}],24:[function(require,module,exports){ +},{"../config":4,"./inspect":23}],25:[function(require,module,exports){ /*! * Chai - overwriteChainableMethod utility * Copyright(c) 2012-2014 Jake Luer @@ -4754,6 +5145,7 @@ module.exports = function (obj) { * @param {String} name of method / property to overwrite * @param {Function} method function that returns a function to be used for name * @param {Function} chainingBehavior function that returns a function to be used for property + * @namespace Utils * @name overwriteChainableMethod * @api public */ @@ -4774,7 +5166,7 @@ module.exports = function (ctx, name, method, chainingBehavior) { }; }; -},{}],25:[function(require,module,exports){ +},{}],26:[function(require,module,exports){ /*! * Chai - overwriteMethod utility * Copyright(c) 2012-2014 Jake Luer @@ -4810,6 +5202,7 @@ module.exports = function (ctx, name, method, chainingBehavior) { * @param {Object} ctx object whose method is to be overwritten * @param {String} name of method to overwrite * @param {Function} method function that returns a function to be used for name + * @namespace Utils * @name overwriteMethod * @api public */ @@ -4827,7 +5220,7 @@ module.exports = function (ctx, name, method) { } }; -},{}],26:[function(require,module,exports){ +},{}],27:[function(require,module,exports){ /*! * Chai - overwriteProperty utility * Copyright(c) 2012-2014 Jake Luer @@ -4863,6 +5256,7 @@ module.exports = function (ctx, name, method) { * @param {Object} ctx object whose property is to be overwritten * @param {String} name of property to overwrite * @param {Function} getter function that returns a getter function to be used for name + * @namespace Utils * @name overwriteProperty * @api public */ @@ -4883,7 +5277,7 @@ module.exports = function (ctx, name, getter) { }); }; -},{}],27:[function(require,module,exports){ +},{}],28:[function(require,module,exports){ /*! * Chai - test utility * Copyright(c) 2012-2014 Jake Luer @@ -4903,6 +5297,8 @@ var flag = require('./flag'); * * @param {Object} object (constructed Assertion) * @param {Arguments} chai.Assertion.prototype.assert arguments + * @namespace Utils + * @name test */ module.exports = function (obj, args) { @@ -4911,7 +5307,7 @@ module.exports = function (obj, args) { return negate ? !expr : expr; }; -},{"./flag":12}],28:[function(require,module,exports){ +},{"./flag":13}],29:[function(require,module,exports){ /*! * Chai - transferFlags utility * Copyright(c) 2012-2014 Jake Luer @@ -4936,6 +5332,7 @@ module.exports = function (obj, args) { * @param {Assertion} assertion the assertion to transfer the flags from * @param {Object} object the object to transfer the flags to; usually a new assertion * @param {Boolean} includeAll + * @namespace Utils * @name transferFlags * @api private */ @@ -4957,7 +5354,7 @@ module.exports = function (assertion, object, includeAll) { } }; -},{}],29:[function(require,module,exports){ +},{}],30:[function(require,module,exports){ /*! * assertion-error * Copyright(c) 2013 Jake Luer @@ -5071,10 +5468,10 @@ AssertionError.prototype.toJSON = function (stack) { return props; }; -},{}],30:[function(require,module,exports){ +},{}],31:[function(require,module,exports){ module.exports = require('./lib/eql'); -},{"./lib/eql":31}],31:[function(require,module,exports){ +},{"./lib/eql":32}],32:[function(require,module,exports){ /*! * deep-eql * Copyright(c) 2013 Jake Luer @@ -5333,10 +5730,10 @@ function objectEqual(a, b, m) { return true; } -},{"buffer":undefined,"type-detect":32}],32:[function(require,module,exports){ +},{"buffer":undefined,"type-detect":33}],33:[function(require,module,exports){ module.exports = require('./lib/type'); -},{"./lib/type":33}],33:[function(require,module,exports){ +},{"./lib/type":34}],34:[function(require,module,exports){ /*! * type-detect * Copyright(c) 2013 jake luer @@ -5480,9 +5877,9 @@ Library.prototype.test = function (obj, type) { } }; -},{}],34:[function(require,module,exports){ -arguments[4][32][0].apply(exports,arguments) -},{"./lib/type":35,"dup":32}],35:[function(require,module,exports){ +},{}],35:[function(require,module,exports){ +arguments[4][33][0].apply(exports,arguments) +},{"./lib/type":36,"dup":33}],36:[function(require,module,exports){ /*! * type-detect * Copyright(c) 2013 jake luer diff --git a/tests/bower_components/chai/package.json b/tests/bower_components/chai/package.json index f6eb3ed..2cb4777 100644 --- a/tests/bower_components/chai/package.json +++ b/tests/bower_components/chai/package.json @@ -17,7 +17,7 @@ "Veselin Todorov ", "John Firebaugh " ], - "version": "3.2.0", + "version": "3.4.2", "repository": { "type": "git", "url": "https://github.com/chaijs/chai" diff --git a/tests/bower_components/mocha/.bower.json b/tests/bower_components/mocha/.bower.json index 4cc7bc3..9d58d0e 100644 --- a/tests/bower_components/mocha/.bower.json +++ b/tests/bower_components/mocha/.bower.json @@ -43,12 +43,12 @@ "tap" ], "license": "MIT", - "version": "2.3.0", - "_release": "2.3.0", + "version": "2.3.4", + "_release": "2.3.4", "_resolution": { "type": "version", - "tag": "2.3.0", - "commit": "236c7ea3e03221adfe5ad1e27d28607bab2a987d" + "tag": "2.3.4", + "commit": "5cc8bdd26c74fb91e7eea57e7c689b4e4890bc55" }, "_source": "git://github.com/mochajs/mocha.git", "_target": "*", diff --git a/tests/bower_components/mocha/HISTORY.md b/tests/bower_components/mocha/HISTORY.md index c23cc39..5a9a363 100644 --- a/tests/bower_components/mocha/HISTORY.md +++ b/tests/bower_components/mocha/HISTORY.md @@ -1,4 +1,51 @@ +2.3.4 / 2015-11-15 +================== + + * Update debug dependency to 2.2.0 + * remove duplication of mocha.opts on process.argv + * Fix typo in test/reporters/nyan.js + +2.3.3 / 2015-09-19 +================== + + * [#1875] - Fix Markdown reporter exceeds maximum call stack size ([@danielstjules]) + * [#1864] - Fix xunit missing output with --reporter-options output ([@danielstjules]) + * [#1846] - Support all harmony flags ([@danielstjules]) + * Fix fragile xunit reporter spec ([@danielstjules]) + * [#1669] - Fix catch uncaught errors outside test suite execution ([@danielstjules]) + * [#1868] - Revert jade to support npm < v1.3.7 ([@danielstjules]) + * [#1766] - Don't remove modules/components from stack trace in the browser ([@danielstjules]) + * [#1798] - Fix correctly attribute mutiple done err with hooks ([@danielstjules]) + * Fix use utils.reduce for IE8 compatibility ([@wsw0108]) + * Some linting errors fixed by [@danielstjules] + * Call the inspect() function if message is not set ([@kevinburke]) + +[#1875]: https://github.com/mochajs/mocha/issues/1875 +[#1864]: https://github.com/mochajs/mocha/issues/1864 +[#1846]: https://github.com/mochajs/mocha/issues/1846 +[#1669]: https://github.com/mochajs/mocha/issues/1669 +[#1868]: https://github.com/mochajs/mocha/issues/1868 +[#1766]: https://github.com/mochajs/mocha/issues/1766 +[#1798]: https://github.com/mochajs/mocha/issues/1798 +[@danielstjules]: https://github.com/danielstjules +[@wsw0108]: https://github.com/wsw0108 +[@kevinburke]: https://github.com/kevinburke + +2.3.2 / 2015-09-07 +================== + * [#1868] - Fix compatibility with older versions of NPM ([@boneskull]) + + [#1868]: https://github.com/mochajs/mocha/issues/1868 + +2.3.1 / 2015-09-06 +================== + + * [#1812] - Fix: Bail flag causes before() hooks to be run even after a failure ([@aaroncrows]) + + [#1812]: https://github.com/mochajs/mocha/issues/1812 + [aaroncrows]: https://github.com/aaroncrows + 2.3.0 / 2015-08-30 ================== @@ -10,7 +57,7 @@ * [#1230] - More descriptive beforeEach/afterEach messages ([@duncanbeevers]) * [#1787] - Scope loading behaviour instead of using early return ([@aryeguy]) * [#1789] - Fix: html-runner crashing ([@sunesimonsen]) - * [#1749] - Fix maximum call stack error on large amount of tests ([@tinganho]) + * [#1749] - Fix maximum call stack error on large amount of tests ([@tinganho]) * [#1230] - Decorate failed hook titles with test title ([@duncanbeevers]) * [#1260] - Build using Browserify ([@ndhoule]) * [#1728] - Don't use `__proto__` ([@ndhoule]) @@ -19,7 +66,7 @@ * [#1766] - Fix overly aggressive stack suppression ([@moll]) * [#1752] - Avoid potential infinite loop ([@gsilk]) * [#1761] - Fix problems running under PhantomJS ([@chromakode]) - * [#1700] - Fix more problems running under PhantomJS ([@jbnicolai]) + * [#1700] - Fix more problems running under PhantomJS ([@jbnicolai]) * [#1774] - Support escaped spaces in CLI options ([@adamgruber]) * [#1687] - Fix HTML reporter links with special chars ([@benvinegar]) * [#1359] - Adopt code style and enforce it using ESLint ([@ndhoule] w/ assist from [@jbnicolai] & [@boneskull]) diff --git a/tests/bower_components/mocha/mocha.js b/tests/bower_components/mocha/mocha.js index 83e091b..7c925f7 100644 --- a/tests/bower_components/mocha/mocha.js +++ b/tests/bower_components/mocha/mocha.js @@ -5,7 +5,7 @@ module.exports = process.env.COV : require('./lib/mocha'); }).call(this,require('_process')) -},{"./lib-cov/mocha":undefined,"./lib/mocha":14,"_process":51}],2:[function(require,module,exports){ +},{"./lib-cov/mocha":undefined,"./lib/mocha":14,"_process":52}],2:[function(require,module,exports){ /* eslint-disable no-unused-vars */ module.exports = function(type) { return function() {}; @@ -437,7 +437,7 @@ Context.prototype.inspect = function() { */ var Runnable = require('./runnable'); -var create = require('lodash.create'); +var inherits = require('./utils').inherits; /** * Expose `Hook`. @@ -460,10 +460,7 @@ function Hook(title, fn) { /** * Inherit from `Runnable.prototype`. */ - -Hook.prototype = create(Runnable.prototype, { - constructor: Hook -}); +inherits(Hook, Runnable); /** * Get or set the test `err`. @@ -482,7 +479,7 @@ Hook.prototype.error = function(err) { this._error = err; }; -},{"./runnable":35,"lodash.create":70}],8:[function(require,module,exports){ +},{"./runnable":35,"./utils":39}],8:[function(require,module,exports){ /** * Module dependencies. */ @@ -594,7 +591,7 @@ module.exports = function(suite) { }); }; -},{"../suite":37,"../test":38,"./common":9,"escape-string-regexp":68}],9:[function(require,module,exports){ +},{"../suite":37,"../test":38,"./common":9,"escape-string-regexp":69}],9:[function(require,module,exports){ 'use strict'; /** @@ -836,7 +833,7 @@ module.exports = function(suite) { }); }; -},{"../suite":37,"../test":38,"./common":9,"escape-string-regexp":68}],13:[function(require,module,exports){ +},{"../suite":37,"../test":38,"./common":9,"escape-string-regexp":69}],13:[function(require,module,exports){ /** * Module dependencies. */ @@ -943,7 +940,7 @@ module.exports = function(suite) { }); }; -},{"../suite":37,"../test":38,"./common":9,"escape-string-regexp":68}],14:[function(require,module,exports){ +},{"../suite":37,"../test":38,"./common":9,"escape-string-regexp":69}],14:[function(require,module,exports){ (function (process,global,__dirname){ /*! * mocha @@ -1032,7 +1029,7 @@ function Mocha(options) { this.ui(options.ui); this.bail(options.bail); this.reporter(options.reporter, options.reporterOptions); - if (options.timeout != null) { + if (typeof options.timeout !== 'undefined' && options.timeout !== null) { this.timeout(options.timeout); } this.useColors(options.useColors); @@ -1434,7 +1431,7 @@ Mocha.prototype.run = function(fn) { }; }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},"/lib") -},{"./context":6,"./hook":7,"./interfaces":11,"./reporters":22,"./runnable":35,"./runner":36,"./suite":37,"./test":38,"./utils":39,"_process":51,"escape-string-regexp":68,"growl":69,"path":41}],15:[function(require,module,exports){ +},{"./context":6,"./hook":7,"./interfaces":11,"./reporters":22,"./runnable":35,"./runner":36,"./suite":37,"./test":38,"./utils":39,"_process":52,"escape-string-regexp":69,"growl":70,"path":41}],15:[function(require,module,exports){ /** * Helpers. */ @@ -1754,7 +1751,14 @@ exports.list = function(failures) { // msg var msg; var err = test.err; - var message = err.message || ''; + var message; + if (err.message) { + message = err.message; + } else if (typeof err.inspect === 'function') { + message = err.inspect() + ''; + } else { + message = ''; + } var stack = err.stack || message; var index = stack.indexOf(message); var actual = err.actual; @@ -1986,7 +1990,7 @@ function unifiedDiff(err, escape) { return indent + line; } function notBlank(line) { - return line != null; + return typeof line !== 'undefined' && line !== null; } var msg = diff.createPatch('string', err.actual, err.expected); var lines = msg.split('\n').splice(4); @@ -2065,7 +2069,7 @@ function sameType(a, b) { } }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"../ms":15,"../utils":39,"_process":51,"diff":67,"supports-color":41,"tty":5}],18:[function(require,module,exports){ +},{"../ms":15,"../utils":39,"_process":52,"diff":68,"supports-color":41,"tty":5}],18:[function(require,module,exports){ /** * Module dependencies. */ @@ -2136,7 +2140,7 @@ function Doc(runner) { */ var Base = require('./base'); -var create = require('lodash.create'); +var inherits = require('../utils').inherits; var color = Base.color; /** @@ -2196,13 +2200,10 @@ function Dot(runner) { /** * Inherit from `Base.prototype`. */ - -Dot.prototype = create(Base.prototype, { - constructor: Dot -}); +inherits(Dot, Base); }).call(this,require('_process')) -},{"./base":17,"_process":51,"lodash.create":70}],20:[function(require,module,exports){ +},{"../utils":39,"./base":17,"_process":52}],20:[function(require,module,exports){ (function (process,__dirname){ /** * Module dependencies. @@ -2262,7 +2263,7 @@ function coverageClass(coveragePctg) { } }).call(this,require('_process'),"/lib/reporters") -},{"./json-cov":23,"_process":51,"fs":41,"jade":41,"path":41}],21:[function(require,module,exports){ +},{"./json-cov":23,"_process":52,"fs":41,"jade":41,"path":41}],21:[function(require,module,exports){ (function (global){ /* eslint-env browser */ @@ -2592,7 +2593,7 @@ function on(el, event, fn) { } }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"../browser/progress":4,"../utils":39,"./base":17,"escape-string-regexp":68}],22:[function(require,module,exports){ +},{"../browser/progress":4,"../utils":39,"./base":17,"escape-string-regexp":69}],22:[function(require,module,exports){ // Alias exports to a their normalized format Mocha#reporter to prevent a need // for dynamic (try/catch) requires, which Browserify doesn't handle. exports.Base = exports.base = require('./base'); @@ -2767,7 +2768,7 @@ function clean(test) { } }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./base":17,"_process":51}],24:[function(require,module,exports){ +},{"./base":17,"_process":52}],24:[function(require,module,exports){ (function (process){ /** * Module dependencies. @@ -2830,7 +2831,7 @@ function clean(test) { } }).call(this,require('_process')) -},{"./base":17,"_process":51}],25:[function(require,module,exports){ +},{"./base":17,"_process":52}],25:[function(require,module,exports){ (function (process){ /** * Module dependencies. @@ -2923,14 +2924,14 @@ function errorJSON(err) { } }).call(this,require('_process')) -},{"./base":17,"_process":51}],26:[function(require,module,exports){ +},{"./base":17,"_process":52}],26:[function(require,module,exports){ (function (process){ /** * Module dependencies. */ var Base = require('./base'); -var create = require('lodash.create'); +var inherits = require('../utils').inherits; var cursor = Base.cursor; var color = Base.color; @@ -3016,20 +3017,17 @@ function Landing(runner) { /** * Inherit from `Base.prototype`. */ - -Landing.prototype = create(Base.prototype, { - constructor: Landing -}); +inherits(Landing, Base); }).call(this,require('_process')) -},{"./base":17,"_process":51,"lodash.create":70}],27:[function(require,module,exports){ +},{"../utils":39,"./base":17,"_process":52}],27:[function(require,module,exports){ (function (process){ /** * Module dependencies. */ var Base = require('./base'); -var create = require('lodash.create'); +var inherits = require('../utils').inherits; var color = Base.color; var cursor = Base.cursor; @@ -3084,13 +3082,10 @@ function List(runner) { /** * Inherit from `Base.prototype`. */ - -List.prototype = create(Base.prototype, { - constructor: List -}); +inherits(List, Base); }).call(this,require('_process')) -},{"./base":17,"_process":51,"lodash.create":70}],28:[function(require,module,exports){ +},{"../utils":39,"./base":17,"_process":52}],28:[function(require,module,exports){ (function (process){ /** * Module dependencies. @@ -3132,7 +3127,7 @@ function Markdown(runner) { var key = SUITE_PREFIX + suite.title; obj = obj[key] = obj[key] || { suite: suite }; - suite.suites.forEach(function() { + suite.suites.forEach(function(suite) { mapTOC(suite, obj); }); @@ -3191,14 +3186,14 @@ function Markdown(runner) { } }).call(this,require('_process')) -},{"../utils":39,"./base":17,"_process":51}],29:[function(require,module,exports){ +},{"../utils":39,"./base":17,"_process":52}],29:[function(require,module,exports){ (function (process){ /** * Module dependencies. */ var Base = require('./base'); -var create = require('lodash.create'); +var inherits = require('../utils').inherits; /** * Expose `Min`. @@ -3228,20 +3223,17 @@ function Min(runner) { /** * Inherit from `Base.prototype`. */ - -Min.prototype = create(Base.prototype, { - constructor: Min -}); +inherits(Min, Base); }).call(this,require('_process')) -},{"./base":17,"_process":51,"lodash.create":70}],30:[function(require,module,exports){ +},{"../utils":39,"./base":17,"_process":52}],30:[function(require,module,exports){ (function (process){ /** * Module dependencies. */ var Base = require('./base'); -var create = require('lodash.create'); +var inherits = require('../utils').inherits; /** * Expose `Dot`. @@ -3300,10 +3292,7 @@ function NyanCat(runner) { /** * Inherit from `Base.prototype`. */ - -NyanCat.prototype = create(Base.prototype, { - constructor: NyanCat -}); +inherits(NyanCat, Base); /** * Draw the nyan cat @@ -3502,14 +3491,14 @@ function write(string) { } }).call(this,require('_process')) -},{"./base":17,"_process":51,"lodash.create":70}],31:[function(require,module,exports){ +},{"../utils":39,"./base":17,"_process":52}],31:[function(require,module,exports){ (function (process){ /** * Module dependencies. */ var Base = require('./base'); -var create = require('lodash.create'); +var inherits = require('../utils').inherits; var color = Base.color; var cursor = Base.cursor; @@ -3592,19 +3581,16 @@ function Progress(runner, options) { /** * Inherit from `Base.prototype`. */ - -Progress.prototype = create(Base.prototype, { - constructor: Progress -}); +inherits(Progress, Base); }).call(this,require('_process')) -},{"./base":17,"_process":51,"lodash.create":70}],32:[function(require,module,exports){ +},{"../utils":39,"./base":17,"_process":52}],32:[function(require,module,exports){ /** * Module dependencies. */ var Base = require('./base'); -var create = require('lodash.create'); +var inherits = require('../utils').inherits; var color = Base.color; var cursor = Base.cursor; @@ -3681,12 +3667,9 @@ function Spec(runner) { /** * Inherit from `Base.prototype`. */ +inherits(Spec, Base); -Spec.prototype = create(Base.prototype, { - constructor: Spec -}); - -},{"./base":17,"lodash.create":70}],33:[function(require,module,exports){ +},{"../utils":39,"./base":17}],33:[function(require,module,exports){ /** * Module dependencies. */ @@ -3763,9 +3746,10 @@ function title(test) { */ var Base = require('./base'); -var create = require('lodash.create'); +var utils = require('../utils'); +var inherits = utils.inherits; var fs = require('fs'); -var escape = require('../utils').escape; +var escape = utils.escape; /** * Save timer references to avoid Sinon interfering (see GH-237). @@ -3836,6 +3820,11 @@ function XUnit(runner, options) { }); } +/** + * Inherit from `Base.prototype`. + */ +inherits(XUnit, Base); + /** * Override done to close the stream (if it's a file). * @@ -3852,14 +3841,6 @@ XUnit.prototype.done = function(failures, fn) { } }; -/** - * Inherit from `Base.prototype`. - */ - -XUnit.prototype = create(Base.prototype, { - constructor: XUnit -}); - /** * Write out the given line. * @@ -3931,7 +3912,7 @@ function cdata(str) { } }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"../utils":39,"./base":17,"fs":41,"lodash.create":70}],35:[function(require,module,exports){ +},{"../utils":39,"./base":17,"fs":41}],35:[function(require,module,exports){ (function (global){ /** * Module dependencies. @@ -3939,10 +3920,10 @@ function cdata(str) { var EventEmitter = require('events').EventEmitter; var Pending = require('./pending'); -var create = require('lodash.create'); var debug = require('debug')('mocha:runnable'); var milliseconds = require('./ms'); var utils = require('./utils'); +var inherits = utils.inherits; /** * Save timer references to avoid Sinon interfering (see GH-237). @@ -3992,10 +3973,7 @@ function Runnable(title, fn) { /** * Inherit from `EventEmitter.prototype`. */ - -Runnable.prototype = create(EventEmitter.prototype, { - constructor: Runnable -}); +inherits(Runnable, EventEmitter); /** * Set & get timeout `ms`. @@ -4258,7 +4236,7 @@ Runnable.prototype.run = function(fn) { }; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./ms":15,"./pending":16,"./utils":39,"debug":2,"events":3,"lodash.create":70}],36:[function(require,module,exports){ +},{"./ms":15,"./pending":16,"./utils":39,"debug":2,"events":3}],36:[function(require,module,exports){ (function (process,global){ /** * Module dependencies. @@ -4266,15 +4244,17 @@ Runnable.prototype.run = function(fn) { var EventEmitter = require('events').EventEmitter; var Pending = require('./pending'); -var create = require('lodash.create'); +var utils = require('./utils'); +var inherits = utils.inherits; var debug = require('debug')('mocha:runner'); -var filter = require('./utils').filter; -var indexOf = require('./utils').indexOf; -var keys = require('./utils').keys; -var stackFilter = require('./utils').stackTraceFilter(); -var stringify = require('./utils').stringify; -var type = require('./utils').type; -var undefinedError = require('./utils').undefinedError; +var Runnable = require('./runnable'); +var filter = utils.filter; +var indexOf = utils.indexOf; +var keys = utils.keys; +var stackFilter = utils.stackTraceFilter(); +var stringify = utils.stringify; +var type = utils.type; +var undefinedError = utils.undefinedError; /** * Non-enumerable globals. @@ -4325,6 +4305,7 @@ function Runner(suite, delay) { this._abort = false; this._delay = delay; this.suite = suite; + this.started = false; this.total = suite.total(); this.failures = 0; this.on('test end', function(test) { @@ -4349,10 +4330,7 @@ Runner.immediately = global.setImmediate || process.nextTick; /** * Inherit from `EventEmitter.prototype`. */ - -Runner.prototype = create(EventEmitter.prototype, { - constructor: Runner -}); +inherits(Runner, EventEmitter); /** * Run tests with full titles matching `re`. Updates runner.total @@ -4550,12 +4528,13 @@ Runner.prototype.hook = function(name, fn) { self.emit('hook', hook); - hook.on('error', function(err) { - self.failHook(hook, err); - }); + if (!hook.listeners('error').length) { + hook.on('error', function(err) { + self.failHook(hook, err); + }); + } hook.run(function(err) { - hook.removeAllListeners('error'); var testError = hook.error(); if (testError) { self.fail(self.test, testError); @@ -4650,7 +4629,8 @@ Runner.prototype.hookDown = function(name, fn) { Runner.prototype.parents = function() { var suite = this.suite; var suites = []; - while (suite = suite.parent) { + while (suite.parent) { + suite = suite.parent; suites.push(suite); } return suites; @@ -4831,7 +4811,7 @@ Runner.prototype.runSuite = function(suite, fn) { debug('run suite %s', suite.fullTitle()); - if (!total) { + if (!total || (self.failures && suite._bail)) { return fn(); } @@ -4916,7 +4896,20 @@ Runner.prototype.uncaught = function(err) { err.uncaught = true; var runnable = this.currentRunnable; + if (!runnable) { + runnable = new Runnable('Uncaught error outside test suite'); + runnable.parent = this.suite; + + if (this.started) { + this.fail(runnable, err); + } else { + // Can't recover from this failure + this.emit('start'); + this.fail(runnable, err); + this.emit('end'); + } + return; } @@ -4975,6 +4968,7 @@ Runner.prototype.run = function(fn) { } function start() { + self.started = true; self.emit('start'); self.runSuite(rootSuite, function() { debug('finished running'); @@ -5070,7 +5064,8 @@ function filterLeaks(ok, globals) { */ function extraGlobals() { if (typeof process === 'object' && typeof process.version === 'string') { - var nodeVersion = process.version.split('.').reduce(function(a, v) { + var parts = process.version.split('.'); + var nodeVersion = utils.reduce(parts, function(a, v) { return a << 8 | v; }); @@ -5085,17 +5080,17 @@ function extraGlobals() { } }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./pending":16,"./utils":39,"_process":51,"debug":2,"events":3,"lodash.create":70}],37:[function(require,module,exports){ +},{"./pending":16,"./runnable":35,"./utils":39,"_process":52,"debug":2,"events":3}],37:[function(require,module,exports){ /** * Module dependencies. */ var EventEmitter = require('events').EventEmitter; var Hook = require('./hook'); -var create = require('lodash.create'); +var utils = require('./utils'); +var inherits = utils.inherits; var debug = require('debug')('mocha:suite'); var milliseconds = require('./ms'); -var utils = require('./utils'); /** * Expose `Suite`. @@ -5154,10 +5149,7 @@ function Suite(title, parentContext) { /** * Inherit from `EventEmitter.prototype`. */ - -Suite.prototype = create(EventEmitter.prototype, { - constructor: Suite -}); +inherits(Suite, EventEmitter); /** * Return a clone of this `Suite`. @@ -5455,13 +5447,13 @@ Suite.prototype.run = function run() { } }; -},{"./hook":7,"./ms":15,"./utils":39,"debug":2,"events":3,"lodash.create":70}],38:[function(require,module,exports){ +},{"./hook":7,"./ms":15,"./utils":39,"debug":2,"events":3}],38:[function(require,module,exports){ /** * Module dependencies. */ var Runnable = require('./runnable'); -var create = require('lodash.create'); +var inherits = require('./utils').inherits; /** * Expose `Test`. @@ -5485,12 +5477,9 @@ function Test(title, fn) { /** * Inherit from `Runnable.prototype`. */ +inherits(Test, Runnable); -Test.prototype = create(Runnable.prototype, { - constructor: Test -}); - -},{"./runnable":35,"lodash.create":70}],39:[function(require,module,exports){ +},{"./runnable":35,"./utils":39}],39:[function(require,module,exports){ (function (process,Buffer){ /* eslint-env browser */ @@ -5513,6 +5502,8 @@ var watchFile = require('fs').watchFile; var ignore = ['node_modules', '.git']; +exports.inherits = require('util').inherits; + /** * Escape special characters in the given string of html. * @@ -6181,7 +6172,7 @@ exports.getError = function(err) { * @description * When invoking this function you get a filter function that get the Error.stack as an input, * and return a prettify output. - * (i.e: strip Mocha, node_modules, bower and componentJS from stack trace). + * (i.e: strip Mocha and internal node functions from stack trace). * @returns {Function} */ exports.stackTraceFilter = function() { @@ -6193,14 +6184,10 @@ exports.stackTraceFilter = function() { : (typeof location === 'undefined' ? window.location : location).href.replace(/\/[^\/]*$/, '/'); function isMochaInternal(line) { - return (~line.indexOf('node_modules' + slash + 'mocha')) - || (~line.indexOf('components' + slash + 'mochajs')) - || (~line.indexOf('components' + slash + 'mocha')); - } - - // node_modules, bower, componentJS - function isBrowserModule(line) { - return (~line.indexOf('node_modules')) || (~line.indexOf('components')); + return (~line.indexOf('node_modules' + slash + 'mocha' + slash)) + || (~line.indexOf('components' + slash + 'mochajs' + slash)) + || (~line.indexOf('components' + slash + 'mocha' + slash)) + || (~line.indexOf(slash + 'mocha.js')); } function isNodeInternal(line) { @@ -6216,11 +6203,11 @@ exports.stackTraceFilter = function() { stack = stack.split('\n'); stack = exports.reduce(stack, function(list, line) { - if (is.node && (isMochaInternal(line) || isNodeInternal(line))) { + if (isMochaInternal(line)) { return list; } - if (is.browser && (isBrowserModule(line))) { + if (is.node && isNodeInternal(line)) { return list; } @@ -6234,7 +6221,7 @@ exports.stackTraceFilter = function() { }; }).call(this,require('_process'),require("buffer").Buffer) -},{"_process":51,"buffer":43,"debug":2,"fs":41,"glob":41,"path":41}],40:[function(require,module,exports){ +},{"_process":52,"buffer":43,"debug":2,"fs":41,"glob":41,"path":41,"util":67}],40:[function(require,module,exports){ (function (process){ var WritableStream = require('stream').Writable var inherits = require('util').inherits @@ -6263,17 +6250,19 @@ BrowserStdout.prototype._write = function(chunks, encoding, cb) { } }).call(this,require('_process')) -},{"_process":51,"stream":63,"util":66}],41:[function(require,module,exports){ +},{"_process":52,"stream":64,"util":67}],41:[function(require,module,exports){ },{}],42:[function(require,module,exports){ arguments[4][41][0].apply(exports,arguments) },{"dup":41}],43:[function(require,module,exports){ +(function (global){ /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */ +/* eslint-disable no-proto */ var base64 = require('base64-js') var ieee754 = require('ieee754') @@ -6294,32 +6283,43 @@ var rootParent = {} * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, * Opera 11.6+, iOS 4.2+. * + * Due to various browser bugs, sometimes the Object implementation will be used even + * when the browser supports typed arrays. + * * Note: * - * - Implementation must support adding new properties to `Uint8Array` instances. - * Firefox 4-29 lacked support, fixed in Firefox 30+. - * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. + * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, + * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. * - * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. + * - Safari 5-7 lacks support for changing the `Object.prototype.constructor` property + * on objects. * - * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of - * incorrect length in some situations. + * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. * - * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they will - * get the Object implementation, which is slower but will work correctly. + * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of + * incorrect length in some situations. + + * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they + * get the Object implementation, which is slower but behaves correctly. */ -Buffer.TYPED_ARRAY_SUPPORT = (function () { +Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined + ? global.TYPED_ARRAY_SUPPORT + : typedArraySupport() + +function typedArraySupport () { + function Bar () {} try { - var buf = new ArrayBuffer(0) - var arr = new Uint8Array(buf) + var arr = new Uint8Array(1) arr.foo = function () { return 42 } + arr.constructor = Bar return arr.foo() === 42 && // typed array instances can be augmented + arr.constructor === Bar && // constructor can be set typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` - new Uint8Array(1).subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` + arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` } catch (e) { return false } -})() +} function kMaxLength () { return Buffer.TYPED_ARRAY_SUPPORT @@ -6393,8 +6393,13 @@ function fromObject (that, object) { throw new TypeError('must start with number, buffer, array or string') } - if (typeof ArrayBuffer !== 'undefined' && object.buffer instanceof ArrayBuffer) { - return fromTypedArray(that, object) + if (typeof ArrayBuffer !== 'undefined') { + if (object.buffer instanceof ArrayBuffer) { + return fromTypedArray(that, object) + } + if (object instanceof ArrayBuffer) { + return fromArrayBuffer(that, object) + } } if (object.length) return fromArrayLike(that, object) @@ -6431,6 +6436,18 @@ function fromTypedArray (that, array) { return that } +function fromArrayBuffer (that, array) { + if (Buffer.TYPED_ARRAY_SUPPORT) { + // Return an augmented `Uint8Array` instance, for best performance + array.byteLength + that = Buffer._augment(new Uint8Array(array)) + } else { + // Fallback: Return an object instance of the Buffer class + that = fromTypedArray(that, new Uint8Array(array)) + } + return that +} + function fromArrayLike (that, array) { var length = checked(array.length) | 0 that = allocate(that, length) @@ -6458,10 +6475,16 @@ function fromJsonObject (that, object) { return that } +if (Buffer.TYPED_ARRAY_SUPPORT) { + Buffer.prototype.__proto__ = Uint8Array.prototype + Buffer.__proto__ = Uint8Array +} + function allocate (that, length) { if (Buffer.TYPED_ARRAY_SUPPORT) { // Return an augmented `Uint8Array` instance, for best performance that = Buffer._augment(new Uint8Array(length)) + that.__proto__ = Buffer.prototype } else { // Fallback: Return an object instance of the Buffer class that.length = length @@ -6548,8 +6571,6 @@ Buffer.concat = function concat (list, length) { if (list.length === 0) { return new Buffer(0) - } else if (list.length === 1) { - return list[0] } var i @@ -6724,13 +6745,13 @@ Buffer.prototype.indexOf = function indexOf (val, byteOffset) { throw new TypeError('val must be string, number or Buffer') } -// `get` will be removed in Node 0.13+ +// `get` is deprecated Buffer.prototype.get = function get (offset) { console.log('.get() is deprecated. Access using array indexes instead.') return this.readUInt8(offset) } -// `set` will be removed in Node 0.13+ +// `set` is deprecated Buffer.prototype.set = function set (v, offset) { console.log('.set() is deprecated. Access using array indexes instead.') return this.writeUInt8(v, offset) @@ -6871,20 +6892,99 @@ function base64Slice (buf, start, end) { } function utf8Slice (buf, start, end) { - var res = '' - var tmp = '' end = Math.min(buf.length, end) + var res = [] + + var i = start + while (i < end) { + var firstByte = buf[i] + var codePoint = null + var bytesPerSequence = (firstByte > 0xEF) ? 4 + : (firstByte > 0xDF) ? 3 + : (firstByte > 0xBF) ? 2 + : 1 + + if (i + bytesPerSequence <= end) { + var secondByte, thirdByte, fourthByte, tempCodePoint + + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte + } + break + case 2: + secondByte = buf[i + 1] + if ((secondByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) + if (tempCodePoint > 0x7F) { + codePoint = tempCodePoint + } + } + break + case 3: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { + codePoint = tempCodePoint + } + } + break + case 4: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + fourthByte = buf[i + 3] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) + if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { + codePoint = tempCodePoint + } + } + } + } - for (var i = start; i < end; i++) { - if (buf[i] <= 0x7F) { - res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i]) - tmp = '' - } else { - tmp += '%' + buf[i].toString(16) + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xFFFD + bytesPerSequence = 1 + } else if (codePoint > 0xFFFF) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000 + res.push(codePoint >>> 10 & 0x3FF | 0xD800) + codePoint = 0xDC00 | codePoint & 0x3FF } + + res.push(codePoint) + i += bytesPerSequence } - return res + decodeUtf8Char(tmp) + return decodeCodePointsArray(res) +} + +// Based on http://stackoverflow.com/a/22747272/680742, the browser with +// the lowest limit is Chrome, with 0x10000 args. +// We go 1 magnitude less, for safety +var MAX_ARGUMENTS_LENGTH = 0x1000 + +function decodeCodePointsArray (codePoints) { + var len = codePoints.length + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints) // avoid extra slice() + } + + // Decode in chunks to avoid "call stack size exceeded". + var res = '' + var i = 0 + while (i < len) { + res += String.fromCharCode.apply( + String, + codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) + ) + } + return res } function asciiSlice (buf, start, end) { @@ -7173,7 +7273,7 @@ Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { offset = offset | 0 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) - this[offset] = value + this[offset] = (value & 0xff) return offset + 1 } @@ -7190,7 +7290,7 @@ Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert offset = offset | 0 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = value + this[offset] = (value & 0xff) this[offset + 1] = (value >>> 8) } else { objectWriteUInt16(this, value, offset, true) @@ -7204,7 +7304,7 @@ Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) if (Buffer.TYPED_ARRAY_SUPPORT) { this[offset] = (value >>> 8) - this[offset + 1] = value + this[offset + 1] = (value & 0xff) } else { objectWriteUInt16(this, value, offset, false) } @@ -7226,7 +7326,7 @@ Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert this[offset + 3] = (value >>> 24) this[offset + 2] = (value >>> 16) this[offset + 1] = (value >>> 8) - this[offset] = value + this[offset] = (value & 0xff) } else { objectWriteUInt32(this, value, offset, true) } @@ -7241,7 +7341,7 @@ Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert this[offset] = (value >>> 24) this[offset + 1] = (value >>> 16) this[offset + 2] = (value >>> 8) - this[offset + 3] = value + this[offset + 3] = (value & 0xff) } else { objectWriteUInt32(this, value, offset, false) } @@ -7294,7 +7394,7 @@ Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) if (value < 0) value = 0xff + value + 1 - this[offset] = value + this[offset] = (value & 0xff) return offset + 1 } @@ -7303,7 +7403,7 @@ Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) offset = offset | 0 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = value + this[offset] = (value & 0xff) this[offset + 1] = (value >>> 8) } else { objectWriteUInt16(this, value, offset, true) @@ -7317,7 +7417,7 @@ Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) if (Buffer.TYPED_ARRAY_SUPPORT) { this[offset] = (value >>> 8) - this[offset + 1] = value + this[offset + 1] = (value & 0xff) } else { objectWriteUInt16(this, value, offset, false) } @@ -7329,7 +7429,7 @@ Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) offset = offset | 0 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = value + this[offset] = (value & 0xff) this[offset + 1] = (value >>> 8) this[offset + 2] = (value >>> 16) this[offset + 3] = (value >>> 24) @@ -7348,7 +7448,7 @@ Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) this[offset] = (value >>> 24) this[offset + 1] = (value >>> 16) this[offset + 2] = (value >>> 8) - this[offset + 3] = value + this[offset + 3] = (value & 0xff) } else { objectWriteUInt32(this, value, offset, false) } @@ -7419,9 +7519,16 @@ Buffer.prototype.copy = function copy (target, targetStart, start, end) { } var len = end - start + var i - if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { - for (var i = 0; i < len; i++) { + if (this === target && start < targetStart && targetStart < end) { + // descending copy from end + for (i = len - 1; i >= 0; i--) { + target[i + targetStart] = this[i + start] + } + } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { + // ascending copy from start + for (i = 0; i < len; i++) { target[i + targetStart] = this[i + start] } } else { @@ -7497,7 +7604,7 @@ Buffer._augment = function _augment (arr) { // save reference to original Uint8Array set method before overwriting arr._set = arr.set - // deprecated, will be removed in node 0.13+ + // deprecated arr.get = BP.get arr.set = BP.set @@ -7553,7 +7660,7 @@ Buffer._augment = function _augment (arr) { return arr } -var INVALID_BASE64_RE = /[^+\/0-9A-z\-]/g +var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g function base64clean (str) { // Node strips out invalid characters like \n and \t from the string, base64-js does not @@ -7583,28 +7690,15 @@ function utf8ToBytes (string, units) { var length = string.length var leadSurrogate = null var bytes = [] - var i = 0 - for (; i < length; i++) { + for (var i = 0; i < length; i++) { codePoint = string.charCodeAt(i) // is surrogate component if (codePoint > 0xD7FF && codePoint < 0xE000) { // last char was a lead - if (leadSurrogate) { - // 2 leads in a row - if (codePoint < 0xDC00) { - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - leadSurrogate = codePoint - continue - } else { - // valid surrogate pair - codePoint = leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 | 0x10000 - leadSurrogate = null - } - } else { + if (!leadSurrogate) { // no lead yet - if (codePoint > 0xDBFF) { // unexpected trail if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) @@ -7613,18 +7707,30 @@ function utf8ToBytes (string, units) { // unpaired lead if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) continue - } else { - // valid lead - leadSurrogate = codePoint - continue } + + // valid lead + leadSurrogate = codePoint + + continue } + + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = codePoint + continue + } + + // valid surrogate pair + codePoint = leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 | 0x10000 } else if (leadSurrogate) { // valid bmp char, but last char was a lead if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - leadSurrogate = null } + leadSurrogate = null + // encode utf8 if (codePoint < 0x80) { if ((units -= 1) < 0) break @@ -7642,7 +7748,7 @@ function utf8ToBytes (string, units) { codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80 ) - } else if (codePoint < 0x200000) { + } else if (codePoint < 0x110000) { if ((units -= 4) < 0) break bytes.push( codePoint >> 0x12 | 0xF0, @@ -7695,14 +7801,7 @@ function blitBuffer (src, dst, offset, length) { return i } -function decodeUtf8Char (str) { - try { - return decodeURIComponent(str) - } catch (err) { - return String.fromCharCode(0xFFFD) // UTF 8 invalid char - } -} - +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"base64-js":44,"ieee754":45,"is-array":46}],44:[function(require,module,exports){ var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; @@ -8279,11 +8378,30 @@ if (typeof Object.create === 'function') { } },{}],49:[function(require,module,exports){ +/** + * Determine if an object is Buffer + * + * Author: Feross Aboukhadijeh + * License: MIT + * + * `npm install is-buffer` + */ + +module.exports = function (obj) { + return !!(obj != null && + (obj._isBuffer || // For Safari 5-7 (missing Object.prototype.constructor) + (obj.constructor && + typeof obj.constructor.isBuffer === 'function' && + obj.constructor.isBuffer(obj)) + )) +} + +},{}],50:[function(require,module,exports){ module.exports = Array.isArray || function (arr) { return Object.prototype.toString.call(arr) == '[object Array]'; }; -},{}],50:[function(require,module,exports){ +},{}],51:[function(require,module,exports){ exports.endianness = function () { return 'LE' }; exports.hostname = function () { @@ -8330,7 +8448,7 @@ exports.tmpdir = exports.tmpDir = function () { exports.EOL = '\n'; -},{}],51:[function(require,module,exports){ +},{}],52:[function(require,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -8363,7 +8481,9 @@ function drainQueue() { currentQueue = queue; queue = []; while (++queueIndex < len) { - currentQueue[queueIndex].run(); + if (currentQueue) { + currentQueue[queueIndex].run(); + } } queueIndex = -1; len = queue.length; @@ -8415,17 +8535,16 @@ process.binding = function (name) { throw new Error('process.binding is not supported'); }; -// TODO(shtylman) process.cwd = function () { return '/' }; process.chdir = function (dir) { throw new Error('process.chdir is not supported'); }; process.umask = function() { return 0; }; -},{}],52:[function(require,module,exports){ +},{}],53:[function(require,module,exports){ module.exports = require("./lib/_stream_duplex.js") -},{"./lib/_stream_duplex.js":53}],53:[function(require,module,exports){ +},{"./lib/_stream_duplex.js":54}],54:[function(require,module,exports){ (function (process){ // Copyright Joyent, Inc. and other Node contributors. // @@ -8518,7 +8637,7 @@ function forEach (xs, f) { } }).call(this,require('_process')) -},{"./_stream_readable":55,"./_stream_writable":57,"_process":51,"core-util-is":58,"inherits":48}],54:[function(require,module,exports){ +},{"./_stream_readable":56,"./_stream_writable":58,"_process":52,"core-util-is":59,"inherits":48}],55:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -8566,7 +8685,7 @@ PassThrough.prototype._transform = function(chunk, encoding, cb) { cb(null, chunk); }; -},{"./_stream_transform":56,"core-util-is":58,"inherits":48}],55:[function(require,module,exports){ +},{"./_stream_transform":57,"core-util-is":59,"inherits":48}],56:[function(require,module,exports){ (function (process){ // Copyright Joyent, Inc. and other Node contributors. // @@ -9521,7 +9640,7 @@ function indexOf (xs, x) { } }).call(this,require('_process')) -},{"./_stream_duplex":53,"_process":51,"buffer":43,"core-util-is":58,"events":47,"inherits":48,"isarray":49,"stream":63,"string_decoder/":64,"util":42}],56:[function(require,module,exports){ +},{"./_stream_duplex":54,"_process":52,"buffer":43,"core-util-is":59,"events":47,"inherits":48,"isarray":50,"stream":64,"string_decoder/":65,"util":42}],57:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -9732,7 +9851,7 @@ function done(stream, er) { return stream.push(null); } -},{"./_stream_duplex":53,"core-util-is":58,"inherits":48}],57:[function(require,module,exports){ +},{"./_stream_duplex":54,"core-util-is":59,"inherits":48}],58:[function(require,module,exports){ (function (process){ // Copyright Joyent, Inc. and other Node contributors. // @@ -10213,7 +10332,7 @@ function endWritable(stream, state, cb) { } }).call(this,require('_process')) -},{"./_stream_duplex":53,"_process":51,"buffer":43,"core-util-is":58,"inherits":48,"stream":63}],58:[function(require,module,exports){ +},{"./_stream_duplex":54,"_process":52,"buffer":43,"core-util-is":59,"inherits":48,"stream":64}],59:[function(require,module,exports){ (function (Buffer){ // Copyright Joyent, Inc. and other Node contributors. // @@ -10322,11 +10441,11 @@ exports.isBuffer = isBuffer; function objectToString(o) { return Object.prototype.toString.call(o); } -}).call(this,require("buffer").Buffer) -},{"buffer":43}],59:[function(require,module,exports){ +}).call(this,{"isBuffer":require("../../../../insert-module-globals/node_modules/is-buffer/index.js")}) +},{"../../../../insert-module-globals/node_modules/is-buffer/index.js":49}],60:[function(require,module,exports){ module.exports = require("./lib/_stream_passthrough.js") -},{"./lib/_stream_passthrough.js":54}],60:[function(require,module,exports){ +},{"./lib/_stream_passthrough.js":55}],61:[function(require,module,exports){ exports = module.exports = require('./lib/_stream_readable.js'); exports.Stream = require('stream'); exports.Readable = exports; @@ -10335,13 +10454,13 @@ exports.Duplex = require('./lib/_stream_duplex.js'); exports.Transform = require('./lib/_stream_transform.js'); exports.PassThrough = require('./lib/_stream_passthrough.js'); -},{"./lib/_stream_duplex.js":53,"./lib/_stream_passthrough.js":54,"./lib/_stream_readable.js":55,"./lib/_stream_transform.js":56,"./lib/_stream_writable.js":57,"stream":63}],61:[function(require,module,exports){ +},{"./lib/_stream_duplex.js":54,"./lib/_stream_passthrough.js":55,"./lib/_stream_readable.js":56,"./lib/_stream_transform.js":57,"./lib/_stream_writable.js":58,"stream":64}],62:[function(require,module,exports){ module.exports = require("./lib/_stream_transform.js") -},{"./lib/_stream_transform.js":56}],62:[function(require,module,exports){ +},{"./lib/_stream_transform.js":57}],63:[function(require,module,exports){ module.exports = require("./lib/_stream_writable.js") -},{"./lib/_stream_writable.js":57}],63:[function(require,module,exports){ +},{"./lib/_stream_writable.js":58}],64:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -10470,7 +10589,7 @@ Stream.prototype.pipe = function(dest, options) { return dest; }; -},{"events":47,"inherits":48,"readable-stream/duplex.js":52,"readable-stream/passthrough.js":59,"readable-stream/readable.js":60,"readable-stream/transform.js":61,"readable-stream/writable.js":62}],64:[function(require,module,exports){ +},{"events":47,"inherits":48,"readable-stream/duplex.js":53,"readable-stream/passthrough.js":60,"readable-stream/readable.js":61,"readable-stream/transform.js":62,"readable-stream/writable.js":63}],65:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -10693,14 +10812,14 @@ function base64DetectIncompleteChar(buffer) { this.charLength = this.charReceived ? 3 : 0; } -},{"buffer":43}],65:[function(require,module,exports){ +},{"buffer":43}],66:[function(require,module,exports){ module.exports = function isBuffer(arg) { return arg && typeof arg === 'object' && typeof arg.copy === 'function' && typeof arg.fill === 'function' && typeof arg.readUInt8 === 'function'; } -},{}],66:[function(require,module,exports){ +},{}],67:[function(require,module,exports){ (function (process,global){ // Copyright Joyent, Inc. and other Node contributors. // @@ -11290,7 +11409,7 @@ function hasOwnProperty(obj, prop) { } }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./support/isBuffer":65,"_process":51,"inherits":48}],67:[function(require,module,exports){ +},{"./support/isBuffer":66,"_process":52,"inherits":48}],68:[function(require,module,exports){ /* See LICENSE file for terms of use */ /* @@ -11911,7 +12030,7 @@ function hasOwnProperty(obj, prop) { } }(this)); -},{}],68:[function(require,module,exports){ +},{}],69:[function(require,module,exports){ 'use strict'; var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g; @@ -11924,7 +12043,7 @@ module.exports = function (str) { return str.replace(matchOperatorsRe, '\\$&'); }; -},{}],69:[function(require,module,exports){ +},{}],70:[function(require,module,exports){ (function (process){ // Growl - Copyright TJ Holowaychuk (MIT Licensed) @@ -12162,987 +12281,7 @@ function growl(msg, options, fn) { }; }).call(this,require('_process')) -},{"_process":51,"child_process":41,"fs":41,"os":50,"path":41}],70:[function(require,module,exports){ -/** - * lodash 3.1.1 (Custom Build) - * Build: `lodash modern modularize exports="npm" -o ./` - * Copyright 2012-2015 The Dojo Foundation - * Based on Underscore.js 1.8.3 - * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - * Available under MIT license - */ -var baseAssign = require('lodash._baseassign'), - baseCreate = require('lodash._basecreate'), - isIterateeCall = require('lodash._isiterateecall'); - -/** - * Creates an object that inherits from the given `prototype` object. If a - * `properties` object is provided its own enumerable properties are assigned - * to the created object. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} prototype The object to inherit from. - * @param {Object} [properties] The properties to assign to the object. - * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {Object} Returns the new object. - * @example - * - * function Shape() { - * this.x = 0; - * this.y = 0; - * } - * - * function Circle() { - * Shape.call(this); - * } - * - * Circle.prototype = _.create(Shape.prototype, { - * 'constructor': Circle - * }); - * - * var circle = new Circle; - * circle instanceof Circle; - * // => true - * - * circle instanceof Shape; - * // => true - */ -function create(prototype, properties, guard) { - var result = baseCreate(prototype); - if (guard && isIterateeCall(prototype, properties, guard)) { - properties = undefined; - } - return properties ? baseAssign(result, properties) : result; -} - -module.exports = create; - -},{"lodash._baseassign":71,"lodash._basecreate":77,"lodash._isiterateecall":78}],71:[function(require,module,exports){ -/** - * lodash 3.2.0 (Custom Build) - * Build: `lodash modern modularize exports="npm" -o ./` - * Copyright 2012-2015 The Dojo Foundation - * Based on Underscore.js 1.8.3 - * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - * Available under MIT license - */ -var baseCopy = require('lodash._basecopy'), - keys = require('lodash.keys'); - -/** - * The base implementation of `_.assign` without support for argument juggling, - * multiple sources, and `customizer` functions. - * - * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @returns {Object} Returns `object`. - */ -function baseAssign(object, source) { - return source == null - ? object - : baseCopy(source, keys(source), object); -} - -module.exports = baseAssign; - -},{"lodash._basecopy":72,"lodash.keys":73}],72:[function(require,module,exports){ -/** - * lodash 3.0.1 (Custom Build) - * Build: `lodash modern modularize exports="npm" -o ./` - * Copyright 2012-2015 The Dojo Foundation - * Based on Underscore.js 1.8.3 - * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - * Available under MIT license - */ - -/** - * Copies properties of `source` to `object`. - * - * @private - * @param {Object} source The object to copy properties from. - * @param {Array} props The property names to copy. - * @param {Object} [object={}] The object to copy properties to. - * @returns {Object} Returns `object`. - */ -function baseCopy(source, props, object) { - object || (object = {}); - - var index = -1, - length = props.length; - - while (++index < length) { - var key = props[index]; - object[key] = source[key]; - } - return object; -} - -module.exports = baseCopy; - -},{}],73:[function(require,module,exports){ -/** - * lodash 3.1.2 (Custom Build) - * Build: `lodash modern modularize exports="npm" -o ./` - * Copyright 2012-2015 The Dojo Foundation - * Based on Underscore.js 1.8.3 - * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - * Available under MIT license - */ -var getNative = require('lodash._getnative'), - isArguments = require('lodash.isarguments'), - isArray = require('lodash.isarray'); - -/** Used to detect unsigned integer values. */ -var reIsUint = /^\d+$/; - -/** Used for native method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/* Native method references for those with the same name as other `lodash` methods. */ -var nativeKeys = getNative(Object, 'keys'); - -/** - * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer) - * of an array-like value. - */ -var MAX_SAFE_INTEGER = 9007199254740991; - -/** - * The base implementation of `_.property` without support for deep paths. - * - * @private - * @param {string} key The key of the property to get. - * @returns {Function} Returns the new function. - */ -function baseProperty(key) { - return function(object) { - return object == null ? undefined : object[key]; - }; -} - -/** - * Gets the "length" property value of `object`. - * - * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) - * that affects Safari on at least iOS 8.1-8.3 ARM64. - * - * @private - * @param {Object} object The object to query. - * @returns {*} Returns the "length" value. - */ -var getLength = baseProperty('length'); - -/** - * Checks if `value` is array-like. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is array-like, else `false`. - */ -function isArrayLike(value) { - return value != null && isLength(getLength(value)); -} - -/** - * Checks if `value` is a valid array-like index. - * - * @private - * @param {*} value The value to check. - * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. - * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. - */ -function isIndex(value, length) { - value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1; - length = length == null ? MAX_SAFE_INTEGER : length; - return value > -1 && value % 1 == 0 && value < length; -} - -/** - * Checks if `value` is a valid array-like length. - * - * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. - */ -function isLength(value) { - return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; -} - -/** - * A fallback implementation of `Object.keys` which creates an array of the - * own enumerable property names of `object`. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - */ -function shimKeys(object) { - var props = keysIn(object), - propsLength = props.length, - length = propsLength && object.length; - - var allowIndexes = !!length && isLength(length) && - (isArray(object) || isArguments(object)); - - var index = -1, - result = []; - - while (++index < propsLength) { - var key = props[index]; - if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) { - result.push(key); - } - } - return result; -} - -/** - * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. - * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an object, else `false`. - * @example - * - * _.isObject({}); - * // => true - * - * _.isObject([1, 2, 3]); - * // => true - * - * _.isObject(1); - * // => false - */ -function isObject(value) { - // Avoid a V8 JIT bug in Chrome 19-20. - // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. - var type = typeof value; - return !!value && (type == 'object' || type == 'function'); -} - -/** - * Creates an array of the own enumerable property names of `object`. - * - * **Note:** Non-object values are coerced to objects. See the - * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys) - * for more details. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.keys(new Foo); - * // => ['a', 'b'] (iteration order is not guaranteed) - * - * _.keys('hi'); - * // => ['0', '1'] - */ -var keys = !nativeKeys ? shimKeys : function(object) { - var Ctor = object == null ? undefined : object.constructor; - if ((typeof Ctor == 'function' && Ctor.prototype === object) || - (typeof object != 'function' && isArrayLike(object))) { - return shimKeys(object); - } - return isObject(object) ? nativeKeys(object) : []; -}; - -/** - * Creates an array of the own and inherited enumerable property names of `object`. - * - * **Note:** Non-object values are coerced to objects. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.keysIn(new Foo); - * // => ['a', 'b', 'c'] (iteration order is not guaranteed) - */ -function keysIn(object) { - if (object == null) { - return []; - } - if (!isObject(object)) { - object = Object(object); - } - var length = object.length; - length = (length && isLength(length) && - (isArray(object) || isArguments(object)) && length) || 0; - - var Ctor = object.constructor, - index = -1, - isProto = typeof Ctor == 'function' && Ctor.prototype === object, - result = Array(length), - skipIndexes = length > 0; - - while (++index < length) { - result[index] = (index + ''); - } - for (var key in object) { - if (!(skipIndexes && isIndex(key, length)) && - !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { - result.push(key); - } - } - return result; -} - -module.exports = keys; - -},{"lodash._getnative":74,"lodash.isarguments":75,"lodash.isarray":76}],74:[function(require,module,exports){ -/** - * lodash 3.9.1 (Custom Build) - * Build: `lodash modern modularize exports="npm" -o ./` - * Copyright 2012-2015 The Dojo Foundation - * Based on Underscore.js 1.8.3 - * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - * Available under MIT license - */ - -/** `Object#toString` result references. */ -var funcTag = '[object Function]'; - -/** Used to detect host constructors (Safari > 5). */ -var reIsHostCtor = /^\[object .+?Constructor\]$/; - -/** - * Checks if `value` is object-like. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is object-like, else `false`. - */ -function isObjectLike(value) { - return !!value && typeof value == 'object'; -} - -/** Used for native method references. */ -var objectProto = Object.prototype; - -/** Used to resolve the decompiled source of functions. */ -var fnToString = Function.prototype.toString; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) - * of values. - */ -var objToString = objectProto.toString; - -/** Used to detect if a method is native. */ -var reIsNative = RegExp('^' + - fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&') - .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' -); - -/** - * Gets the native function at `key` of `object`. - * - * @private - * @param {Object} object The object to query. - * @param {string} key The key of the method to get. - * @returns {*} Returns the function if it's native, else `undefined`. - */ -function getNative(object, key) { - var value = object == null ? undefined : object[key]; - return isNative(value) ? value : undefined; -} - -/** - * Checks if `value` is classified as a `Function` object. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. - * @example - * - * _.isFunction(_); - * // => true - * - * _.isFunction(/abc/); - * // => false - */ -function isFunction(value) { - // The use of `Object#toString` avoids issues with the `typeof` operator - // in older versions of Chrome and Safari which return 'function' for regexes - // and Safari 8 equivalents which return 'object' for typed array constructors. - return isObject(value) && objToString.call(value) == funcTag; -} - -/** - * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. - * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an object, else `false`. - * @example - * - * _.isObject({}); - * // => true - * - * _.isObject([1, 2, 3]); - * // => true - * - * _.isObject(1); - * // => false - */ -function isObject(value) { - // Avoid a V8 JIT bug in Chrome 19-20. - // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. - var type = typeof value; - return !!value && (type == 'object' || type == 'function'); -} - -/** - * Checks if `value` is a native function. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a native function, else `false`. - * @example - * - * _.isNative(Array.prototype.push); - * // => true - * - * _.isNative(_); - * // => false - */ -function isNative(value) { - if (value == null) { - return false; - } - if (isFunction(value)) { - return reIsNative.test(fnToString.call(value)); - } - return isObjectLike(value) && reIsHostCtor.test(value); -} - -module.exports = getNative; - -},{}],75:[function(require,module,exports){ -/** - * lodash 3.0.4 (Custom Build) - * Build: `lodash modern modularize exports="npm" -o ./` - * Copyright 2012-2015 The Dojo Foundation - * Based on Underscore.js 1.8.3 - * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - * Available under MIT license - */ - -/** - * Checks if `value` is object-like. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is object-like, else `false`. - */ -function isObjectLike(value) { - return !!value && typeof value == 'object'; -} - -/** Used for native method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** Native method references. */ -var propertyIsEnumerable = objectProto.propertyIsEnumerable; - -/** - * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer) - * of an array-like value. - */ -var MAX_SAFE_INTEGER = 9007199254740991; - -/** - * The base implementation of `_.property` without support for deep paths. - * - * @private - * @param {string} key The key of the property to get. - * @returns {Function} Returns the new function. - */ -function baseProperty(key) { - return function(object) { - return object == null ? undefined : object[key]; - }; -} - -/** - * Gets the "length" property value of `object`. - * - * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) - * that affects Safari on at least iOS 8.1-8.3 ARM64. - * - * @private - * @param {Object} object The object to query. - * @returns {*} Returns the "length" value. - */ -var getLength = baseProperty('length'); - -/** - * Checks if `value` is array-like. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is array-like, else `false`. - */ -function isArrayLike(value) { - return value != null && isLength(getLength(value)); -} - -/** - * Checks if `value` is a valid array-like length. - * - * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. - */ -function isLength(value) { - return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; -} - -/** - * Checks if `value` is classified as an `arguments` object. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. - * @example - * - * _.isArguments(function() { return arguments; }()); - * // => true - * - * _.isArguments([1, 2, 3]); - * // => false - */ -function isArguments(value) { - return isObjectLike(value) && isArrayLike(value) && - hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee'); -} - -module.exports = isArguments; - -},{}],76:[function(require,module,exports){ -/** - * lodash 3.0.4 (Custom Build) - * Build: `lodash modern modularize exports="npm" -o ./` - * Copyright 2012-2015 The Dojo Foundation - * Based on Underscore.js 1.8.3 - * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - * Available under MIT license - */ - -/** `Object#toString` result references. */ -var arrayTag = '[object Array]', - funcTag = '[object Function]'; - -/** Used to detect host constructors (Safari > 5). */ -var reIsHostCtor = /^\[object .+?Constructor\]$/; - -/** - * Checks if `value` is object-like. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is object-like, else `false`. - */ -function isObjectLike(value) { - return !!value && typeof value == 'object'; -} - -/** Used for native method references. */ -var objectProto = Object.prototype; - -/** Used to resolve the decompiled source of functions. */ -var fnToString = Function.prototype.toString; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) - * of values. - */ -var objToString = objectProto.toString; - -/** Used to detect if a method is native. */ -var reIsNative = RegExp('^' + - fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&') - .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' -); - -/* Native method references for those with the same name as other `lodash` methods. */ -var nativeIsArray = getNative(Array, 'isArray'); - -/** - * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer) - * of an array-like value. - */ -var MAX_SAFE_INTEGER = 9007199254740991; - -/** - * Gets the native function at `key` of `object`. - * - * @private - * @param {Object} object The object to query. - * @param {string} key The key of the method to get. - * @returns {*} Returns the function if it's native, else `undefined`. - */ -function getNative(object, key) { - var value = object == null ? undefined : object[key]; - return isNative(value) ? value : undefined; -} - -/** - * Checks if `value` is a valid array-like length. - * - * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. - */ -function isLength(value) { - return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; -} - -/** - * Checks if `value` is classified as an `Array` object. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. - * @example - * - * _.isArray([1, 2, 3]); - * // => true - * - * _.isArray(function() { return arguments; }()); - * // => false - */ -var isArray = nativeIsArray || function(value) { - return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag; -}; - -/** - * Checks if `value` is classified as a `Function` object. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. - * @example - * - * _.isFunction(_); - * // => true - * - * _.isFunction(/abc/); - * // => false - */ -function isFunction(value) { - // The use of `Object#toString` avoids issues with the `typeof` operator - // in older versions of Chrome and Safari which return 'function' for regexes - // and Safari 8 equivalents which return 'object' for typed array constructors. - return isObject(value) && objToString.call(value) == funcTag; -} - -/** - * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. - * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an object, else `false`. - * @example - * - * _.isObject({}); - * // => true - * - * _.isObject([1, 2, 3]); - * // => true - * - * _.isObject(1); - * // => false - */ -function isObject(value) { - // Avoid a V8 JIT bug in Chrome 19-20. - // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. - var type = typeof value; - return !!value && (type == 'object' || type == 'function'); -} - -/** - * Checks if `value` is a native function. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a native function, else `false`. - * @example - * - * _.isNative(Array.prototype.push); - * // => true - * - * _.isNative(_); - * // => false - */ -function isNative(value) { - if (value == null) { - return false; - } - if (isFunction(value)) { - return reIsNative.test(fnToString.call(value)); - } - return isObjectLike(value) && reIsHostCtor.test(value); -} - -module.exports = isArray; - -},{}],77:[function(require,module,exports){ -/** - * lodash 3.0.3 (Custom Build) - * Build: `lodash modern modularize exports="npm" -o ./` - * Copyright 2012-2015 The Dojo Foundation - * Based on Underscore.js 1.8.3 - * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - * Available under MIT license - */ - -/** - * The base implementation of `_.create` without support for assigning - * properties to the created object. - * - * @private - * @param {Object} prototype The object to inherit from. - * @returns {Object} Returns the new object. - */ -var baseCreate = (function() { - function object() {} - return function(prototype) { - if (isObject(prototype)) { - object.prototype = prototype; - var result = new object; - object.prototype = undefined; - } - return result || {}; - }; -}()); - -/** - * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. - * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an object, else `false`. - * @example - * - * _.isObject({}); - * // => true - * - * _.isObject([1, 2, 3]); - * // => true - * - * _.isObject(1); - * // => false - */ -function isObject(value) { - // Avoid a V8 JIT bug in Chrome 19-20. - // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. - var type = typeof value; - return !!value && (type == 'object' || type == 'function'); -} - -module.exports = baseCreate; - -},{}],78:[function(require,module,exports){ -/** - * lodash 3.0.9 (Custom Build) - * Build: `lodash modern modularize exports="npm" -o ./` - * Copyright 2012-2015 The Dojo Foundation - * Based on Underscore.js 1.8.3 - * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - * Available under MIT license - */ - -/** Used to detect unsigned integer values. */ -var reIsUint = /^\d+$/; - -/** - * Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer) - * of an array-like value. - */ -var MAX_SAFE_INTEGER = 9007199254740991; - -/** - * The base implementation of `_.property` without support for deep paths. - * - * @private - * @param {string} key The key of the property to get. - * @returns {Function} Returns the new function. - */ -function baseProperty(key) { - return function(object) { - return object == null ? undefined : object[key]; - }; -} - -/** - * Gets the "length" property value of `object`. - * - * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) - * that affects Safari on at least iOS 8.1-8.3 ARM64. - * - * @private - * @param {Object} object The object to query. - * @returns {*} Returns the "length" value. - */ -var getLength = baseProperty('length'); - -/** - * Checks if `value` is array-like. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is array-like, else `false`. - */ -function isArrayLike(value) { - return value != null && isLength(getLength(value)); -} - -/** - * Checks if `value` is a valid array-like index. - * - * @private - * @param {*} value The value to check. - * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. - * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. - */ -function isIndex(value, length) { - value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1; - length = length == null ? MAX_SAFE_INTEGER : length; - return value > -1 && value % 1 == 0 && value < length; -} - -/** - * Checks if the provided arguments are from an iteratee call. - * - * @private - * @param {*} value The potential iteratee value argument. - * @param {*} index The potential iteratee index or key argument. - * @param {*} object The potential iteratee object argument. - * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`. - */ -function isIterateeCall(value, index, object) { - if (!isObject(object)) { - return false; - } - var type = typeof index; - if (type == 'number' - ? (isArrayLike(object) && isIndex(index, object.length)) - : (type == 'string' && index in object)) { - var other = object[index]; - return value === value ? (value === other) : (other !== other); - } - return false; -} - -/** - * Checks if `value` is a valid array-like length. - * - * **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength). - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. - */ -function isLength(value) { - return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; -} - -/** - * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. - * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an object, else `false`. - * @example - * - * _.isObject({}); - * // => true - * - * _.isObject([1, 2, 3]); - * // => true - * - * _.isObject(1); - * // => false - */ -function isObject(value) { - // Avoid a V8 JIT bug in Chrome 19-20. - // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. - var type = typeof value; - return !!value && (type == 'object' || type == 'function'); -} - -module.exports = isIterateeCall; - -},{}],79:[function(require,module,exports){ +},{"_process":52,"child_process":41,"fs":41,"os":51,"path":41}],71:[function(require,module,exports){ (function (process,global){ /** * Shim process.stdout. @@ -13307,4 +12446,4 @@ window.Mocha = Mocha; window.mocha = mocha; }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"../":1,"_process":51,"browser-stdout":40}]},{},[79]); +},{"../":1,"_process":52,"browser-stdout":40}]},{},[71]); diff --git a/tests/bower_components/mocha/scripts/ensure-compatible-npm.sh b/tests/bower_components/mocha/scripts/ensure-compatible-npm.sh index 00372f7..7105e3b 100755 --- a/tests/bower_components/mocha/scripts/ensure-compatible-npm.sh +++ b/tests/bower_components/mocha/scripts/ensure-compatible-npm.sh @@ -5,6 +5,7 @@ set -o errexit npm install semver if node -e "process.exit(require('semver').lt(process.argv[1], '1.3.7') ? 0 : 1)" $(npm -v); then - npm install -g npm@'>= 1.3.7' + npm install -g npm@2 + npm install -g npm fi npm uninstall semver diff --git a/tests/fixtures/helper.js b/tests/fixtures/helper.js index 2db2970..2f8be87 100644 --- a/tests/fixtures/helper.js +++ b/tests/fixtures/helper.js @@ -52,6 +52,15 @@ expected.columnNumber = json.columnNumber; } + if (userAgent.isSafari) { + expect(json.sourceURL).to.be.a('string').and.not.empty; + expect(json.line).to.be.a('number').above(0); + expect(json.column).to.be.a('number').above(0); + expected.sourceURL = json.sourceURL; + expected.line = json.line; + expected.column = json.column; + } + if (userAgent.isIE && 'description' in json) { expect(json.description).to.be.a('string'); expected.description = json.description; diff --git a/tests/specs/ono.spec.js b/tests/specs/ono.spec.js index 487fb37..cff7638 100644 --- a/tests/specs/ono.spec.js +++ b/tests/specs/ono.spec.js @@ -121,7 +121,10 @@ helper.forEachMethod(function(name, ono, ErrorType, ErrorTypeName) { it('can be called with just an inner-error', function() { function makeInnerError() { - return new SyntaxError('This is the inner error'); + var err = new SyntaxError('This is the inner error'); + err.foo = 'bar'; + err.code = 404; + return err; } var err = (function newErrorWithInnerError(innerErr) { @@ -131,6 +134,8 @@ helper.forEachMethod(function(name, ono, ErrorType, ErrorTypeName) { expect(err).to.be.an.instanceOf(ErrorType); expect(err.name).to.equal(ErrorTypeName); expect(err.message).to.equal('This is the inner error'); + expect(err.foo).to.equal('bar'); + expect(err.code).to.equal(404); if (err.stack) { expect(err.stack).to.match(/newErrorWithInnerError/); @@ -145,7 +150,9 @@ helper.forEachMethod(function(name, ono, ErrorType, ErrorTypeName) { expect(json).to.satisfy(helper.matchesJSON({ name: err.name, message: err.message, - stack: err.stack + stack: err.stack, + foo: 'bar', + code: 404 })); } ); @@ -153,7 +160,10 @@ helper.forEachMethod(function(name, ono, ErrorType, ErrorTypeName) { it('can be called with an inner-error and a message', function() { function makeInnerError() { - return new ReferenceError('This is the inner error'); + var err = new ReferenceError('This is the inner error'); + err.foo = 'bar'; + err.code = 404; + return err; } var err = (function newErrorWithInnerErrorAndMessage(innerErr) { @@ -163,6 +173,8 @@ helper.forEachMethod(function(name, ono, ErrorType, ErrorTypeName) { expect(err).to.be.an.instanceOf(ErrorType); expect(err.name).to.equal(ErrorTypeName); expect(err.message).to.equal('Oops, an error happened. \nThis is the inner error'); + expect(err.foo).to.equal('bar'); + expect(err.code).to.equal(404); if (err.stack) { expect(err.stack).to.match(/newErrorWithInnerErrorAndMessage/); @@ -177,7 +189,9 @@ helper.forEachMethod(function(name, ono, ErrorType, ErrorTypeName) { expect(json).to.satisfy(helper.matchesJSON({ name: err.name, message: err.message, - stack: err.stack + stack: err.stack, + foo: 'bar', + code: 404 })); } ); @@ -185,7 +199,10 @@ helper.forEachMethod(function(name, ono, ErrorType, ErrorTypeName) { it('can be called with an inner-error and a parameterized message', function() { function makeInnerError() { - return new RangeError('This is the inner error'); + var err = new RangeError('This is the inner error'); + err.foo = 'bar'; + err.code = 404; + return err; } var err = (function newErrorWithInnerErrorAndParamMessage(innerErr) { @@ -195,6 +212,8 @@ helper.forEachMethod(function(name, ono, ErrorType, ErrorTypeName) { expect(err).to.be.an.instanceOf(ErrorType); expect(err.name).to.equal(ErrorTypeName); expect(err.message).to.equal('Testing, 1, 2, "3" \nThis is the inner error'); + expect(err.foo).to.equal('bar'); + expect(err.code).to.equal(404); if (err.stack) { expect(err.stack).to.match(/newErrorWithInnerErrorAndParamMessage/); @@ -209,7 +228,9 @@ helper.forEachMethod(function(name, ono, ErrorType, ErrorTypeName) { expect(json).to.satisfy(helper.matchesJSON({ name: err.name, message: err.message, - stack: err.stack + stack: err.stack, + foo: 'bar', + code: 404 })); } ); @@ -256,10 +277,13 @@ helper.forEachMethod(function(name, ono, ErrorType, ErrorTypeName) { function() { var now = new Date(); - function foo() {} + function someMethod() {return this.code;} function makeInnerError() { - return new EvalError('This is the inner error'); + var err = new EvalError('This is the inner error'); + err.foo = 'bar'; + err.code = 500; + return err; } var err = (function newErrorWithInnerErrorAndProps(innerErr) { @@ -267,7 +291,7 @@ helper.forEachMethod(function(name, ono, ErrorType, ErrorTypeName) { code: 404, text: 'Not Found', timestamp: now, - foo: foo + someMethod: someMethod }); })(makeInnerError()); @@ -277,6 +301,9 @@ helper.forEachMethod(function(name, ono, ErrorType, ErrorTypeName) { expect(err.code).to.equal(404); expect(err.text).to.equal('Not Found'); expect(err.timestamp).to.equal(now); + expect(err.foo).to.equal('bar'); + expect(err.someMethod).to.equal(someMethod); + expect(err.someMethod()).to.equal(404); if (err.stack) { expect(err.stack).to.match(/makeInnerError/); @@ -294,7 +321,8 @@ helper.forEachMethod(function(name, ono, ErrorType, ErrorTypeName) { stack: err.stack, code: 404, text: 'Not Found', - timestamp: now.toJSON() + timestamp: now.toJSON(), + foo: 'bar' })); } ); @@ -303,14 +331,14 @@ helper.forEachMethod(function(name, ono, ErrorType, ErrorTypeName) { function() { var now = new Date(); - function foo() {} + function someMethod() {return this.code;} var err = (function newErrorWithPropsAndMessage() { return ono({ code: 404, text: 'Not Found', timestamp: now, - foo: foo + someMethod: someMethod }, 'Onoes! Something bad happened.'); })(); @@ -320,6 +348,8 @@ helper.forEachMethod(function(name, ono, ErrorType, ErrorTypeName) { expect(err.code).to.equal(404); expect(err.text).to.equal('Not Found'); expect(err.timestamp).to.equal(now); + expect(err.someMethod).to.equal(someMethod); + expect(err.someMethod()).to.equal(404); if (err.stack) { expect(err.stack).to.match(/newErrorWithPropsAndMessage/); @@ -378,10 +408,13 @@ helper.forEachMethod(function(name, ono, ErrorType, ErrorTypeName) { function() { var now = new Date(); - function foo() {} + function someMethod() {return this.code;} function makeInnerError() { - return new EvalError('This is the inner error'); + var err = new EvalError('This is the inner error'); + err.foo = 'bar'; + err.code = 500; + return err; } var err = (function newErrorWithInnerErrorPropsAndParamMessage(innerErr) { @@ -391,7 +424,7 @@ helper.forEachMethod(function(name, ono, ErrorType, ErrorTypeName) { code: 404, text: 'Not Found', timestamp: now, - foo: foo + someMethod: someMethod }, 'Testing, %s, %d, %j', 1, '2', '3' ); @@ -403,6 +436,9 @@ helper.forEachMethod(function(name, ono, ErrorType, ErrorTypeName) { expect(err.code).to.equal(404); expect(err.text).to.equal('Not Found'); expect(err.timestamp).to.equal(now); + expect(err.foo).to.equal('bar'); + expect(err.someMethod).to.equal(someMethod); + expect(err.someMethod()).to.equal(404); if (err.stack) { expect(err.stack).to.match(/newErrorWithInnerErrorPropsAndParamMessage/); @@ -420,7 +456,8 @@ helper.forEachMethod(function(name, ono, ErrorType, ErrorTypeName) { stack: err.stack, code: 404, text: 'Not Found', - timestamp: now.toJSON() + timestamp: now.toJSON(), + foo: 'bar' })); } );