made with requirebin
Created
March 30, 2015 19:14
-
-
Save gregglind/e894d7094062b5e171f5 to your computer and use it in GitHub Desktop.
requirebin sketch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// require() some stuff from npm (like you were using browserify) | |
// and then hit Run Code to run it on the right | |
var p = document.createElement("pre"); | |
document.body.appendChild(p); | |
p.textContent="LOG"; | |
var log = function () { | |
p.textContent += "\n" + Array.prototype.slice.call(arguments).join(" ") | |
} | |
var chai = require("chai"); | |
var chaiAsPromised = require("chai-as-promised"); | |
chai.use(chaiAsPromised); | |
var thrower = function () {throw new Error("oops")}; | |
try { | |
log("test 1"); | |
chai.expect(Promise.resolve(true)).eventually.false(); | |
} catch (err) { | |
log(err); | |
} | |
try { | |
log("test 2"); | |
chai.expect(Promise.resolve(true).then(thrower)).eventually.throw(); | |
} catch (err) { | |
log(err) | |
} ; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require=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<r.length;o++)s(r[o]);return s}({"chai-as-promised":[function(require,module,exports){(function(){"use strict";if(typeof require==="function"&&typeof exports==="object"&&typeof module==="object"){module.exports=chaiAsPromised}else if(typeof define==="function"&&define.amd){define(function(){return chaiAsPromised})}else{chai.use(chaiAsPromised);self.chaiAsPromised=chaiAsPromised}chaiAsPromised.transferPromiseness=function(assertion,promise){assertion.then=promise.then.bind(promise)};chaiAsPromised.transformAsserterArgs=function(values){return values};function chaiAsPromised(chai,utils){var Assertion=chai.Assertion;var assert=chai.assert;function isJQueryPromise(thenable){return typeof thenable.always==="function"&&typeof thenable.done==="function"&&typeof thenable.fail==="function"&&typeof thenable.pipe==="function"&&typeof thenable.progress==="function"&&typeof thenable.state==="function"}function assertIsAboutPromise(assertion){if(typeof assertion._obj.then!=="function"){throw new TypeError(utils.inspect(assertion._obj)+" is not a thenable.")}if(isJQueryPromise(assertion._obj)){throw new TypeError("Chai as Promised is incompatible with jQuery's thenables, sorry! Please use a "+"Promises/A+ compatible library (see http://promisesaplus.com/).")}}function method(name,asserter){utils.addMethod(Assertion.prototype,name,function(){assertIsAboutPromise(this);return asserter.apply(this,arguments)})}function property(name,asserter){utils.addProperty(Assertion.prototype,name,function(){assertIsAboutPromise(this);return asserter.apply(this,arguments)})}function doNotify(promise,done){promise.then(function(){done()},done)}function assertIfNegated(assertion,message,extra){assertion.assert(true,null,message,extra.expected,extra.actual)}function assertIfNotNegated(assertion,message,extra){assertion.assert(false,message,null,extra.expected,extra.actual)}function getBasePromise(assertion){return typeof assertion.then==="function"?assertion:assertion._obj}var propertyNames=Object.getOwnPropertyNames(Assertion.prototype);var propertyDescs={};propertyNames.forEach(function(name){propertyDescs[name]=Object.getOwnPropertyDescriptor(Assertion.prototype,name)});property("fulfilled",function(){var that=this;var derivedPromise=getBasePromise(that).then(function(value){that._obj=value;assertIfNegated(that,"expected promise not to be fulfilled but it was fulfilled with #{act}",{actual:value});return value},function(reason){assertIfNotNegated(that,"expected promise to be fulfilled but it was rejected with #{act}",{actual:reason})});chaiAsPromised.transferPromiseness(that,derivedPromise)});property("rejected",function(){var that=this;var derivedPromise=getBasePromise(that).then(function(value){that._obj=value;assertIfNotNegated(that,"expected promise to be rejected but it was fulfilled with #{act}",{actual:value});return value},function(reason){assertIfNegated(that,"expected promise not to be rejected but it was rejected with #{act}",{actual:reason});return reason});chaiAsPromised.transferPromiseness(that,derivedPromise)});method("rejectedWith",function(Constructor,message){var desiredReason=null;var constructorName=null;if(Constructor instanceof RegExp||typeof Constructor==="string"){message=Constructor;Constructor=null}else if(Constructor&&Constructor instanceof Error){desiredReason=Constructor;Constructor=null;message=null}else if(typeof Constructor==="function"){constructorName=(new Constructor).name}else{Constructor=null}var that=this;var derivedPromise=getBasePromise(that).then(function(value){var assertionMessage=null;var expected=null;if(Constructor){assertionMessage="expected promise to be rejected with #{exp} but it was fulfilled with "+"#{act}";expected=constructorName}else if(message){var verb=message instanceof RegExp?"matching":"including";assertionMessage="expected promise to be rejected with an error "+verb+" #{exp} but it "+"was fulfilled with #{act}";expected=message}else if(desiredReason){assertionMessage="expected promise to be rejected with #{exp} but it was fulfilled with "+"#{act}";expected=desiredReason}that._obj=value;assertIfNotNegated(that,assertionMessage,{expected:expected,actual:value})},function(reason){if(Constructor){that.assert(reason instanceof Constructor,"expected promise to be rejected with #{exp} but it was rejected with #{act}","expected promise not to be rejected with #{exp} but it was rejected with #{act}",constructorName,reason)}var reasonMessage=utils.type(reason)==="object"&&"message"in reason?reason.message:""+reason;if(message&&reasonMessage!==null&&reasonMessage!==undefined){if(message instanceof RegExp){that.assert(message.test(reasonMessage),"expected promise to be rejected with an error matching #{exp} but got #{act}","expected promise not to be rejected with an error matching #{exp}",message,reasonMessage)}if(typeof message==="string"){that.assert(reasonMessage.indexOf(message)!==-1,"expected promise to be rejected with an error including #{exp} but got #{act}","expected promise not to be rejected with an error including #{exp}",message,reasonMessage)}}if(desiredReason){that.assert(reason===desiredReason,"expected promise to be rejected with #{exp} but it was rejected with #{act}","expected promise not to be rejected with #{exp}",desiredReason,reason)}});chaiAsPromised.transferPromiseness(that,derivedPromise)});property("eventually",function(){utils.flag(this,"eventually",true)});method("notify",function(done){doNotify(getBasePromise(this),done)});method("become",function(value){return this.eventually.deep.equal(value)});var methodNames=propertyNames.filter(function(name){return name!=="assert"&&typeof propertyDescs[name].value==="function"});methodNames.forEach(function(methodName){Assertion.overwriteMethod(methodName,function(originalMethod){return function(){doAsserterAsyncAndAddThen(originalMethod,this,arguments)}})});var getterNames=propertyNames.filter(function(name){return name!=="_obj"&&typeof propertyDescs[name].get==="function"});getterNames.forEach(function(getterName){var propertyDesc=propertyDescs[getterName];var isChainableMethod=false;try{isChainableMethod=typeof propertyDesc.get.call({})==="function"}catch(e){}if(isChainableMethod){Assertion.addChainableMethod(getterName,function(){var assertion=this;function originalMethod(){return propertyDesc.get.call(assertion).apply(assertion,arguments)}doAsserterAsyncAndAddThen(originalMethod,this,arguments)},function(){var originalGetter=propertyDesc.get;doAsserterAsyncAndAddThen(originalGetter,this)})}else{Assertion.overwriteProperty(getterName,function(originalGetter){return function(){doAsserterAsyncAndAddThen(originalGetter,this)}})}});function doAsserterAsyncAndAddThen(asserter,assertion,args){if(!utils.flag(assertion,"eventually")){return asserter.apply(assertion,args)}var derivedPromise=getBasePromise(assertion).then(function(value){assertion._obj=value;utils.flag(assertion,"eventually",false);return args?chaiAsPromised.transformAsserterArgs(args):args}).then(function(args){asserter.apply(assertion,args);return assertion._obj});chaiAsPromised.transferPromiseness(assertion,derivedPromise)}var originalAssertMethods=Object.getOwnPropertyNames(assert).filter(function(propName){return typeof assert[propName]==="function"});assert.isFulfilled=function(promise,message){return new Assertion(promise,message).to.be.fulfilled};assert.isRejected=function(promise,toTestAgainst,message){if(typeof toTestAgainst==="string"){message=toTestAgainst;toTestAgainst=undefined}var assertion=new Assertion(promise,message);return toTestAgainst!==undefined?assertion.to.be.rejectedWith(toTestAgainst):assertion.to.be.rejected};assert.becomes=function(promise,value,message){return assert.eventually.deepEqual(promise,value,message)};assert.doesNotBecome=function(promise,value,message){return assert.eventually.notDeepEqual(promise,value,message)};assert.eventually={};originalAssertMethods.forEach(function(assertMethodName){assert.eventually[assertMethodName]=function(promise){var otherArgs=Array.prototype.slice.call(arguments,1);var customRejectionHandler;var message=arguments[assert[assertMethodName].length-1];if(typeof message==="string"){customRejectionHandler=function(reason){throw new chai.AssertionError(message+"\n\nOriginal reason: "+utils.inspect(reason))}}var returnedPromise=promise.then(function(fulfillmentValue){return assert[assertMethodName].apply(assert,[fulfillmentValue].concat(otherArgs))},customRejectionHandler);returnedPromise.notify=function(done){doNotify(returnedPromise,done)};return returnedPromise}})}})()},{}]},{},[]);require=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<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){var base64=require("base64-js");var ieee754=require("ieee754");var isArray=require("is-array");exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;Buffer.poolSize=8192;var kMaxLength=1073741823;var rootParent={};Buffer.TYPED_ARRAY_SUPPORT=function(){try{var buf=new ArrayBuffer(0);var arr=new Uint8Array(buf);arr.foo=function(){return 42};return 42===arr.foo()&&typeof arr.subarray==="function"&&new Uint8Array(1).subarray(1,1).byteLength===0}catch(e){return false}}();function Buffer(subject,encoding,noZero){if(!(this instanceof Buffer))return new Buffer(subject,encoding,noZero);var type=typeof subject;var length;if(type==="number")length=subject>0?subject>>>0:0;else if(type==="string"){length=Buffer.byteLength(subject,encoding)}else if(type==="object"&&subject!==null){if(subject.type==="Buffer"&&isArray(subject.data))subject=subject.data;length=+subject.length>0?Math.floor(+subject.length):0}else throw new TypeError("must start with number, buffer, array or string");if(length>kMaxLength)throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+kMaxLength.toString(16)+" bytes");var buf;if(Buffer.TYPED_ARRAY_SUPPORT){buf=Buffer._augment(new Uint8Array(length))}else{buf=this;buf.length=length;buf._isBuffer=true}var i;if(Buffer.TYPED_ARRAY_SUPPORT&&typeof subject.byteLength==="number"){buf._set(subject)}else if(isArrayish(subject)){if(Buffer.isBuffer(subject)){for(i=0;i<length;i++)buf[i]=subject.readUInt8(i)}else{for(i=0;i<length;i++)buf[i]=(subject[i]%256+256)%256}}else if(type==="string"){buf.write(subject,0,encoding)}else if(type==="number"&&!Buffer.TYPED_ARRAY_SUPPORT&&!noZero){for(i=0;i<length;i++){buf[i]=0}}if(length>0&&length<=Buffer.poolSize)buf.parent=rootParent;return buf}function SlowBuffer(subject,encoding,noZero){if(!(this instanceof SlowBuffer))return new SlowBuffer(subject,encoding,noZero);var buf=new Buffer(subject,encoding,noZero);delete buf.parent;return buf}Buffer.isBuffer=function(b){return!!(b!=null&&b._isBuffer)};Buffer.compare=function(a,b){if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b))throw new TypeError("Arguments must be Buffers");var x=a.length;var y=b.length;for(var i=0,len=Math.min(x,y);i<len&&a[i]===b[i];i++){}if(i!==len){x=a[i];y=b[i]}if(x<y)return-1;if(y<x)return 1;return 0};Buffer.isEncoding=function(encoding){switch(String(encoding).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return true;default:return false}};Buffer.concat=function(list,totalLength){if(!isArray(list))throw new TypeError("Usage: Buffer.concat(list[, length])");if(list.length===0){return new Buffer(0)}else if(list.length===1){return list[0]}var i;if(totalLength===undefined){totalLength=0;for(i=0;i<list.length;i++){totalLength+=list[i].length}}var buf=new Buffer(totalLength);var pos=0;for(i=0;i<list.length;i++){var item=list[i];item.copy(buf,pos);pos+=item.length}return buf};Buffer.byteLength=function(str,encoding){var ret;str=str+"";switch(encoding||"utf8"){case"ascii":case"binary":case"raw":ret=str.length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":ret=str.length*2;break;case"hex":ret=str.length>>>1;break;case"utf8":case"utf-8":ret=utf8ToBytes(str).length;break;case"base64":ret=base64ToBytes(str).length;break;default:ret=str.length}return ret};Buffer.prototype.length=undefined;Buffer.prototype.parent=undefined;Buffer.prototype.toString=function(encoding,start,end){var loweredCase=false;start=start>>>0;end=end===undefined||end===Infinity?this.length:end>>>0;if(!encoding)encoding="utf8";if(start<0)start=0;if(end>this.length)end=this.length;if(end<=start)return"";while(true){switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"binary":return binarySlice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase();loweredCase=true}}};Buffer.prototype.equals=function(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");return Buffer.compare(this,b)===0};Buffer.prototype.inspect=function(){var str="";var max=exports.INSPECT_MAX_BYTES;if(this.length>0){str=this.toString("hex",0,max).match(/.{2}/g).join(" ");if(this.length>max)str+=" ... "}return"<Buffer "+str+">"};Buffer.prototype.compare=function(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");return Buffer.compare(this,b)};Buffer.prototype.get=function(offset){console.log(".get() is deprecated. Access using array indexes instead.");return this.readUInt8(offset)};Buffer.prototype.set=function(v,offset){console.log(".set() is deprecated. Access using array indexes instead.");return this.writeUInt8(v,offset)};function hexWrite(buf,string,offset,length){offset=Number(offset)||0;var remaining=buf.length-offset;if(!length){length=remaining}else{length=Number(length);if(length>remaining){length=remaining}}var strLen=string.length;if(strLen%2!==0)throw new Error("Invalid hex string");if(length>strLen/2){length=strLen/2}for(var i=0;i<length;i++){var byte=parseInt(string.substr(i*2,2),16);if(isNaN(byte))throw new Error("Invalid hex string");buf[offset+i]=byte}return i}function utf8Write(buf,string,offset,length){var charsWritten=blitBuffer(utf8ToBytes(string,buf.length-offset),buf,offset,length);return charsWritten}function asciiWrite(buf,string,offset,length){var charsWritten=blitBuffer(asciiToBytes(string),buf,offset,length);return charsWritten}function binaryWrite(buf,string,offset,length){return asciiWrite(buf,string,offset,length)}function base64Write(buf,string,offset,length){var charsWritten=blitBuffer(base64ToBytes(string),buf,offset,length);return charsWritten}function utf16leWrite(buf,string,offset,length){var charsWritten=blitBuffer(utf16leToBytes(string,buf.length-offset),buf,offset,length,2);return charsWritten}Buffer.prototype.write=function(string,offset,length,encoding){if(isFinite(offset)){if(!isFinite(length)){encoding=length;length=undefined}}else{var swap=encoding;encoding=offset;offset=length;length=swap}offset=Number(offset)||0;if(length<0||offset<0||offset>this.length)throw new RangeError("attempt to write outside buffer bounds");var remaining=this.length-offset;if(!length){length=remaining}else{length=Number(length);if(length>remaining){length=remaining}}encoding=String(encoding||"utf8").toLowerCase();var ret;switch(encoding){case"hex":ret=hexWrite(this,string,offset,length);break;case"utf8":case"utf-8":ret=utf8Write(this,string,offset,length);break;case"ascii":ret=asciiWrite(this,string,offset,length);break;case"binary":ret=binaryWrite(this,string,offset,length);break;case"base64":ret=base64Write(this,string,offset,length);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":ret=utf16leWrite(this,string,offset,length);break;default:throw new TypeError("Unknown encoding: "+encoding)}return ret};Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf)}else{return base64.fromByteArray(buf.slice(start,end))}}function utf8Slice(buf,start,end){var res="";var tmp="";end=Math.min(buf.length,end);for(var i=start;i<end;i++){if(buf[i]<=127){res+=decodeUtf8Char(tmp)+String.fromCharCode(buf[i]);tmp=""}else{tmp+="%"+buf[i].toString(16)}}return res+decodeUtf8Char(tmp)}function asciiSlice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;i++){ret+=String.fromCharCode(buf[i]&127)}return ret}function binarySlice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;i++){ret+=String.fromCharCode(buf[i])}return ret}function hexSlice(buf,start,end){var len=buf.length;if(!start||start<0)start=0;if(!end||end<0||end>len)end=len;var out="";for(var i=start;i<end;i++){out+=toHex(buf[i])}return out}function utf16leSlice(buf,start,end){var bytes=buf.slice(start,end);var res="";for(var i=0;i<bytes.length;i+=2){res+=String.fromCharCode(bytes[i]+bytes[i+1]*256)}return res}Buffer.prototype.slice=function(start,end){var len=this.length;start=~~start;end=end===undefined?len:~~end;if(start<0){start+=len;if(start<0)start=0}else if(start>len){start=len}if(end<0){end+=len;if(end<0)end=0}else if(end>len){end=len}if(end<start)end=start;var newBuf;if(Buffer.TYPED_ARRAY_SUPPORT){newBuf=Buffer._augment(this.subarray(start,end))}else{var sliceLen=end-start;newBuf=new Buffer(sliceLen,undefined,true);for(var i=0;i<sliceLen;i++){newBuf[i]=this[i+start]}}if(newBuf.length)newBuf.parent=this.parent||this;return newBuf};function checkOffset(offset,ext,length){if(offset%1!==0||offset<0)throw new RangeError("offset is not uint");if(offset+ext>length)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i<byteLength&&(mul*=256))val+=this[offset+i]*mul;return val};Buffer.prototype.readUIntBE=function(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset+--byteLength];var mul=1;while(byteLength>0&&(mul*=256))val+=this[offset+--byteLength]*mul;return val};Buffer.prototype.readUInt8=function(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);return this[offset]};Buffer.prototype.readUInt16LE=function(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8};Buffer.prototype.readUInt16BE=function(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1]};Buffer.prototype.readUInt32LE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*16777216};Buffer.prototype.readUInt32BE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*16777216+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])};Buffer.prototype.readIntLE=function(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i<byteLength&&(mul*=256))val+=this[offset+i]*mul;mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readIntBE=function(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var i=byteLength;var mul=1;var val=this[offset+--i];while(i>0&&(mul*=256))val+=this[offset+--i]*mul;mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readInt8=function(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&128))return this[offset];return(255-this[offset]+1)*-1};Buffer.prototype.readInt16LE=function(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt16BE=function(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt32LE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24};Buffer.prototype.readInt32BE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]};Buffer.prototype.readFloatLE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4)};Buffer.prototype.readFloatBE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4)};Buffer.prototype.readDoubleLE=function(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8)};Buffer.prototype.readDoubleBE=function(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError("buffer must be a Buffer instance");if(value>max||value<min)throw new RangeError("value is out of bounds");if(offset+ext>buf.length)throw new RangeError("index out of range")}Buffer.prototype.writeUIntLE=function(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength),0);var mul=1;var i=0;this[offset]=value&255;while(++i<byteLength&&(mul*=256))this[offset+i]=value/mul>>>0&255;return offset+byteLength};Buffer.prototype.writeUIntBE=function(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength),0);var i=byteLength-1;var mul=1;this[offset+i]=value&255;while(--i>=0&&(mul*=256))this[offset+i]=value/mul>>>0&255;return offset+byteLength};Buffer.prototype.writeUInt8=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,255,0);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);this[offset]=value;return offset+1};function objectWriteUInt16(buf,value,offset,littleEndian){if(value<0)value=65535+value+1;for(var i=0,j=Math.min(buf.length-offset,2);i<j;i++){buf[offset+i]=(value&255<<8*(littleEndian?i:1-i))>>>(littleEndian?i:1-i)*8}}Buffer.prototype.writeUInt16LE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8}else objectWriteUInt16(this,value,offset,true);return offset+2};Buffer.prototype.writeUInt16BE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value}else objectWriteUInt16(this,value,offset,false);return offset+2};function objectWriteUInt32(buf,value,offset,littleEndian){if(value<0)value=4294967295+value+1;for(var i=0,j=Math.min(buf.length-offset,4);i<j;i++){buf[offset+i]=value>>>(littleEndian?i:3-i)*8&255}}Buffer.prototype.writeUInt32LE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value}else objectWriteUInt32(this,value,offset,true);return offset+4};Buffer.prototype.writeUInt32BE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value}else objectWriteUInt32(this,value,offset,false);return offset+4};Buffer.prototype.writeIntLE=function(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength-1)-1,-Math.pow(2,8*byteLength-1))}var i=0;var mul=1;var sub=value<0?1:0;this[offset]=value&255;while(++i<byteLength&&(mul*=256))this[offset+i]=(value/mul>>0)-sub&255;return offset+byteLength};Buffer.prototype.writeIntBE=function(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength-1)-1,-Math.pow(2,8*byteLength-1))}var i=byteLength-1;var mul=1;var sub=value<0?1:0;this[offset+i]=value&255;while(--i>=0&&(mul*=256))this[offset+i]=(value/mul>>0)-sub&255;return offset+byteLength};Buffer.prototype.writeInt8=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,127,-128);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);if(value<0)value=255+value+1;this[offset]=value;return offset+1};Buffer.prototype.writeInt16LE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8}else objectWriteUInt16(this,value,offset,true);return offset+2};Buffer.prototype.writeInt16BE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value}else objectWriteUInt16(this,value,offset,false);return offset+2};Buffer.prototype.writeInt32LE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24}else objectWriteUInt32(this,value,offset,true);return offset+4};Buffer.prototype.writeInt32BE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(value<0)value=4294967295+value+1;if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value}else objectWriteUInt32(this,value,offset,false);return offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(value>max||value<min)throw new RangeError("value is out of bounds");if(offset+ext>buf.length)throw new RangeError("index out of range");if(offset<0)throw new RangeError("index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){if(!noAssert)checkIEEE754(buf,value,offset,4,3.4028234663852886e38,-3.4028234663852886e38);ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4}Buffer.prototype.writeFloatLE=function(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){if(!noAssert)checkIEEE754(buf,value,offset,8,1.7976931348623157e308,-1.7976931348623157e308);ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8}Buffer.prototype.writeDoubleLE=function(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.copy=function(target,target_start,start,end){var source=this;if(!start)start=0;if(!end&&end!==0)end=this.length;if(target_start>=target.length)target_start=target.length;if(!target_start)target_start=0;if(end>0&&end<start)end=start;if(end===start)return 0;if(target.length===0||source.length===0)return 0;if(target_start<0)throw new RangeError("targetStart out of bounds");if(start<0||start>=source.length)throw new RangeError("sourceStart out of bounds");if(end<0)throw new RangeError("sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-target_start<end-start)end=target.length-target_start+start;var len=end-start;if(len<1e3||!Buffer.TYPED_ARRAY_SUPPORT){for(var i=0;i<len;i++){target[i+target_start]=this[i+start]}}else{target._set(this.subarray(start,start+len),target_start)}return len};Buffer.prototype.fill=function(value,start,end){if(!value)value=0;if(!start)start=0;if(!end)end=this.length;if(end<start)throw new RangeError("end < start");if(end===start)return;if(this.length===0)return;if(start<0||start>=this.length)throw new RangeError("start out of bounds");if(end<0||end>this.length)throw new RangeError("end out of bounds");var i;if(typeof value==="number"){for(i=start;i<end;i++){this[i]=value}}else{var bytes=utf8ToBytes(value.toString());var len=bytes.length;for(i=start;i<end;i++){this[i]=bytes[i%len]}}return this};Buffer.prototype.toArrayBuffer=function(){if(typeof Uint8Array!=="undefined"){if(Buffer.TYPED_ARRAY_SUPPORT){return new Buffer(this).buffer}else{var buf=new Uint8Array(this.length);for(var i=0,len=buf.length;i<len;i+=1){buf[i]=this[i]}return buf.buffer}}else{throw new TypeError("Buffer.toArrayBuffer not supported in this browser")}};var BP=Buffer.prototype;Buffer._augment=function(arr){arr.constructor=Buffer;arr._isBuffer=true;arr._get=arr.get;arr._set=arr.set;arr.get=BP.get;arr.set=BP.set;arr.write=BP.write;arr.toString=BP.toString;arr.toLocaleString=BP.toString;arr.toJSON=BP.toJSON;arr.equals=BP.equals;arr.compare=BP.compare;arr.copy=BP.copy;arr.slice=BP.slice;arr.readUIntLE=BP.readUIntLE;arr.readUIntBE=BP.readUIntBE;arr.readUInt8=BP.readUInt8;arr.readUInt16LE=BP.readUInt16LE;arr.readUInt16BE=BP.readUInt16BE;arr.readUInt32LE=BP.readUInt32LE;arr.readUInt32BE=BP.readUInt32BE;arr.readIntLE=BP.readIntLE;arr.readIntBE=BP.readIntBE;arr.readInt8=BP.readInt8;arr.readInt16LE=BP.readInt16LE;arr.readInt16BE=BP.readInt16BE;arr.readInt32LE=BP.readInt32LE;arr.readInt32BE=BP.readInt32BE;arr.readFloatLE=BP.readFloatLE;arr.readFloatBE=BP.readFloatBE;arr.readDoubleLE=BP.readDoubleLE;arr.readDoubleBE=BP.readDoubleBE;arr.writeUInt8=BP.writeUInt8;arr.writeUIntLE=BP.writeUIntLE;arr.writeUIntBE=BP.writeUIntBE;arr.writeUInt16LE=BP.writeUInt16LE;arr.writeUInt16BE=BP.writeUInt16BE;arr.writeUInt32LE=BP.writeUInt32LE;arr.writeUInt32BE=BP.writeUInt32BE;arr.writeIntLE=BP.writeIntLE;arr.writeIntBE=BP.writeIntBE;arr.writeInt8=BP.writeInt8;arr.writeInt16LE=BP.writeInt16LE;arr.writeInt16BE=BP.writeInt16BE;arr.writeInt32LE=BP.writeInt32LE;arr.writeInt32BE=BP.writeInt32BE;arr.writeFloatLE=BP.writeFloatLE;arr.writeFloatBE=BP.writeFloatBE;arr.writeDoubleLE=BP.writeDoubleLE;arr.writeDoubleBE=BP.writeDoubleBE;arr.fill=BP.fill;arr.inspect=BP.inspect;arr.toArrayBuffer=BP.toArrayBuffer;return arr};var INVALID_BASE64_RE=/[^+\/0-9A-z\-]/g;function base64clean(str){str=stringtrim(str).replace(INVALID_BASE64_RE,"");if(str.length<2)return"";while(str.length%4!==0){str=str+"="}return str}function stringtrim(str){if(str.trim)return str.trim();return str.replace(/^\s+|\s+$/g,"")}function isArrayish(subject){return isArray(subject)||Buffer.isBuffer(subject)||subject&&typeof subject==="object"&&typeof subject.length==="number"}function toHex(n){if(n<16)return"0"+n.toString(16); | |
return n.toString(16)}function utf8ToBytes(string,units){var codePoint,length=string.length;var leadSurrogate=null;units=units||Infinity;var bytes=[];var i=0;for(;i<length;i++){codePoint=string.charCodeAt(i);if(codePoint>55295&&codePoint<57344){if(leadSurrogate){if(codePoint<56320){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=codePoint;continue}else{codePoint=leadSurrogate-55296<<10|codePoint-56320|65536;leadSurrogate=null}}else{if(codePoint>56319){if((units-=3)>-1)bytes.push(239,191,189);continue}else if(i+1===length){if((units-=3)>-1)bytes.push(239,191,189);continue}else{leadSurrogate=codePoint;continue}}}else if(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=null}if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}else if(codePoint<2097152){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{throw new Error("Invalid code point")}}return bytes}function asciiToBytes(str){var byteArray=[];for(var i=0;i<str.length;i++){byteArray.push(str.charCodeAt(i)&255)}return byteArray}function utf16leToBytes(str,units){var c,hi,lo;var byteArray=[];for(var i=0;i<str.length;i++){if((units-=2)<0)break;c=str.charCodeAt(i);hi=c>>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length,unitSize){if(unitSize)length-=length%unitSize;for(var i=0;i<length;i++){if(i+offset>=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function decodeUtf8Char(str){try{return decodeURIComponent(str)}catch(err){return String.fromCharCode(65533)}}},{"base64-js":2,ieee754:3,"is-array":4}],2:[function(require,module,exports){var lookup="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(exports){"use strict";var Arr=typeof Uint8Array!=="undefined"?Uint8Array:Array;var PLUS="+".charCodeAt(0);var SLASH="/".charCodeAt(0);var NUMBER="0".charCodeAt(0);var LOWER="a".charCodeAt(0);var UPPER="A".charCodeAt(0);var PLUS_URL_SAFE="-".charCodeAt(0);var SLASH_URL_SAFE="_".charCodeAt(0);function decode(elt){var code=elt.charCodeAt(0);if(code===PLUS||code===PLUS_URL_SAFE)return 62;if(code===SLASH||code===SLASH_URL_SAFE)return 63;if(code<NUMBER)return-1;if(code<NUMBER+10)return code-NUMBER+26+26;if(code<UPPER+26)return code-UPPER;if(code<LOWER+26)return code-LOWER+26}function b64ToByteArray(b64){var i,j,l,tmp,placeHolders,arr;if(b64.length%4>0){throw new Error("Invalid string. Length must be a multiple of 4")}var len=b64.length;placeHolders="="===b64.charAt(len-2)?2:"="===b64.charAt(len-1)?1:0;arr=new Arr(b64.length*3/4-placeHolders);l=placeHolders>0?b64.length-4:b64.length;var L=0;function push(v){arr[L++]=v}for(i=0,j=0;i<l;i+=4,j+=3){tmp=decode(b64.charAt(i))<<18|decode(b64.charAt(i+1))<<12|decode(b64.charAt(i+2))<<6|decode(b64.charAt(i+3));push((tmp&16711680)>>16);push((tmp&65280)>>8);push(tmp&255)}if(placeHolders===2){tmp=decode(b64.charAt(i))<<2|decode(b64.charAt(i+1))>>4;push(tmp&255)}else if(placeHolders===1){tmp=decode(b64.charAt(i))<<10|decode(b64.charAt(i+1))<<4|decode(b64.charAt(i+2))>>2;push(tmp>>8&255);push(tmp&255)}return arr}function uint8ToBase64(uint8){var i,extraBytes=uint8.length%3,output="",temp,length;function encode(num){return lookup.charAt(num)}function tripletToBase64(num){return encode(num>>18&63)+encode(num>>12&63)+encode(num>>6&63)+encode(num&63)}for(i=0,length=uint8.length-extraBytes;i<length;i+=3){temp=(uint8[i]<<16)+(uint8[i+1]<<8)+uint8[i+2];output+=tripletToBase64(temp)}switch(extraBytes){case 1:temp=uint8[uint8.length-1];output+=encode(temp>>2);output+=encode(temp<<4&63);output+="==";break;case 2:temp=(uint8[uint8.length-2]<<8)+uint8[uint8.length-1];output+=encode(temp>>10);output+=encode(temp>>4&63);output+=encode(temp<<2&63);output+="=";break}return output}exports.toByteArray=b64ToByteArray;exports.fromByteArray=uint8ToBase64})(typeof exports==="undefined"?this.base64js={}:exports)},{}],3:[function(require,module,exports){exports.read=function(buffer,offset,isLE,mLen,nBytes){var e,m,eLen=nBytes*8-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>1,nBits=-7,i=isLE?nBytes-1:0,d=isLE?-1:1,s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8);m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8);if(e===0){e=1-eBias}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity}else{m=m+Math.pow(2,mLen);e=e-eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c,eLen=nBytes*8-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>1,rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0,i=isLE?0:nBytes-1,d=isLE?1:-1,s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2}if(e+eBias>=1){value+=rt/c}else{value+=rt*Math.pow(2,1-eBias)}if(value*c>=2){e++;c/=2}if(e+eBias>=eMax){m=0;e=eMax}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0}}for(;mLen>=8;buffer[offset+i]=m&255,i+=d,m/=256,mLen-=8);e=e<<mLen|m;eLen+=mLen;for(;eLen>0;buffer[offset+i]=e&255,i+=d,e/=256,eLen-=8);buffer[offset+i-d]|=s*128}},{}],4:[function(require,module,exports){var isArray=Array.isArray;var str=Object.prototype.toString;module.exports=isArray||function(val){return!!val&&"[object Array]"==str.call(val)}},{}],5:[function(require,module,exports){var used=[],exports=module.exports={};exports.version="2.2.0";exports.AssertionError=require("assertion-error");var util=require("./chai/utils");exports.use=function(fn){if(!~used.indexOf(fn)){fn(this,util);used.push(fn)}return this};exports.util=util;var config=require("./chai/config");exports.config=config;var assertion=require("./chai/assertion");exports.use(assertion);var core=require("./chai/core/assertions");exports.use(core);var expect=require("./chai/interface/expect");exports.use(expect);var should=require("./chai/interface/should");exports.use(should);var assert=require("./chai/interface/assert");exports.use(assert)},{"./chai/assertion":6,"./chai/config":7,"./chai/core/assertions":8,"./chai/interface/assert":9,"./chai/interface/expect":10,"./chai/interface/should":11,"./chai/utils":24,"assertion-error":33}],6:[function(require,module,exports){var config=require("./config");module.exports=function(_chai,util){var AssertionError=_chai.AssertionError,flag=util.flag;_chai.Assertion=Assertion;function Assertion(obj,msg,stack){flag(this,"ssfi",stack||arguments.callee);flag(this,"object",obj);flag(this,"message",msg)}Object.defineProperty(Assertion,"includeStack",{get:function(){console.warn("Assertion.includeStack is deprecated, use chai.config.includeStack instead.");return config.includeStack},set:function(value){console.warn("Assertion.includeStack is deprecated, use chai.config.includeStack instead.");config.includeStack=value}});Object.defineProperty(Assertion,"showDiff",{get:function(){console.warn("Assertion.showDiff is deprecated, use chai.config.showDiff instead.");return config.showDiff},set:function(value){console.warn("Assertion.showDiff is deprecated, use chai.config.showDiff instead.");config.showDiff=value}});Assertion.addProperty=function(name,fn){util.addProperty(this.prototype,name,fn)};Assertion.addMethod=function(name,fn){util.addMethod(this.prototype,name,fn)};Assertion.addChainableMethod=function(name,fn,chainingBehavior){util.addChainableMethod(this.prototype,name,fn,chainingBehavior)};Assertion.overwriteProperty=function(name,fn){util.overwriteProperty(this.prototype,name,fn)};Assertion.overwriteMethod=function(name,fn){util.overwriteMethod(this.prototype,name,fn)};Assertion.overwriteChainableMethod=function(name,fn,chainingBehavior){util.overwriteChainableMethod(this.prototype,name,fn,chainingBehavior)};Assertion.prototype.assert=function(expr,msg,negateMsg,expected,_actual,showDiff){var ok=util.test(this,arguments);if(true!==showDiff)showDiff=false;if(true!==config.showDiff)showDiff=false;if(!ok){var msg=util.getMessage(this,arguments),actual=util.getActual(this,arguments);throw new AssertionError(msg,{actual:actual,expected:expected,showDiff:showDiff},config.includeStack?this.assert:flag(this,"ssfi"))}};Object.defineProperty(Assertion.prototype,"_obj",{get:function(){return flag(this,"object")},set:function(val){flag(this,"object",val)}})}},{"./config":7}],7:[function(require,module,exports){module.exports={includeStack:false,showDiff:true,truncateThreshold:40}},{}],8:[function(require,module,exports){module.exports=function(chai,_){var Assertion=chai.Assertion,toString=Object.prototype.toString,flag=_.flag;["to","be","been","is","and","has","have","with","that","which","at","of","same"].forEach(function(chain){Assertion.addProperty(chain,function(){return this})});Assertion.addProperty("not",function(){flag(this,"negate",true)});Assertion.addProperty("deep",function(){flag(this,"deep",true)});Assertion.addProperty("any",function(){flag(this,"any",true);flag(this,"all",false)});Assertion.addProperty("all",function(){flag(this,"all",true);flag(this,"any",false)});function an(type,msg){if(msg)flag(this,"message",msg);type=type.toLowerCase();var obj=flag(this,"object"),article=~["a","e","i","o","u"].indexOf(type.charAt(0))?"an ":"a ";this.assert(type===_.type(obj),"expected #{this} to be "+article+type,"expected #{this} not to be "+article+type)}Assertion.addChainableMethod("an",an);Assertion.addChainableMethod("a",an);function includeChainingBehavior(){flag(this,"contains",true)}function include(val,msg){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)){expected=true;break}}}else if(_.type(val)==="object"){if(!flag(this,"negate")){for(var k in val)new Assertion(obj).property(k,val[k]);return}var subset={};for(var k in val)subset[k]=obj[k];expected=_.eql(subset,val)}else{expected=obj&&~obj.indexOf(val)}this.assert(expected,"expected #{this} to include "+_.inspect(val),"expected #{this} to not include "+_.inspect(val))}Assertion.addChainableMethod("include",include,includeChainingBehavior);Assertion.addChainableMethod("contain",include,includeChainingBehavior);Assertion.addChainableMethod("contains",include,includeChainingBehavior);Assertion.addChainableMethod("includes",include,includeChainingBehavior);Assertion.addProperty("ok",function(){this.assert(flag(this,"object"),"expected #{this} to be truthy","expected #{this} to be falsy")});Assertion.addProperty("true",function(){this.assert(true===flag(this,"object"),"expected #{this} to be true","expected #{this} to be false",this.negate?false:true)});Assertion.addProperty("false",function(){this.assert(false===flag(this,"object"),"expected #{this} to be false","expected #{this} to be true",this.negate?true:false)});Assertion.addProperty("null",function(){this.assert(null===flag(this,"object"),"expected #{this} to be null","expected #{this} not to be null")});Assertion.addProperty("undefined",function(){this.assert(undefined===flag(this,"object"),"expected #{this} to be undefined","expected #{this} not to be undefined")});Assertion.addProperty("exist",function(){this.assert(null!=flag(this,"object"),"expected #{this} to exist","expected #{this} to not exist")});Assertion.addProperty("empty",function(){var obj=flag(this,"object"),expected=obj;if(Array.isArray(obj)||"string"===typeof object){expected=obj.length}else if(typeof obj==="object"){expected=Object.keys(obj).length}this.assert(!expected,"expected #{this} to be empty","expected #{this} not to be empty")});function checkArguments(){var obj=flag(this,"object"),type=Object.prototype.toString.call(obj);this.assert("[object Arguments]"===type,"expected #{this} to be arguments but got "+type,"expected #{this} to not be arguments")}Assertion.addProperty("arguments",checkArguments);Assertion.addProperty("Arguments",checkArguments);function assertEqual(val,msg){if(msg)flag(this,"message",msg);var obj=flag(this,"object");if(flag(this,"deep")){return this.eql(val)}else{this.assert(val===obj,"expected #{this} to equal #{exp}","expected #{this} to not equal #{exp}",val,this._obj,true)}}Assertion.addMethod("equal",assertEqual);Assertion.addMethod("equals",assertEqual);Assertion.addMethod("eq",assertEqual);function assertEql(obj,msg){if(msg)flag(this,"message",msg);this.assert(_.eql(obj,flag(this,"object")),"expected #{this} to deeply equal #{exp}","expected #{this} to not deeply equal #{exp}",obj,this._obj,true)}Assertion.addMethod("eql",assertEql);Assertion.addMethod("eqls",assertEql);function assertAbove(n,msg){if(msg)flag(this,"message",msg);var obj=flag(this,"object");if(flag(this,"doLength")){new Assertion(obj,msg).to.have.property("length");var len=obj.length;this.assert(len>n,"expected #{this} to have a length above #{exp} but got #{act}","expected #{this} to not have a length above #{exp}",n,len)}else{this.assert(obj>n,"expected #{this} to be above "+n,"expected #{this} to be at most "+n)}}Assertion.addMethod("above",assertAbove);Assertion.addMethod("gt",assertAbove);Assertion.addMethod("greaterThan",assertAbove);function assertLeast(n,msg){if(msg)flag(this,"message",msg);var obj=flag(this,"object");if(flag(this,"doLength")){new Assertion(obj,msg).to.have.property("length");var len=obj.length;this.assert(len>=n,"expected #{this} to have a length at least #{exp} but got #{act}","expected #{this} to have a length below #{exp}",n,len)}else{this.assert(obj>=n,"expected #{this} to be at least "+n,"expected #{this} to be below "+n)}}Assertion.addMethod("least",assertLeast);Assertion.addMethod("gte",assertLeast);function assertBelow(n,msg){if(msg)flag(this,"message",msg);var obj=flag(this,"object");if(flag(this,"doLength")){new Assertion(obj,msg).to.have.property("length");var len=obj.length;this.assert(len<n,"expected #{this} to have a length below #{exp} but got #{act}","expected #{this} to not have a length below #{exp}",n,len)}else{this.assert(obj<n,"expected #{this} to be below "+n,"expected #{this} to be at least "+n)}}Assertion.addMethod("below",assertBelow);Assertion.addMethod("lt",assertBelow);Assertion.addMethod("lessThan",assertBelow);function assertMost(n,msg){if(msg)flag(this,"message",msg);var obj=flag(this,"object");if(flag(this,"doLength")){new Assertion(obj,msg).to.have.property("length");var len=obj.length;this.assert(len<=n,"expected #{this} to have a length at most #{exp} but got #{act}","expected #{this} to have a length above #{exp}",n,len)}else{this.assert(obj<=n,"expected #{this} to be at most "+n,"expected #{this} to be above "+n)}}Assertion.addMethod("most",assertMost);Assertion.addMethod("lte",assertMost);Assertion.addMethod("within",function(start,finish,msg){if(msg)flag(this,"message",msg);var obj=flag(this,"object"),range=start+".."+finish;if(flag(this,"doLength")){new Assertion(obj,msg).to.have.property("length");var len=obj.length;this.assert(len>=start&&len<=finish,"expected #{this} to have a length within "+range,"expected #{this} to not have a length within "+range)}else{this.assert(obj>=start&&obj<=finish,"expected #{this} to be within "+range,"expected #{this} to not be within "+range)}});function assertInstanceOf(constructor,msg){if(msg)flag(this,"message",msg);var name=_.getName(constructor);this.assert(flag(this,"object")instanceof constructor,"expected #{this} to be an instance of "+name,"expected #{this} to not be an instance of "+name)}Assertion.addMethod("instanceof",assertInstanceOf);Assertion.addMethod("instanceOf",assertInstanceOf);Assertion.addMethod("property",function(name,val,msg){if(msg)flag(this,"message",msg);var isDeep=!!flag(this,"deep"),descriptor=isDeep?"deep property ":"property ",negate=flag(this,"negate"),obj=flag(this,"object"),pathInfo=isDeep?_.getPathInfo(name,obj):null,hasProperty=isDeep?pathInfo.exists:_.hasProperty(name,obj),value=isDeep?pathInfo.value:obj[name];if(negate&&undefined!==val){if(undefined===value){msg=msg!=null?msg+": ":"";throw new Error(msg+_.inspect(obj)+" has no "+descriptor+_.inspect(name))}}else{this.assert(hasProperty,"expected #{this} to have a "+descriptor+_.inspect(name),"expected #{this} to not have "+descriptor+_.inspect(name))}if(undefined!==val){this.assert(val===value,"expected #{this} to have a "+descriptor+_.inspect(name)+" of #{exp}, but got #{act}","expected #{this} to not have a "+descriptor+_.inspect(name)+" of #{act}",val,value)}flag(this,"object",value)});function assertOwnProperty(name,msg){if(msg)flag(this,"message",msg);var obj=flag(this,"object");this.assert(obj.hasOwnProperty(name),"expected #{this} to have own property "+_.inspect(name),"expected #{this} to not have own property "+_.inspect(name))}Assertion.addMethod("ownProperty",assertOwnProperty);Assertion.addMethod("haveOwnProperty",assertOwnProperty);function assertLengthChain(){flag(this,"doLength",true)}function assertLength(n,msg){if(msg)flag(this,"message",msg);var obj=flag(this,"object");new Assertion(obj,msg).to.have.property("length");var len=obj.length;this.assert(len==n,"expected #{this} to have a length of #{exp} but got #{act}","expected #{this} to not have a length of #{act}",n,len)}Assertion.addChainableMethod("length",assertLength,assertLengthChain);Assertion.addMethod("lengthOf",assertLength);Assertion.addMethod("match",function(re,msg){if(msg)flag(this,"message",msg);var obj=flag(this,"object");this.assert(re.exec(obj),"expected #{this} to match "+re,"expected #{this} not to match "+re)});Assertion.addMethod("string",function(str,msg){if(msg)flag(this,"message",msg);var obj=flag(this,"object");new Assertion(obj,msg).is.a("string");this.assert(~obj.indexOf(str),"expected #{this} to contain "+_.inspect(str),"expected #{this} to not contain "+_.inspect(str))});function assertKeys(keys){var obj=flag(this,"object"),str,ok=true,mixedArgsMsg="keys must be given single argument of Array|Object|String, or multiple String arguments";switch(_.type(keys)){case"array":if(arguments.length>1)throw new Error(mixedArgsMsg);break;case"object":if(arguments.length>1)throw new Error(mixedArgsMsg);keys=Object.keys(keys);break;default:keys=Array.prototype.slice.call(arguments)}if(!keys.length)throw new Error("keys required");var actual=Object.keys(obj),expected=keys,len=keys.length,any=flag(this,"any"),all=flag(this,"all");if(!any&&!all){all=true}if(any){var intersection=expected.filter(function(key){return~actual.indexOf(key)});ok=intersection.length>0}if(all){ok=keys.every(function(key){return~actual.indexOf(key)});if(!flag(this,"negate")&&!flag(this,"contains")){ok=ok&&keys.length==actual.length}}if(len>1){keys=keys.map(function(key){return _.inspect(key)});var last=keys.pop();if(all){str=keys.join(", ")+", and "+last}if(any){str=keys.join(", ")+", or "+last}}else{str=_.inspect(keys[0])}str=(len>1?"keys ":"key ")+str;str=(flag(this,"contains")?"contain ":"have ")+str;this.assert(ok,"expected #{this} to "+str,"expected #{this} to not "+str,expected.slice(0).sort(),actual.sort(),true)}Assertion.addMethod("keys",assertKeys);Assertion.addMethod("key",assertKeys);function assertThrows(constructor,errMsg,msg){if(msg)flag(this,"message",msg);var obj=flag(this,"object");new Assertion(obj,msg).is.a("function");var thrown=false,desiredError=null,name=null,thrownError=null;if(arguments.length===0){errMsg=null;constructor=null}else if(constructor&&(constructor instanceof RegExp||"string"===typeof constructor)){errMsg=constructor;constructor=null}else if(constructor&&constructor instanceof Error){desiredError=constructor;constructor=null;errMsg=null}else if(typeof constructor==="function"){name=constructor.prototype.name||constructor.name;if(name==="Error"&&constructor!==Error){name=(new constructor).name}}else{constructor=null}try{obj()}catch(err){if(desiredError){this.assert(err===desiredError,"expected #{this} to throw #{exp} but #{act} was thrown","expected #{this} to not throw #{exp}",desiredError instanceof Error?desiredError.toString():desiredError,err instanceof Error?err.toString():err);flag(this,"object",err);return this}if(constructor){this.assert(err instanceof constructor,"expected #{this} to throw #{exp} but #{act} was thrown","expected #{this} to not throw #{exp} but #{act} was thrown",name,err instanceof Error?err.toString():err);if(!errMsg){flag(this,"object",err);return this}}var message="object"===_.type(err)&&"message"in err?err.message:""+err;if(message!=null&&errMsg&&errMsg instanceof RegExp){this.assert(errMsg.exec(message),"expected #{this} to throw error matching #{exp} but got #{act}","expected #{this} to throw error not matching #{exp}",errMsg,message);flag(this,"object",err);return this}else if(message!=null&&errMsg&&"string"===typeof errMsg){this.assert(~message.indexOf(errMsg),"expected #{this} to throw error including #{exp} but got #{act}","expected #{this} to throw error not including #{act}",errMsg,message);flag(this,"object",err);return this}else{thrown=true;thrownError=err}}var actuallyGot="",expectedThrown=name!==null?name:desiredError?"#{exp}":"an error";if(thrown){actuallyGot=" but #{act} was thrown"}this.assert(thrown===true,"expected #{this} to throw "+expectedThrown+actuallyGot,"expected #{this} to not throw "+expectedThrown+actuallyGot,desiredError instanceof Error?desiredError.toString():desiredError,thrownError instanceof Error?thrownError.toString():thrownError);flag(this,"object",thrownError)}Assertion.addMethod("throw",assertThrows);Assertion.addMethod("throws",assertThrows);Assertion.addMethod("Throw",assertThrows);Assertion.addMethod("respondTo",function(method,msg){if(msg)flag(this,"message",msg);var obj=flag(this,"object"),itself=flag(this,"itself"),context="function"===_.type(obj)&&!itself?obj.prototype[method]:obj[method];this.assert("function"===typeof context,"expected #{this} to respond to "+_.inspect(method),"expected #{this} to not respond to "+_.inspect(method))});Assertion.addProperty("itself",function(){flag(this,"itself",true)});Assertion.addMethod("satisfy",function(matcher,msg){if(msg)flag(this,"message",msg);var obj=flag(this,"object");var result=matcher(obj);this.assert(result,"expected #{this} to satisfy "+_.objDisplay(matcher),"expected #{this} to not satisfy"+_.objDisplay(matcher),this.negate?false:true,result)});Assertion.addMethod("closeTo",function(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")}this.assert(Math.abs(obj-expected)<=delta,"expected #{this} to be close to "+expected+" +/- "+delta,"expected #{this} not to be close to "+expected+" +/- "+delta)});function isSubsetOf(subset,superset,cmp){return subset.every(function(elem){if(!cmp)return superset.indexOf(elem)!==-1;return superset.some(function(elem2){return cmp(elem,elem2)})})}Assertion.addMethod("members",function(subset,msg){if(msg)flag(this,"message",msg);var obj=flag(this,"object");new Assertion(obj).to.be.an("array");new Assertion(subset).to.be.an("array");var cmp=flag(this,"deep")?_.eql:undefined;if(flag(this,"contains")){return this.assert(isSubsetOf(subset,obj,cmp),"expected #{this} to be a superset of #{act}","expected #{this} to not be a superset of #{act}",obj,subset)}this.assert(isSubsetOf(obj,subset,cmp)&&isSubsetOf(subset,obj,cmp),"expected #{this} to have the same members as #{act}","expected #{this} to not have the same members as #{act}",obj,subset)});function assertChanges(object,prop,msg){if(msg)flag(this,"message",msg);var fn=flag(this,"object");new Assertion(object,msg).to.have.property(prop);new Assertion(fn).is.a("function");var initial=object[prop];fn();this.assert(initial!==object[prop],"expected ."+prop+" to change","expected ."+prop+" to not change")}Assertion.addChainableMethod("change",assertChanges);Assertion.addChainableMethod("changes",assertChanges);function assertIncreases(object,prop,msg){if(msg)flag(this,"message",msg);var fn=flag(this,"object");new Assertion(object,msg).to.have.property(prop);new Assertion(fn).is.a("function");var initial=object[prop];fn();this.assert(object[prop]-initial>0,"expected ."+prop+" to increase","expected ."+prop+" to not increase")}Assertion.addChainableMethod("increase",assertIncreases);Assertion.addChainableMethod("increases",assertIncreases);function assertDecreases(object,prop,msg){if(msg)flag(this,"message",msg);var fn=flag(this,"object");new Assertion(object,msg).to.have.property(prop);new Assertion(fn).is.a("function");var initial=object[prop];fn();this.assert(object[prop]-initial<0,"expected ."+prop+" to decrease","expected ."+prop+" to not decrease")}Assertion.addChainableMethod("decrease",assertDecreases);Assertion.addChainableMethod("decreases",assertDecreases)}},{}],9:[function(require,module,exports){module.exports=function(chai,util){var Assertion=chai.Assertion,flag=util.flag;var assert=chai.assert=function(express,errmsg){var test=new Assertion(null,null,chai.assert);test.assert(express,errmsg,"[ negation message unavailable ]")};assert.fail=function(actual,expected,message,operator){message=message||"assert.fail()";throw new chai.AssertionError(message,{actual:actual,expected:expected,operator:operator},assert.fail)};assert.ok=function(val,msg){new Assertion(val,msg).is.ok};assert.notOk=function(val,msg){new Assertion(val,msg).is.not.ok};assert.equal=function(act,exp,msg){var test=new Assertion(act,msg,assert.equal);test.assert(exp==flag(test,"object"),"expected #{this} to equal #{exp}","expected #{this} to not equal #{act}",exp,act)};assert.notEqual=function(act,exp,msg){var test=new Assertion(act,msg,assert.notEqual);test.assert(exp!=flag(test,"object"),"expected #{this} to not equal #{exp}","expected #{this} to equal #{act}",exp,act)};assert.strictEqual=function(act,exp,msg){new Assertion(act,msg).to.equal(exp)};assert.notStrictEqual=function(act,exp,msg){new Assertion(act,msg).to.not.equal(exp)};assert.deepEqual=function(act,exp,msg){new Assertion(act,msg).to.eql(exp)};assert.notDeepEqual=function(act,exp,msg){new Assertion(act,msg).to.not.eql(exp)};assert.isAbove=function(val,abv,msg){new Assertion(val,msg).to.be.above(abv)};assert.isBelow=function(val,blw,msg){new Assertion(val,msg).to.be.below(blw)};assert.isTrue=function(val,msg){new Assertion(val,msg).is["true"]};assert.isFalse=function(val,msg){new Assertion(val,msg).is["false"]};assert.isNull=function(val,msg){new Assertion(val,msg).to.equal(null)};assert.isNotNull=function(val,msg){new Assertion(val,msg).to.not.equal(null)};assert.isUndefined=function(val,msg){new Assertion(val,msg).to.equal(undefined)};assert.isDefined=function(val,msg){new Assertion(val,msg).to.not.equal(undefined)};assert.isFunction=function(val,msg){new Assertion(val,msg).to.be.a("function")};assert.isNotFunction=function(val,msg){new Assertion(val,msg).to.not.be.a("function")};assert.isObject=function(val,msg){new Assertion(val,msg).to.be.a("object")};assert.isNotObject=function(val,msg){new Assertion(val,msg).to.not.be.a("object")};assert.isArray=function(val,msg){new Assertion(val,msg).to.be.an("array")};assert.isNotArray=function(val,msg){new Assertion(val,msg).to.not.be.an("array")};assert.isString=function(val,msg){new Assertion(val,msg).to.be.a("string")};assert.isNotString=function(val,msg){new Assertion(val,msg).to.not.be.a("string")};assert.isNumber=function(val,msg){new Assertion(val,msg).to.be.a("number")};assert.isNotNumber=function(val,msg){new Assertion(val,msg).to.not.be.a("number")};assert.isBoolean=function(val,msg){new Assertion(val,msg).to.be.a("boolean")};assert.isNotBoolean=function(val,msg){new Assertion(val,msg).to.not.be.a("boolean")};assert.typeOf=function(val,type,msg){new Assertion(val,msg).to.be.a(type)};assert.notTypeOf=function(val,type,msg){new Assertion(val,msg).to.not.be.a(type)};assert.instanceOf=function(val,type,msg){new Assertion(val,msg).to.be.instanceOf(type)};assert.notInstanceOf=function(val,type,msg){new Assertion(val,msg).to.not.be.instanceOf(type)};assert.include=function(exp,inc,msg){new Assertion(exp,msg,assert.include).include(inc)};assert.notInclude=function(exp,inc,msg){new Assertion(exp,msg,assert.notInclude).not.include(inc)};assert.match=function(exp,re,msg){new Assertion(exp,msg).to.match(re)};assert.notMatch=function(exp,re,msg){new Assertion(exp,msg).to.not.match(re)};assert.property=function(obj,prop,msg){new Assertion(obj,msg).to.have.property(prop)};assert.notProperty=function(obj,prop,msg){new Assertion(obj,msg).to.not.have.property(prop)};assert.deepProperty=function(obj,prop,msg){new Assertion(obj,msg).to.have.deep.property(prop)};assert.notDeepProperty=function(obj,prop,msg){new Assertion(obj,msg).to.not.have.deep.property(prop)};assert.propertyVal=function(obj,prop,val,msg){new Assertion(obj,msg).to.have.property(prop,val)};assert.propertyNotVal=function(obj,prop,val,msg){new Assertion(obj,msg).to.not.have.property(prop,val)};assert.deepPropertyVal=function(obj,prop,val,msg){new Assertion(obj,msg).to.have.deep.property(prop,val)};assert.deepPropertyNotVal=function(obj,prop,val,msg){new Assertion(obj,msg).to.not.have.deep.property(prop,val)};assert.lengthOf=function(exp,len,msg){new Assertion(exp,msg).to.have.length(len)};assert.Throw=function(fn,errt,errs,msg){if("string"===typeof errt||errt instanceof RegExp){errs=errt;errt=null}var assertErr=new Assertion(fn,msg).to.Throw(errt,errs);return flag(assertErr,"object")};assert.doesNotThrow=function(fn,type,msg){if("string"===typeof type){msg=type;type=null}new Assertion(fn,msg).to.not.Throw(type)};assert.operator=function(val,operator,val2,msg){var ok;switch(operator){case"==":ok=val==val2;break;case"===":ok=val===val2;break;case">":ok=val>val2;break;case">=":ok=val>=val2;break;case"<":ok=val<val2;break;case"<=":ok=val<=val2;break;case"!=":ok=val!=val2;break;case"!==":ok=val!==val2;break;default:throw new Error('Invalid operator "'+operator+'"')}var test=new Assertion(ok,msg);test.assert(true===flag(test,"object"),"expected "+util.inspect(val)+" to be "+operator+" "+util.inspect(val2),"expected "+util.inspect(val)+" to not be "+operator+" "+util.inspect(val2))};assert.closeTo=function(act,exp,delta,msg){new Assertion(act,msg).to.be.closeTo(exp,delta)};assert.sameMembers=function(set1,set2,msg){new Assertion(set1,msg).to.have.same.members(set2)};assert.sameDeepMembers=function(set1,set2,msg){new Assertion(set1,msg).to.have.same.deep.members(set2)};assert.includeMembers=function(superset,subset,msg){new Assertion(superset,msg).to.include.members(subset)};assert.changes=function(fn,obj,prop){new Assertion(fn).to.change(obj,prop)};assert.doesNotChange=function(fn,obj,prop){new Assertion(fn).to.not.change(obj,prop)};assert.increases=function(fn,obj,prop){new Assertion(fn).to.increase(obj,prop)};assert.doesNotIncrease=function(fn,obj,prop){new Assertion(fn).to.not.increase(obj,prop)};assert.decreases=function(fn,obj,prop){new Assertion(fn).to.decrease(obj,prop)};assert.doesNotDecrease=function(fn,obj,prop){new Assertion(fn).to.not.decrease(obj,prop)};assert.ifError=function(val,msg){new Assertion(val,msg).to.not.be.ok};(function alias(name,as){assert[as]=assert[name];return alias})("Throw","throw")("Throw","throws")}},{}],10:[function(require,module,exports){module.exports=function(chai,util){chai.expect=function(val,message){return new chai.Assertion(val,message)};chai.expect.fail=function(actual,expected,message,operator){message=message||"expect.fail()";throw new chai.AssertionError(message,{actual:actual,expected:expected,operator:operator},chai.expect.fail)}}},{}],11:[function(require,module,exports){module.exports=function(chai,util){var Assertion=chai.Assertion;function loadShould(){function shouldGetter(){ | |
if(this instanceof String||this instanceof Number||this instanceof Boolean){return new Assertion(this.valueOf(),null,shouldGetter)}return new Assertion(this,null,shouldGetter)}function shouldSetter(value){Object.defineProperty(this,"should",{value:value,enumerable:true,configurable:true,writable:true})}Object.defineProperty(Object.prototype,"should",{set:shouldSetter,get:shouldGetter,configurable:true});var should={};should.fail=function(actual,expected,message,operator){message=message||"should.fail()";throw new chai.AssertionError(message,{actual:actual,expected:expected,operator:operator},should.fail)};should.equal=function(val1,val2,msg){new Assertion(val1,msg).to.equal(val2)};should.Throw=function(fn,errt,errs,msg){new Assertion(fn,msg).to.Throw(errt,errs)};should.exist=function(val,msg){new Assertion(val,msg).to.exist};should.not={};should.not.equal=function(val1,val2,msg){new Assertion(val1,msg).to.not.equal(val2)};should.not.Throw=function(fn,errt,errs,msg){new Assertion(fn,msg).to.not.Throw(errt,errs)};should.not.exist=function(val,msg){new Assertion(val,msg).to.not.exist};should["throw"]=should["Throw"];should.not["throw"]=should.not["Throw"];return should}chai.should=loadShould;chai.Should=loadShould}},{}],12:[function(require,module,exports){var transferFlags=require("./transferFlags");var flag=require("./flag");var config=require("../config");var hasProtoSupport="__proto__"in Object;var excludeNames=/^(?:length|name|arguments|caller)$/;var call=Function.prototype.call,apply=Function.prototype.apply;module.exports=function(ctx,name,method,chainingBehavior){if(typeof chainingBehavior!=="function"){chainingBehavior=function(){}}var chainableBehavior={method:method,chainingBehavior:chainingBehavior};if(!ctx.__methods){ctx.__methods={}}ctx.__methods[name]=chainableBehavior;Object.defineProperty(ctx,name,{get:function(){chainableBehavior.chainingBehavior.call(this);var assert=function assert(){var old_ssfi=flag(this,"ssfi");if(old_ssfi&&config.includeStack===false)flag(this,"ssfi",assert);var result=chainableBehavior.method.apply(this,arguments);return result===undefined?this:result};if(hasProtoSupport){var prototype=assert.__proto__=Object.create(this);prototype.call=call;prototype.apply=apply}else{var asserterNames=Object.getOwnPropertyNames(ctx);asserterNames.forEach(function(asserterName){if(!excludeNames.test(asserterName)){var pd=Object.getOwnPropertyDescriptor(ctx,asserterName);Object.defineProperty(assert,asserterName,pd)}})}transferFlags(this,assert);return assert},configurable:true})}},{"../config":7,"./flag":15,"./transferFlags":31}],13:[function(require,module,exports){var config=require("../config");var flag=require("./flag");module.exports=function(ctx,name,method){ctx[name]=function(){var old_ssfi=flag(this,"ssfi");if(old_ssfi&&config.includeStack===false)flag(this,"ssfi",ctx[name]);var result=method.apply(this,arguments);return result===undefined?this:result}}},{"../config":7,"./flag":15}],14:[function(require,module,exports){module.exports=function(ctx,name,getter){Object.defineProperty(ctx,name,{get:function(){var result=getter.call(this);return result===undefined?this:result},configurable:true})}},{}],15:[function(require,module,exports){module.exports=function(obj,key,value){var flags=obj.__flags||(obj.__flags=Object.create(null));if(arguments.length===3){flags[key]=value}else{return flags[key]}}},{}],16:[function(require,module,exports){module.exports=function(obj,args){return args.length>4?args[4]:obj._obj}},{}],17:[function(require,module,exports){module.exports=function getEnumerableProperties(object){var result=[];for(var name in object){result.push(name)}return result}},{}],18:[function(require,module,exports){var flag=require("./flag"),getActual=require("./getActual"),inspect=require("./inspect"),objDisplay=require("./objDisplay");module.exports=function(obj,args){var negate=flag(obj,"negate"),val=flag(obj,"object"),expected=args[3],actual=getActual(obj,args),msg=negate?args[2]:args[1],flagMsg=flag(obj,"message");if(typeof msg==="function")msg=msg();msg=msg||"";msg=msg.replace(/#{this}/g,objDisplay(val)).replace(/#{act}/g,objDisplay(actual)).replace(/#{exp}/g,objDisplay(expected));return flagMsg?flagMsg+": "+msg:msg}},{"./flag":15,"./getActual":16,"./inspect":25,"./objDisplay":26}],19:[function(require,module,exports){module.exports=function(func){if(func.name)return func.name;var match=/^\s?function ([^(]*)\(/.exec(func);return match&&match[1]?match[1]:""}},{}],20:[function(require,module,exports){var hasProperty=require("./hasProperty");module.exports=function getPathInfo(path,obj){var parsed=parsePath(path),last=parsed[parsed.length-1];var info={parent:parsed.length>1?_getPathValue(parsed,obj,parsed.length-1):obj,name:last.p||last.i,value:_getPathValue(parsed,obj)};info.exists=hasProperty(info.name,info.parent);return info};function parsePath(path){var str=path.replace(/([^\\])\[/g,"$1.["),parts=str.match(/(\\\.|[^.]+?)+/g);return parts.map(function(value){var re=/^\[(\d+)\]$/,mArr=re.exec(value);if(mArr)return{i:parseFloat(mArr[1])};else return{p:value.replace(/\\([.\[\]])/g,"$1")}})}function _getPathValue(parsed,obj,index){var tmp=obj,res;index=index===undefined?parsed.length:index;for(var i=0,l=index;i<l;i++){var part=parsed[i];if(tmp){if("undefined"!==typeof part.p)tmp=tmp[part.p];else if("undefined"!==typeof part.i)tmp=tmp[part.i];if(i==l-1)res=tmp}else{res=undefined}}return res}},{"./hasProperty":23}],21:[function(require,module,exports){var getPathInfo=require("./getPathInfo");module.exports=function(path,obj){var info=getPathInfo(path,obj);return info.value}},{"./getPathInfo":20}],22:[function(require,module,exports){module.exports=function getProperties(object){var result=Object.getOwnPropertyNames(subject);function addProperty(property){if(result.indexOf(property)===-1){result.push(property)}}var proto=Object.getPrototypeOf(subject);while(proto!==null){Object.getOwnPropertyNames(proto).forEach(addProperty);proto=Object.getPrototypeOf(proto)}return result}},{}],23:[function(require,module,exports){var type=require("./type");var literals={number:Number,string:String};module.exports=function hasProperty(name,obj){var ot=type(obj);if(ot==="null"||ot==="undefined")return false;if(literals[ot]&&typeof obj!=="object")obj=new literals[ot](obj);return name in obj}},{"./type":32}],24:[function(require,module,exports){var exports=module.exports={};exports.test=require("./test");exports.type=require("./type");exports.getMessage=require("./getMessage");exports.getActual=require("./getActual");exports.inspect=require("./inspect");exports.objDisplay=require("./objDisplay");exports.flag=require("./flag");exports.transferFlags=require("./transferFlags");exports.eql=require("deep-eql");exports.getPathValue=require("./getPathValue");exports.getPathInfo=require("./getPathInfo");exports.hasProperty=require("./hasProperty");exports.getName=require("./getName");exports.addProperty=require("./addProperty");exports.addMethod=require("./addMethod");exports.overwriteProperty=require("./overwriteProperty");exports.overwriteMethod=require("./overwriteMethod");exports.addChainableMethod=require("./addChainableMethod");exports.overwriteChainableMethod=require("./overwriteChainableMethod")},{"./addChainableMethod":12,"./addMethod":13,"./addProperty":14,"./flag":15,"./getActual":16,"./getMessage":18,"./getName":19,"./getPathInfo":20,"./getPathValue":21,"./hasProperty":23,"./inspect":25,"./objDisplay":26,"./overwriteChainableMethod":27,"./overwriteMethod":28,"./overwriteProperty":29,"./test":30,"./transferFlags":31,"./type":32,"deep-eql":34}],25:[function(require,module,exports){var getName=require("./getName");var getProperties=require("./getProperties");var getEnumerableProperties=require("./getEnumerableProperties");module.exports=inspect;function inspect(obj,showHidden,depth,colors){var ctx={showHidden:showHidden,seen:[],stylize:function(str){return str}};return formatValue(ctx,obj,typeof depth==="undefined"?2:depth)}var isDOMElement=function(object){if(typeof HTMLElement==="object"){return object instanceof HTMLElement}else{return object&&typeof object==="object"&&object.nodeType===1&&typeof object.nodeName==="string"}};function formatValue(ctx,value,recurseTimes){if(value&&typeof value.inspect==="function"&&value.inspect!==exports.inspect&&!(value.constructor&&value.constructor.prototype===value)){var ret=value.inspect(recurseTimes);if(typeof ret!=="string"){ret=formatValue(ctx,ret,recurseTimes)}return ret}var primitive=formatPrimitive(ctx,value);if(primitive){return primitive}if(isDOMElement(value)){if("outerHTML"in value){return value.outerHTML}else{try{if(document.xmlVersion){var xmlSerializer=new XMLSerializer;return xmlSerializer.serializeToString(value)}else{var ns="http://www.w3.org/1999/xhtml";var container=document.createElementNS(ns,"_");container.appendChild(value.cloneNode(false));html=container.innerHTML.replace("><",">"+value.innerHTML+"<");container.innerHTML="";return html}}catch(err){}}}var visibleKeys=getEnumerableProperties(value);var keys=ctx.showHidden?getProperties(value):visibleKeys;if(keys.length===0||isError(value)&&(keys.length===1&&keys[0]==="stack"||keys.length===2&&keys[0]==="description"&&keys[1]==="stack")){if(typeof value==="function"){var name=getName(value);var nameSuffix=name?": "+name:"";return ctx.stylize("[Function"+nameSuffix+"]","special")}if(isRegExp(value)){return ctx.stylize(RegExp.prototype.toString.call(value),"regexp")}if(isDate(value)){return ctx.stylize(Date.prototype.toUTCString.call(value),"date")}if(isError(value)){return formatError(value)}}var base="",array=false,braces=["{","}"];if(isArray(value)){array=true;braces=["[","]"]}if(typeof value==="function"){var name=getName(value);var nameSuffix=name?": "+name:"";base=" [Function"+nameSuffix+"]"}if(isRegExp(value)){base=" "+RegExp.prototype.toString.call(value)}if(isDate(value)){base=" "+Date.prototype.toUTCString.call(value)}if(isError(value)){return formatError(value)}if(keys.length===0&&(!array||value.length==0)){return braces[0]+base+braces[1]}if(recurseTimes<0){if(isRegExp(value)){return ctx.stylize(RegExp.prototype.toString.call(value),"regexp")}else{return ctx.stylize("[Object]","special")}}ctx.seen.push(value);var output;if(array){output=formatArray(ctx,value,recurseTimes,visibleKeys,keys)}else{output=keys.map(function(key){return formatProperty(ctx,value,recurseTimes,visibleKeys,key,array)})}ctx.seen.pop();return reduceToSingleString(output,base,braces)}function formatPrimitive(ctx,value){switch(typeof value){case"undefined":return ctx.stylize("undefined","undefined");case"string":var simple="'"+JSON.stringify(value).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return ctx.stylize(simple,"string");case"number":if(value===0&&1/value===-Infinity){return ctx.stylize("-0","number")}return ctx.stylize(""+value,"number");case"boolean":return ctx.stylize(""+value,"boolean")}if(value===null){return ctx.stylize("null","null")}}function formatError(value){return"["+Error.prototype.toString.call(value)+"]"}function formatArray(ctx,value,recurseTimes,visibleKeys,keys){var output=[];for(var i=0,l=value.length;i<l;++i){if(Object.prototype.hasOwnProperty.call(value,String(i))){output.push(formatProperty(ctx,value,recurseTimes,visibleKeys,String(i),true))}else{output.push("")}}keys.forEach(function(key){if(!key.match(/^\d+$/)){output.push(formatProperty(ctx,value,recurseTimes,visibleKeys,key,true))}});return output}function formatProperty(ctx,value,recurseTimes,visibleKeys,key,array){var name,str;if(value.__lookupGetter__){if(value.__lookupGetter__(key)){if(value.__lookupSetter__(key)){str=ctx.stylize("[Getter/Setter]","special")}else{str=ctx.stylize("[Getter]","special")}}else{if(value.__lookupSetter__(key)){str=ctx.stylize("[Setter]","special")}}}if(visibleKeys.indexOf(key)<0){name="["+key+"]"}if(!str){if(ctx.seen.indexOf(value[key])<0){if(recurseTimes===null){str=formatValue(ctx,value[key],null)}else{str=formatValue(ctx,value[key],recurseTimes-1)}if(str.indexOf("\n")>-1){if(array){str=str.split("\n").map(function(line){return" "+line}).join("\n").substr(2)}else{str="\n"+str.split("\n").map(function(line){return" "+line}).join("\n")}}}else{str=ctx.stylize("[Circular]","special")}}if(typeof name==="undefined"){if(array&&key.match(/^\d+$/)){return str}name=JSON.stringify(""+key);if(name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)){name=name.substr(1,name.length-2);name=ctx.stylize(name,"name")}else{name=name.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'");name=ctx.stylize(name,"string")}}return name+": "+str}function reduceToSingleString(output,base,braces){var numLinesEst=0;var length=output.reduce(function(prev,cur){numLinesEst++;if(cur.indexOf("\n")>=0)numLinesEst++;return prev+cur.length+1},0);if(length>60){return braces[0]+(base===""?"":base+"\n ")+" "+output.join(",\n ")+" "+braces[1]}return braces[0]+base+" "+output.join(", ")+" "+braces[1]}function isArray(ar){return Array.isArray(ar)||typeof ar==="object"&&objectToString(ar)==="[object Array]"}function isRegExp(re){return typeof re==="object"&&objectToString(re)==="[object RegExp]"}function isDate(d){return typeof d==="object"&&objectToString(d)==="[object Date]"}function isError(e){return typeof e==="object"&&objectToString(e)==="[object Error]"}function objectToString(o){return Object.prototype.toString.call(o)}},{"./getEnumerableProperties":17,"./getName":19,"./getProperties":22}],26:[function(require,module,exports){var inspect=require("./inspect");var config=require("../config");module.exports=function(obj){var str=inspect(obj),type=Object.prototype.toString.call(obj);if(config.truncateThreshold&&str.length>=config.truncateThreshold){if(type==="[object Function]"){return!obj.name||obj.name===""?"[Function]":"[Function: "+obj.name+"]"}else if(type==="[object Array]"){return"[ Array("+obj.length+") ]"}else if(type==="[object Object]"){var keys=Object.keys(obj),kstr=keys.length>2?keys.splice(0,2).join(", ")+", ...":keys.join(", ");return"{ Object ("+kstr+") }"}else{return str}}else{return str}}},{"../config":7,"./inspect":25}],27:[function(require,module,exports){module.exports=function(ctx,name,method,chainingBehavior){var chainableBehavior=ctx.__methods[name];var _chainingBehavior=chainableBehavior.chainingBehavior;chainableBehavior.chainingBehavior=function(){var result=chainingBehavior(_chainingBehavior).call(this);return result===undefined?this:result};var _method=chainableBehavior.method;chainableBehavior.method=function(){var result=method(_method).apply(this,arguments);return result===undefined?this:result}}},{}],28:[function(require,module,exports){module.exports=function(ctx,name,method){var _method=ctx[name],_super=function(){return this};if(_method&&"function"===typeof _method)_super=_method;ctx[name]=function(){var result=method(_super).apply(this,arguments);return result===undefined?this:result}}},{}],29:[function(require,module,exports){module.exports=function(ctx,name,getter){var _get=Object.getOwnPropertyDescriptor(ctx,name),_super=function(){};if(_get&&"function"===typeof _get.get)_super=_get.get;Object.defineProperty(ctx,name,{get:function(){var result=getter(_super).call(this);return result===undefined?this:result},configurable:true})}},{}],30:[function(require,module,exports){var flag=require("./flag");module.exports=function(obj,args){var negate=flag(obj,"negate"),expr=args[0];return negate?!expr:expr}},{"./flag":15}],31:[function(require,module,exports){module.exports=function(assertion,object,includeAll){var flags=assertion.__flags||(assertion.__flags=Object.create(null));if(!object.__flags){object.__flags=Object.create(null)}includeAll=arguments.length===3?includeAll:true;for(var flag in flags){if(includeAll||flag!=="object"&&flag!=="ssfi"&&flag!="message"){object.__flags[flag]=flags[flag]}}}},{}],32:[function(require,module,exports){var natives={"[object Arguments]":"arguments","[object Array]":"array","[object Date]":"date","[object Function]":"function","[object Number]":"number","[object RegExp]":"regexp","[object String]":"string"};module.exports=function(obj){var str=Object.prototype.toString.call(obj);if(natives[str])return natives[str];if(obj===null)return"null";if(obj===undefined)return"undefined";if(obj===Object(obj))return"object";return typeof obj}},{}],33:[function(require,module,exports){function exclude(){var excludes=[].slice.call(arguments);function excludeProps(res,obj){Object.keys(obj).forEach(function(key){if(!~excludes.indexOf(key))res[key]=obj[key]})}return function extendExclude(){var args=[].slice.call(arguments),i=0,res={};for(;i<args.length;i++){excludeProps(res,args[i])}return res}}module.exports=AssertionError;function AssertionError(message,_props,ssf){var extend=exclude("name","message","stack","constructor","toJSON"),props=extend(_props||{});this.message=message||"Unspecified AssertionError";this.showDiff=false;for(var key in props){this[key]=props[key]}ssf=ssf||arguments.callee;if(ssf&&Error.captureStackTrace){Error.captureStackTrace(this,ssf)}}AssertionError.prototype=Object.create(Error.prototype);AssertionError.prototype.name="AssertionError";AssertionError.prototype.constructor=AssertionError;AssertionError.prototype.toJSON=function(stack){var extend=exclude("constructor","toJSON","stack"),props=extend({name:this.name},this);if(false!==stack&&this.stack){props.stack=this.stack}return props}},{}],34:[function(require,module,exports){module.exports=require("./lib/eql")},{"./lib/eql":35}],35:[function(require,module,exports){var type=require("type-detect");var Buffer;try{Buffer=require("buffer").Buffer}catch(ex){Buffer={};Buffer.isBuffer=function(){return false}}module.exports=deepEqual;function deepEqual(a,b,m){if(sameValue(a,b)){return true}else if("date"===type(a)){return dateEqual(a,b)}else if("regexp"===type(a)){return regexpEqual(a,b)}else if(Buffer.isBuffer(a)){return bufferEqual(a,b)}else if("arguments"===type(a)){return argumentsEqual(a,b,m)}else if(!typeEqual(a,b)){return false}else if("object"!==type(a)&&"object"!==type(b)&&("array"!==type(a)&&"array"!==type(b))){return sameValue(a,b)}else{return objectEqual(a,b,m)}}function sameValue(a,b){if(a===b)return a!==0||1/a===1/b;return a!==a&&b!==b}function typeEqual(a,b){return type(a)===type(b)}function dateEqual(a,b){if("date"!==type(b))return false;return sameValue(a.getTime(),b.getTime())}function regexpEqual(a,b){if("regexp"!==type(b))return false;return sameValue(a.toString(),b.toString())}function argumentsEqual(a,b,m){if("arguments"!==type(b))return false;a=[].slice.call(a);b=[].slice.call(b);return deepEqual(a,b,m)}function enumerable(a){var res=[];for(var key in a)res.push(key);return res}function iterableEqual(a,b){if(a.length!==b.length)return false;var i=0;var match=true;for(;i<a.length;i++){if(a[i]!==b[i]){match=false;break}}return match}function bufferEqual(a,b){if(!Buffer.isBuffer(b))return false;return iterableEqual(a,b)}function isValue(a){return a!==null&&a!==undefined}function objectEqual(a,b,m){if(!isValue(a)||!isValue(b)){return false}if(a.prototype!==b.prototype){return false}var i;if(m){for(i=0;i<m.length;i++){if(m[i][0]===a&&m[i][1]===b||m[i][0]===b&&m[i][1]===a){return true}}}else{m=[]}try{var ka=enumerable(a);var kb=enumerable(b)}catch(ex){return false}ka.sort();kb.sort();if(!iterableEqual(ka,kb)){return false}m.push([a,b]);var key;for(i=ka.length-1;i>=0;i--){key=ka[i];if(!deepEqual(a[key],b[key],m)){return false}}return true}},{buffer:1,"type-detect":36}],36:[function(require,module,exports){module.exports=require("./lib/type")},{"./lib/type":37}],37:[function(require,module,exports){var exports=module.exports=getType;var natives={"[object Array]":"array","[object RegExp]":"regexp","[object Function]":"function","[object Arguments]":"arguments","[object Date]":"date"};function getType(obj){var str=Object.prototype.toString.call(obj);if(natives[str])return natives[str];if(obj===null)return"null";if(obj===undefined)return"undefined";if(obj===Object(obj))return"object";return typeof obj}exports.Library=Library;function Library(){this.tests={}}Library.prototype.of=getType;Library.prototype.define=function(type,test){if(arguments.length===1)return this.tests[type];this.tests[type]=test;return this};Library.prototype.test=function(obj,type){if(type===getType(obj))return true;var test=this.tests[type];if(test&&"regexp"===getType(test)){return test.test(obj)}else if(test&&"function"===getType(test)){return test(obj)}else{throw new ReferenceError('Type test "'+type+'" not defined or invalid.')}}},{}],chai:[function(require,module,exports){module.exports=require("./lib/chai")},{"./lib/chai":5}]},{},[]);var p=document.createElement("pre");document.body.appendChild(p);p.textContent="LOG";var log=function(){p.textContent+="\n"+Array.prototype.slice.call(arguments).join(" ")};var chai=require("chai");var chaiAsPromised=require("chai-as-promised");chai.use(chaiAsPromised);var thrower=function(){throw new Error("oops")};try{log("test 1");chai.expect(Promise.resolve(true)).eventually.false()}catch(err){log(err)}try{log("test 2");chai.expect(Promise.resolve(true).then(thrower)).eventually.throw()}catch(err){log(err)} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "requirebin-sketch", | |
"version": "1.0.0", | |
"dependencies": { | |
"chai-as-promised": "4.3.0", | |
"chai": "2.2.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment