<commit_before>(function(Gear, Constants, Util) {

	var _attrChangeList = ['fontFamily', 'fontSize', 'fontStyle', 'padding', 'align', 'lineHeight', 'text', 'width', 'height', 'wrap'],
		_attrChangeListLength = _attrChangeList.length,
		_dummyContext = _.element(Constants.CANVAS).getContext(Constants.CONTEXT_2D);

	/**
	 * Display text
	 * @param {Object} config
	 * @param {String} config.text
	 * @param {Number} [config.padding]
	 * @param {Number} [config.width] default is auto
	 * @param {Number} [config.height] default is auto
	 * @param {String} [config.fontFamily] default is Calibri
	 * @param {Number} [config.fontSize] in pixels. Default is 12
	 * @param {String} [config.fontStyle] can be normal, bold, or italic. Default is normal
	 * @param {String} [config.align] can be left, center, or right
	 * @param {String} [config.wrap] word, char, or none. Default is word
	 * @param {Number} [config.lineHeight] default is 1
	 * @example
	 * var text = new Gear.Text({
	 *   x: 0,
	 *   y: 0,
	 *   text: 'Lorem Ipsum',
	 *   fontSize: 14,
	 *   fontFamily: 'Calibri',
	 *   fill: 'green'
	 * });
	 */
	var Txt = function(config) {
		if (!_.exists(config.width)) { config.width = 'auto'; }
		if (!_.exists(config.height)) { config.height = 'auto'; }

		Gear.Shape.call(this, config);
		this._className = Constants.CLASS.TEXT;

		// update text data for certain attr changes
		var idx = 0;
		for (; idx < _attrChangeListLength; idx += 1) {
			this.on(_attrChangeList[idx] + Constants.CHANGE_GEAR, this._setTxtData);
		}

		this._setTxtData();
	};

	Txt.extend = Util.extend;

	Util.construct(Txt.prototype, Gear.Shape.prototype, {

		draw: function(canvas) {
			var context = canvas.getContext(),
				padding = this.getPadding(),
				fontStyle = this.getFontStyle(),
				fontSize = this.getFontSize(),
				fontFamily = this.getFontFamily(),
				textHeight = this.getTextHeight(),
				lineHeightPx = this.getLineHeight() * textHeight,
				textArr = this.textArr,
				totalWidth = this.getWidth();

			canvas.save();

			context.font = this._getContextFont();
			context.textBaseline = 'middle';
			context.textAlign = Constants.LEFT;
			context.translate(padding, 0);
			context.translate(0, padding + textHeight / 2);

			// draw text lines
			var idx = 0, textArrLength = textArr.length;
			for (; idx < textArrLength; idx += 1) {
				var obj = textArr[idx],
					text = obj.text,
					width = obj.width;

				if (this.getAlign() === Constants.RIGHT) {
					context.translate(totalWidth - width - padding * 2, 0);
				} else if (this.getAlign() === Constants.CENTER) {
					context.translate((totalWidth - width - padding * 2) / 2, 0);
				}

				context.fillText(text, 0, 0);
				context.translate(0, lineHeightPx);
			}

			canvas.restore();
		},

		hit: function(canvas) {
			var context = canvas.getContext(),
				width = this.getWidth(),
				height = this.getHeight();

			context.beginPath();
			context.rect(0, 0, width, height);
			context.closePath();
			canvas.fillAndStroke(this);
		},

		getWidth: function() {
			return (this.attr.width === 'auto') ? this.getTextWidth() + this.getPadding() * 2 : this.attr.width;
		},

		getHeight: function() {
			return (this.attr.height === 'auto') ? (this.getTextHeight() * this.textArr.length * this.getLineHeight()) + this.getPadding() * 2 : this.attr.height;
		},

		getTextWidth: function() { return this.textWidth; },

		getTextHeight: function() { return this.textHeight; },

		_getTextSize: function(text) {
			_dummyContext.save();
			_dummyContext.font = this._getContextFont();

			var metrics = _dummyContext.measureText(text);
			_dummyContext.restore();

			return {
				width: metrics.width,
				height: +(this.getFontSize())
			};
		},

		_getContextFont: function() {
			return this.getFontStyle() + ' ' + _.toPx(this.getFontSize()) + ' ' + this.getFontFamily();
		},

		_addTxtLine: function(line, width, height) {
			return this.textArr.push({text: line, width: width});
		},

		_getTextWidth: function(text) {
			return _dummyContext.measureText(text).width;
		},

		_setTxtData: function() {
			var lines = this.getText().split('\n'),
				fontSize = +this.getFontSize(),
				textWidth = 0,
				lineHeightPx = this.getLineHeight() * fontSize,
				width = this.attr.width,
				height = this.attr.height,
				fixedWidth = (width !== 'auto'),
				fixedHeight = (height !== 'auto'),
				padding = this.getPadding(),
				maxWidth = (width - padding * 2),
				maxHeightPx = (height - padding * 2),
				currentHeightPx = 0,
				wrap = this.getWrap(),
				shouldWrap = (wrap !== 'none'),
				wrapAtWord = (wrap !== 'char' && shouldWrap);

			this.textArr = [];
			_dummyContext.save();
			_dummyContext.font = (this.getFontStyle() + ' ' + _.toPx(fontSize) + ' ' + this.getFontFamily());

			 var idx = 0, length = lines.length;
			 for (; idx < length; ++idx) {

				 var line = lines[idx],
					 lineWidth = this._getTextWidth(line);
				 if (fixedWidth && lineWidth > maxWidth) {

					// if width is fixed and line does not fit entirely
					// break the line into multiple fitting lines
					while (line.length > 0) {
						// use binary search to find the longest substring that
						// that would fit in the specified width
						 var low = 0, high = line.length,
							 match = '', matchWidth = 0;
						 while (low < high) {
							 var mid = (low + high) >>> 1,
								 substr = line.slice(0, mid + 1),
								 substrWidth = this._getTextWidth(substr);
							 if (substrWidth <= maxWidth) {
								 low = mid + 1;
								 match = substr;
								 matchWidth = substrWidth;
							 } else {
								 high = mid;
							 }
						 }

						// 'low' is now the index of the substring end
						// 'match' is the substring
						// 'matchWidth' is the substring width in px
						if (match) {
							 // a fitting substring was found
							 if (wrapAtWord) {
								 // try to find a space or dash where wrapping could be done
								 var wrapIndex = Math.max(match.lastIndexOf(' '),
														  match.lastIndexOf('-')) + 1;
								 if (wrapIndex > 0) {
									 // re-cut the substring found at the space/dash position
									 low = wrapIndex;
									 match = match.slice(0, low);
									 matchWidth = this._getTextWidth(match);
								 }
							 }

							 this._addTxtLine(match, matchWidth);
							 currentHeightPx += lineHeightPx;
							 if (!shouldWrap ||
								 (fixedHeight && currentHeightPx + lineHeightPx > maxHeightPx)) {
								 /*
								  * stop wrapping if wrapping is disabled or if adding
								  * one more line would overflow the fixed height
								  */
								 break;
							 }

							 line = line.slice(low);
							 if (line.length > 0) {
								 // Check if the remaining text would fit on one line
								 lineWidth = this._getTextWidth(line);
								 if (lineWidth <= maxWidth) {
									 // if it does, add the line and break out of the loop
									 this._addTxtLine(line, lineWidth);
									 currentHeightPx += lineHeightPx;
									 break;
								 }
							 }

						 } else {
							// not even one character could fit in the element, abort
							break;
						 }
					 }
				} else {
					// element width is automatically adjusted to max line width
					this._addTxtLine(line, lineWidth);
					currentHeightPx += lineHeightPx;
					textWidth = Math.max(textWidth, lineWidth);
				}

				// if element height is fixed, abort if adding one more line would overflow
				if (fixedHeight && currentHeightPx + lineHeightPx > maxHeightPx) {
					break;
				}
			 }
			_dummyContext.restore();
			this.textHeight = fontSize;
			this.textWidth = textWidth;
		},

		toString: function() {
			return '[Text]';
		},

		getFontFamily: function() {
			var val = this.attr.fontFamily;
			return (!_.exists(val)) ? Constants.DEFAULT_FONT : val;
		},

		setFontFamily: function(val) {
			this.attr.fontFamily = val;
		},

		getFontSize: function() {
			var val = this.attr.fontSize;
			return (!_.exists(val)) ? 12 : val;
		},

		setFontSize: function(val) {
			this.attr.fontSize = val;
		},

		getFontStyle: function() {
			var val = this.attr.fontStyle;
			return (!_.exists(val)) ? 'normal' : val;
		},

		setFontStyle: function(val) {
			this.attr.fontStyle = val;
		},

		getPadding: function() {
			var val = this.attr.padding;
			return (!_.exists(val)) ? 0 : val;
		},

		setPadding: function(val) {
			this.attr.padding = val;
		},

		getAlign: function() {
			var val = this.attr.align;
			return (!_.exists(val)) ? Constants.LEFT : val;
		},

		setAlign: function(val) {
			this.attr.align = val;
		},

		getLineHeight: function() {
			var val = this.attr.lineHeight;
			return (!_.exists(val)) ? 1 : val;
		},

		setLineHeight: function(val) {
			this.attr.lineHeight = val;
		},

		getWrap: function() {
			var val = this.attr.wrap;
			return (!_.exists(val)) ? 'word' : val;
		},

		setWrap: function(val) {
			this.attr.wrap = val;
		},

		getText: function() {
			var val = this.attr.text;
			return (!_.exists(val)) ? '' : val;
		},

		setText: function(text) {
			var str = _.isString(text) ? text : text.toString();
			this.attr.text = str;
		}
	});

	Gear.Text = Txt;

}(Gear, Gear.Constants, Gear.Util));
<commit_msg>Text setter bug fix<commit_after>(function(Gear, Constants, Util) {

	var _attrChangeList = ['fontFamily', 'fontSize', 'fontStyle', 'padding', 'align', 'lineHeight', 'text', 'width', 'height', 'wrap'],
		_attrChangeListLength = _attrChangeList.length,
		_dummyContext = _.element(Constants.CANVAS).getContext(Constants.CONTEXT_2D);

	/**
	 * Display text
	 * @param {Object} config
	 * @param {String} config.text
	 * @param {Number} [config.padding]
	 * @param {Number} [config.width] default is auto
	 * @param {Number} [config.height] default is auto
	 * @param {String} [config.fontFamily] default is Calibri
	 * @param {Number} [config.fontSize] in pixels. Default is 12
	 * @param {String} [config.fontStyle] can be normal, bold, or italic. Default is normal
	 * @param {String} [config.align] can be left, center, or right
	 * @param {String} [config.wrap] word, char, or none. Default is word
	 * @param {Number} [config.lineHeight] default is 1
	 * @example
	 * var text = new Gear.Text({
	 *   x: 0,
	 *   y: 0,
	 *   text: 'Lorem Ipsum',
	 *   fontSize: 14,
	 *   fontFamily: 'Calibri',
	 *   fill: 'green'
	 * });
	 */
	var Txt = function(config) {
		if (!_.exists(config.width)) { config.width = 'auto'; }
		if (!_.exists(config.height)) { config.height = 'auto'; }

		Gear.Shape.call(this, config);
		this._className = Constants.CLASS.TEXT;

		// update text data for certain attr changes
		var idx = 0;
		for (; idx < _attrChangeListLength; idx += 1) {
			this.on(_attrChangeList[idx] + Constants.CHANGE_GEAR, this._setTxtData);
		}

		this._setTxtData();
	};

	Txt.extend = Util.extend;

	Util.construct(Txt.prototype, Gear.Shape.prototype, {

		draw: function(canvas) {
			var context = canvas.getContext(),
				padding = this.getPadding(),
				fontStyle = this.getFontStyle(),
				fontSize = this.getFontSize(),
				fontFamily = this.getFontFamily(),
				textHeight = this.getTextHeight(),
				lineHeightPx = this.getLineHeight() * textHeight,
				textArr = this.textArr,
				totalWidth = this.getWidth();

			canvas.save();

			context.font = this._getContextFont();
			context.textBaseline = 'middle';
			context.textAlign = Constants.LEFT;
			context.translate(padding, 0);
			context.translate(0, padding + textHeight / 2);

			canvas.fillAndStroke(this);

			// draw text lines
			var idx = 0, textArrLength = textArr.length;
			for (; idx < textArrLength; idx += 1) {
				var obj = textArr[idx],
					text = obj.text,
					width = obj.width;

				if (this.getAlign() === Constants.RIGHT) {
					context.translate(totalWidth - width - padding * 2, 0);
				} else if (this.getAlign() === Constants.CENTER) {
					context.translate((totalWidth - width - padding * 2) / 2, 0);
				}

				context.fillText(text, 0, 0);
				context.translate(0, lineHeightPx);
			}

			canvas.restore();
		},

		hit: function(canvas) {
			var context = canvas.getContext(),
				width = this.getWidth(),
				height = this.getHeight();

			context.beginPath();
			context.rect(0, 0, width, height);
			context.closePath();
			canvas.fillAndStroke(this);
		},

		getWidth: function() {
			return (this.attr.width === 'auto') ? this.getTextWidth() + this.getPadding() * 2 : this.attr.width;
		},

		getHeight: function() {
			return (this.attr.height === 'auto') ? (this.getTextHeight() * this.textArr.length * this.getLineHeight()) + this.getPadding() * 2 : this.attr.height;
		},

		getTextWidth: function() { return this.textWidth; },

		getTextHeight: function() { return this.textHeight; },

		_getTextSize: function(text) {
			_dummyContext.save();
			_dummyContext.font = this._getContextFont();

			var metrics = _dummyContext.measureText(text);
			_dummyContext.restore();

			return {
				width: metrics.width,
				height: +(this.getFontSize())
			};
		},

		_getContextFont: function() {
			return this.getFontStyle() + ' ' + _.toPx(this.getFontSize()) + ' ' + this.getFontFamily();
		},

		_addTxtLine: function(line, width, height) {
			return this.textArr.push({text: line, width: width});
		},

		_getTextWidth: function(text) {
			return _dummyContext.measureText(text).width;
		},

		_setTxtData: function() {
			var lines = this.getText().split('\n'),
				fontSize = +this.getFontSize(),
				textWidth = 0,
				lineHeightPx = this.getLineHeight() * fontSize,
				width = this.attr.width,
				height = this.attr.height,
				fixedWidth = (width !== 'auto'),
				fixedHeight = (height !== 'auto'),
				padding = this.getPadding(),
				maxWidth = (width - padding * 2),
				maxHeightPx = (height - padding * 2),
				currentHeightPx = 0,
				wrap = this.getWrap(),
				shouldWrap = (wrap !== 'none'),
				wrapAtWord = (wrap !== 'char' && shouldWrap);

			this.textArr = [];
			_dummyContext.save();
			_dummyContext.font = (this.getFontStyle() + ' ' + _.toPx(fontSize) + ' ' + this.getFontFamily());

			 var idx = 0, length = lines.length;
			 for (; idx < length; ++idx) {

				 var line = lines[idx],
					 lineWidth = this._getTextWidth(line);
				 if (fixedWidth && lineWidth > maxWidth) {

					// if width is fixed and line does not fit entirely
					// break the line into multiple fitting lines
					while (line.length > 0) {
						// use binary search to find the longest substring that
						// that would fit in the specified width
						 var low = 0, high = line.length,
							 match = '', matchWidth = 0;
						 while (low < high) {
							 var mid = (low + high) >>> 1,
								 substr = line.slice(0, mid + 1),
								 substrWidth = this._getTextWidth(substr);
							 if (substrWidth <= maxWidth) {
								 low = mid + 1;
								 match = substr;
								 matchWidth = substrWidth;
							 } else {
								 high = mid;
							 }
						 }

						// 'low' is now the index of the substring end
						// 'match' is the substring
						// 'matchWidth' is the substring width in px
						if (match) {
							 // a fitting substring was found
							 if (wrapAtWord) {
								 // try to find a space or dash where wrapping could be done
								 var wrapIndex = Math.max(match.lastIndexOf(' '),
														  match.lastIndexOf('-')) + 1;
								 if (wrapIndex > 0) {
									 // re-cut the substring found at the space/dash position
									 low = wrapIndex;
									 match = match.slice(0, low);
									 matchWidth = this._getTextWidth(match);
								 }
							 }

							 this._addTxtLine(match, matchWidth);
							 currentHeightPx += lineHeightPx;
							 if (!shouldWrap ||
								 (fixedHeight && currentHeightPx + lineHeightPx > maxHeightPx)) {
								 /*
								  * stop wrapping if wrapping is disabled or if adding
								  * one more line would overflow the fixed height
								  */
								 break;
							 }

							 line = line.slice(low);
							 if (line.length > 0) {
								 // Check if the remaining text would fit on one line
								 lineWidth = this._getTextWidth(line);
								 if (lineWidth <= maxWidth) {
									 // if it does, add the line and break out of the loop
									 this._addTxtLine(line, lineWidth);
									 currentHeightPx += lineHeightPx;
									 break;
								 }
							 }

						 } else {
							// not even one character could fit in the element, abort
							break;
						 }
					 }
				} else {
					// element width is automatically adjusted to max line width
					this._addTxtLine(line, lineWidth);
					currentHeightPx += lineHeightPx;
					textWidth = Math.max(textWidth, lineWidth);
				}

				// if element height is fixed, abort if adding one more line would overflow
				if (fixedHeight && currentHeightPx + lineHeightPx > maxHeightPx) {
					break;
				}
			 }
			_dummyContext.restore();
			this.textHeight = fontSize;
			this.textWidth = textWidth;
		},

		toString: function() {
			return '[Text]';
		},

		getFontFamily: function() {
			var val = this.attr.fontFamily;
			return (!_.exists(val)) ? Constants.DEFAULT_FONT : val;
		},

		setFontFamily: function(val) {
			this.attr.fontFamily = val;
		},

		getFontSize: function() {
			var val = this.attr.fontSize;
			return (!_.exists(val)) ? 12 : val;
		},

		setFontSize: function(val) {
			this.attr.fontSize = val;
		},

		getFontStyle: function() {
			var val = this.attr.fontStyle;
			return (!_.exists(val)) ? 'normal' : val;
		},

		setFontStyle: function(val) {
			this.attr.fontStyle = val;
		},

		getPadding: function() {
			var val = this.attr.padding;
			return (!_.exists(val)) ? 0 : val;
		},

		setPadding: function(val) {
			this.attr.padding = val;
		},

		getAlign: function() {
			var val = this.attr.align;
			return (!_.exists(val)) ? Constants.LEFT : val;
		},

		setAlign: function(val) {
			this.attr.align = val;
		},

		getLineHeight: function() {
			var val = this.attr.lineHeight;
			return (!_.exists(val)) ? 1 : val;
		},

		setLineHeight: function(val) {
			this.attr.lineHeight = val;
		},

		getWrap: function() {
			var val = this.attr.wrap;
			return (!_.exists(val)) ? 'word' : val;
		},

		setWrap: function(val) {
			this.attr.wrap = val;
		},

		getText: function() {
			return this.attr.text || '';
		},

		setText: function(text) {
			var str = _.isString(text) ? text : _.exists(text) ? text.toString() : '';
			this.attr.text = str;
			this._setTxtData();
			return this;
		}
	});

	Gear.Text = Txt;

}(Gear, Gear.Constants, Gear.Util));
<|endoftext|>


<commit_before>$("div.mask.mask-inner ul.list li").on("click", function() {
  $('.main-header popin-header animation-start animation-start-timeout displayed').removeClass('displayed');
});
<commit_msg>Update custom.js<commit_after>$("div.mask.mask-inner ul.list li").on("click", function() {
  console.log('clicked!')
  $('.main-header popin-header animation-start animation-start-timeout displayed').removeClass('displayed');
});
<|endoftext|>


<commit_before>/* =================================
   LOADER
=================================== */
// makes sure the whole site is loaded
jQuery(window).load(function() {
        // will first fade out the loading animation
	jQuery(".status").fadeOut();
        // will fade out the whole DIV that covers the website.
	jQuery(".preloader").delay(1000).fadeOut("slow");
})

/* =================================
===  RESPONSIVE VIDEO           ====
=================================== */

$(".video-container").fitVids();

/* =================================
===  MAILCHIMP                 ====
=================================== */

$('.mailchimpAjaaa').ajaxChimp({
    callback: mailchimpCallback,
    url: "https://tinyletter.com/helphelp" //Replace this with your own mailchimp post URL. Don't remove the "". Just paste the url inside "".
});

function mailchimpCallback(resp) {
     if (resp.result === 'success') {
        $('.subscription-success').html('
' + resp.msg).fadeIn(1000);
        $('.subscription-error').fadeOut(500);

    } else if(resp.result === 'error') {
        $('.subscription-error').html('
' + resp.msg).fadeIn(1000);
    }
}

/* =================================
===  STICKY NAV                 ====
=================================== */

$(document).ready(function() {
  $('.main-navigation').onePageNav({
    scrollThreshold: 0.2, // Adjust if Navigation highlights too early or too late
    filter: ':not(.external)',
    changeHash: true
  });

});

/* COLLAPSE NAVIGATION ON MOBILE AFTER CLICKING ON LINK - ADDED ON V1.5*/

if (matchMedia('(max-width: 480px)').matches) {
    $('.main-navigation a').on('click', function () {
        $(".navbar-toggle").click();
    });
}

/* NAVIGATION VISIBLE ON SCROLL */

$(document).ready(function () {
    mainNav();
});

$(window).scroll(function () {
    mainNav();
});

if (matchMedia('(min-width: 992px), (max-width: 767px)').matches) {
  function mainNav() {
        var top = (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop;
        if (top > 40) $('.sticky-navigation').stop().animate({"top": '0'});

        else $('.sticky-navigation').stop().animate({"top": '-60'});
    }
}

if (matchMedia('(min-width: 768px) and (max-width: 991px)').matches) {
  function mainNav() {
        var top = (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop;
        if (top > 40) $('.sticky-navigation').stop().animate({"top": '0'});

        else $('.sticky-navigation').stop().animate({"top": '-120'});
    }
}

/* =================================
===  DOWNLOAD BUTTON CLICK SCROLL ==
=================================== */
jQuery(function( $ ){
			$('#download-button').localScroll({
				duration:1000
			});
		});

/* =================================
===  FULL SCREEN HEADER         ====
=================================== */
function alturaMaxima() {
  var altura = $(window).height();
  $(".full-screen").css('min-height',altura);

}

$(document).ready(function() {
  alturaMaxima();
  $(window).bind('resize', alturaMaxima);
});

/* =================================
===  SMOOTH SCROLL             ====
=================================== */
var scrollAnimationTime = 1200,
    scrollAnimation = 'easeInOutExpo';
$('a.scrollto').bind('click.smoothscroll', function (event) {
    event.preventDefault();
    var target = this.hash;
    $('html, body').stop().animate({
        'scrollTop': $(target).offset().top
    }, scrollAnimationTime, scrollAnimation, function () {
        window.location.hash = target;
    });
});

/* =================================
===  WOW ANIMATION             ====
=================================== */
wow = new WOW(
  {
    mobile: false
  });
wow.init();

/* =================================
===  OWL CROUSEL               ====
=================================== */
$(document).ready(function () {

    $("#feedbacks").owlCarousel({

        navigation: false, // Show next and prev buttons
        slideSpeed: 800,
        paginationSpeed: 400,
        autoPlay: 5000,
        singleItem: true
    });

    var owl = $("#screenshots");

    owl.owlCarousel({
        items: 4, //10 items above 1000px browser width
        itemsDesktop: [1000, 4], //5 items between 1000px and 901px
        itemsDesktopSmall: [900, 2], // betweem 900px and 601px
        itemsTablet: [600, 1], //2 items between 600 and 0
        itemsMobile: false // itemsMobile disabled - inherit from itemsTablet option
    });

});

/* =================================
===  Nivo Lightbox              ====
=================================== */
$(document).ready(function () {

    $('#screenshots a').nivoLightbox({
        effect: 'fadeScale',
    });

});

/* =================================
===  SUBSCRIPTION FORM          ====
=================================== */
$("#subscribeAsadsa").submit(function (e) {
    e.preventDefault();
    var email = $("#subscriber-email").val();
    var dataString = 'email=' + email;

    function isValidEmail(emailAddress) {
        var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
        return pattern.test(emailAddress);
    };

    if (isValidEmail(email)) {
        $.ajax({
            type: "POST",
            url: "subscribe/subscribe.php",
            data: dataString,
            success: function () {
                $('.subscription-success').fadeIn(1000);
                $('.subscription-error').fadeOut(500);
                $('.hide-after').fadeOut(500);
            }
        });
    } else {
        $('.subscription-error').fadeIn(1000);
    }

    return false;
});

/* =================================
===  CONTACT FORM          ====
=================================== */
$("#contactSuccess").submit(function (e) {
    $.ajax({
			$('.success').fadeIn(1000);
			$('.error').fadeOut(500);
        });
    return false;
});

/* =================================
===  EXPAND COLLAPSE            ====
=================================== */
$('.expand-form').simpleexpand({
    'defaultTarget': '.expanded-contact-form'
});

/* =================================
===  STELLAR                    ====
=================================== */
$(window).stellar({
horizontalScrolling: false
});

/* =================================
===  Bootstrap Internet Explorer 10 in Windows 8 and Windows Phone 8 FIX
=================================== */
if (navigator.userAgent.match(/IEMobile\/10\.0/)) {
  var msViewportStyle = document.createElement('style')
  msViewportStyle.appendChild(
    document.createTextNode(
      '@-ms-viewport{width:auto!important}'
    )
  )
  document.querySelector('head').appendChild(msViewportStyle)
}<commit_msg>update js<commit_after>/* =================================
   LOADER
=================================== */
// makes sure the whole site is loaded
jQuery(window).load(function() {
        // will first fade out the loading animation
	jQuery(".status").fadeOut();
        // will fade out the whole DIV that covers the website.
	jQuery(".preloader").delay(1000).fadeOut("slow");
})

/* =================================
===  RESPONSIVE VIDEO           ====
=================================== */

$(".video-container").fitVids();

/* =================================
===  MAILCHIMP                 ====
=================================== */

$('.mailchimpAjaaa').ajaxChimp({
    callback: mailchimpCallback,
    url: "https://tinyletter.com/helphelp" //Replace this with your own mailchimp post URL. Don't remove the "". Just paste the url inside "".
});

function mailchimpCallback(resp) {
     if (resp.result === 'success') {
        $('.subscription-success').html('
' + resp.msg).fadeIn(1000);
        $('.subscription-error').fadeOut(500);

    } else if(resp.result === 'error') {
        $('.subscription-error').html('
' + resp.msg).fadeIn(1000);
    }
}

/* =================================
===  STICKY NAV                 ====
=================================== */

$(document).ready(function() {
  $('.main-navigation').onePageNav({
    scrollThreshold: 0.2, // Adjust if Navigation highlights too early or too late
    filter: ':not(.external)',
    changeHash: true
  });

});

/* COLLAPSE NAVIGATION ON MOBILE AFTER CLICKING ON LINK - ADDED ON V1.5*/

if (matchMedia('(max-width: 480px)').matches) {
    $('.main-navigation a').on('click', function () {
        $(".navbar-toggle").click();
    });
}

/* NAVIGATION VISIBLE ON SCROLL */

$(document).ready(function () {
    mainNav();
});

$(window).scroll(function () {
    mainNav();
});

if (matchMedia('(min-width: 992px), (max-width: 767px)').matches) {
  function mainNav() {
        var top = (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop;
        if (top > 40) $('.sticky-navigation').stop().animate({"top": '0'});

        else $('.sticky-navigation').stop().animate({"top": '-60'});
    }
}

if (matchMedia('(min-width: 768px) and (max-width: 991px)').matches) {
  function mainNav() {
        var top = (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop;
        if (top > 40) $('.sticky-navigation').stop().animate({"top": '0'});

        else $('.sticky-navigation').stop().animate({"top": '-120'});
    }
}

/* =================================
===  DOWNLOAD BUTTON CLICK SCROLL ==
=================================== */
jQuery(function( $ ){
			$('#download-button').localScroll({
				duration:1000
			});
		});

/* =================================
===  FULL SCREEN HEADER         ====
=================================== */
function alturaMaxima() {
  var altura = $(window).height();
  $(".full-screen").css('min-height',altura);

}

$(document).ready(function() {
  alturaMaxima();
  $(window).bind('resize', alturaMaxima);
});

/* =================================
===  SMOOTH SCROLL             ====
=================================== */
var scrollAnimationTime = 1200,
    scrollAnimation = 'easeInOutExpo';
$('a.scrollto').bind('click.smoothscroll', function (event) {
    event.preventDefault();
    var target = this.hash;
    $('html, body').stop().animate({
        'scrollTop': $(target).offset().top
    }, scrollAnimationTime, scrollAnimation, function () {
        window.location.hash = target;
    });
});

/* =================================
===  WOW ANIMATION             ====
=================================== */
wow = new WOW(
  {
    mobile: false
  });
wow.init();

/* =================================
===  OWL CROUSEL               ====
=================================== */
$(document).ready(function () {

    $("#feedbacks").owlCarousel({

        navigation: false, // Show next and prev buttons
        slideSpeed: 800,
        paginationSpeed: 400,
        autoPlay: 5000,
        singleItem: true
    });

    var owl = $("#screenshots");

    owl.owlCarousel({
        items: 4, //10 items above 1000px browser width
        itemsDesktop: [1000, 4], //5 items between 1000px and 901px
        itemsDesktopSmall: [900, 2], // betweem 900px and 601px
        itemsTablet: [600, 1], //2 items between 600 and 0
        itemsMobile: false // itemsMobile disabled - inherit from itemsTablet option
    });

});

/* =================================
===  Nivo Lightbox              ====
=================================== */
$(document).ready(function () {

    $('#screenshots a').nivoLightbox({
        effect: 'fadeScale',
    });

});

/* =================================
===  SUBSCRIPTION FORM          ====
=================================== */
$("#subscribeAsadsa").submit(function (e) {
    e.preventDefault();
    var email = $("#subscriber-email").val();
    var dataString = 'email=' + email;

    function isValidEmail(emailAddress) {
        var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
        return pattern.test(emailAddress);
    };

    if (isValidEmail(email)) {
        $.ajax({
            type: "POST",
            url: "subscribe/subscribe.php",
            data: dataString,
            success: function () {
                $('.subscription-success').fadeIn(1000);
                $('.subscription-error').fadeOut(500);
                $('.hide-after').fadeOut(500);
            }
        });
    } else {
        $('.subscription-error').fadeIn(1000);
    }

    return false;
});

/* =================================
===  CONTACT FORM          ====
=================================== */
$("#contactSuccess").on("click", function(e){
	$('.success').fadeIn(1000);
	$('.error').fadeOut(500);
    return false;
});

/* =================================
===  EXPAND COLLAPSE            ====
=================================== */
$('.expand-form').simpleexpand({
    'defaultTarget': '.expanded-contact-form'
});

/* =================================
===  STELLAR                    ====
=================================== */
$(window).stellar({
horizontalScrolling: false
});

/* =================================
===  Bootstrap Internet Explorer 10 in Windows 8 and Windows Phone 8 FIX
=================================== */
if (navigator.userAgent.match(/IEMobile\/10\.0/)) {
  var msViewportStyle = document.createElement('style')
  msViewportStyle.appendChild(
    document.createTextNode(
      '@-ms-viewport{width:auto!important}'
    )
  )
  document.querySelector('head').appendChild(msViewportStyle)
}<|endoftext|>


<commit_before>/**
 * Libs and functions utils for project development
 *
 */

const fs = require('fs'),
  path = require('path'),
  _ = require('lodash'),
  // single model associations
  singleAssociations = ['belongsTo', 'hasOne'];

module.exports = {
  listFilesRecursive: walk,
  moment: require('moment'),
  async: require('async'),
  _: _,
  mkdirp: require('mkdirp'),
  cookieParser: require('cookie-parser'),
  mime: require('mime'),
  express: require('express'),

  /**
   * Strip tags from string
   * @param  {String} string String to cleanup
   * @return {String}        String without tags
   */
  stripTags(string) {
    return string.replace(/<\/?[^>]+(>|$)/g, '');
  },

  /**
   * Strip tags and truncate
   *
   * Usage: stripTagsAndTruncate('something big', 5, '......')
   *
   * @param  {String} string   String to cleanup and truncate
   * @param  {Number} length   Length to truncate if it is too big
   * @param  {String} omission default: ...
   * @return {String}          Clean and truncated string
   */
  stripTagsAndTruncate(string, length = 200, omission = '...') {
    return _.truncate(this.stripTags(string), {
      length: length,
      omission: omission
    });
  },

  /**
   * Is authenticated method usable if we-plugin-auth not is installed
   *
   * @return {Boolean} True
   */
  isAuthenticated() {
    if (!this.user || !this.user.id) return false;
    return true;
  },
  /**
   * Get redirect url
   * @param  {Object} req express request
   * @param  {[type]} res express response
   * @return {string|null} url or null
   */
  getRedirectUrl(req) {
    if (req.query) {
      if (req.query.service) {
        if (req.we.config.services && req.we.config.services[req.query.service]) {
          req.we.log.verbose(
            'Service redirect found for service: ', req.we.config.services[req.query.service]
          );
          return req.we.config.services[req.query.service].url;
        }
      }

      if (req.query.redirectTo) {
        if (!req.we.router.isAbsoluteUrl(req.query.redirectTo))
          return req.query.redirectTo;
      }
    }

    if (req.body && req.body.redirectTo) {
      if (!req.we.router.isAbsoluteUrl(req.body.redirectTo))
        return req.body.redirectTo;
    }

    return null;
  },

  helper: {
    /**
     * Parse handlebars helper options and return attributes text
     *
     * @param  {Object} options handlebars helper options
     * @return {String}         [description]
     */
    parseAttributes(options) {
      let attributes = [];
      // pass helper attributes to link element
      for (let attributeName in options.hash) {
        if (typeof options.hash[attributeName] == 'string') {
          attributes.push(attributeName + '="' + options.hash[attributeName] + '"');
        }
      }

      return attributes.join(' ');
    }
  },

  /**
   * Check if is a NxN association
   *
   * @param  {Object}  association The sequelize association object
   * @return {Boolean}
   */
  isNNAssoc(association) {
    if ( singleAssociations.indexOf( association.associationType ) > -1 ) {
      return true;
    }

    return false;
  }
};

/**
 * List files in dir in parallel
 *
 * see: http://stackoverflow.com/questions/5827612/node-js-fs-readdir-recursive-directory-search
 *
 * @param  {String}   dir
 * @param  {Function} done run with error, files
 */
function walk(dir, done) {
  var results = [];

  fs.readdir(dir, (err, list)=> {
    if (err) {
      if (err.code === 'ENOENT') {
        return done(null, []);
      } else {
        return done(err);
      }
    }
    let pending = list.length;
    if (!pending) return done(null, results);

    list.forEach( (file)=> {
      file = path.resolve(dir, file);
      fs.stat(file, (err, stat)=> {
        if (stat && stat.isDirectory()) {
          walk(file, (err, res)=> {
            results = results.concat(res);
            if (!--pending) done(null, results);
          });
        } else {
          results.push(file);
          if (!--pending) done(null, results);
        }
      });
    });
  });
};<commit_msg>Update we.utils to allow use of stripTagsAndTruncate with any context<commit_after>/**
 * Libs and functions utils for project development
 *
 */

const fs = require('fs'),
  path = require('path'),
  _ = require('lodash'),
  // single model associations
  singleAssociations = ['belongsTo', 'hasOne'];

const utils = {
  listFilesRecursive: walk,
  moment: require('moment'),
  async: require('async'),
  _: _,
  mkdirp: require('mkdirp'),
  cookieParser: require('cookie-parser'),
  mime: require('mime'),
  express: require('express'),

  /**
   * Strip tags from string
   *
   * @param  {String} string String to cleanup
   * @return {String}        String without tags
   */
  stripTags(string = '') {
    return string.replace(/<\/?[^>]+(>|$)/g, '');
  },

  /**
   * Strip tags and truncate
   *
   * Usage: stripTagsAndTruncate('something big', 5, '......')
   *
   * @param  {String} string   String to cleanup and truncate
   * @param  {Number} length   Length to truncate if it is too big
   * @param  {String} omission default: ...
   * @return {String}          Clean and truncated string
   */
  stripTagsAndTruncate(string, length = 200, omission = '...') {
    return _.truncate(utils.stripTags(string), {
      length: length,
      omission: omission
    });
  },

  /**
   * Is authenticated method usable if we-plugin-auth not is installed
   *
   * @return {Boolean} True
   */
  isAuthenticated() {
    if (!this.user || !this.user.id) return false;
    return true;
  },
  /**
   * Get redirect url
   * @param  {Object} req express request
   * @param  {[type]} res express response
   * @return {string|null} url or null
   */
  getRedirectUrl(req) {
    if (req.query) {
      if (req.query.service) {
        if (req.we.config.services && req.we.config.services[req.query.service]) {
          req.we.log.verbose(
            'Service redirect found for service: ', req.we.config.services[req.query.service]
          );
          return req.we.config.services[req.query.service].url;
        }
      }

      if (req.query.redirectTo) {
        if (!req.we.router.isAbsoluteUrl(req.query.redirectTo))
          return req.query.redirectTo;
      }
    }

    if (req.body && req.body.redirectTo) {
      if (!req.we.router.isAbsoluteUrl(req.body.redirectTo))
        return req.body.redirectTo;
    }

    return null;
  },

  helper: {
    /**
     * Parse handlebars helper options and return attributes text
     *
     * @param  {Object} options handlebars helper options
     * @return {String}         [description]
     */
    parseAttributes(options) {
      let attributes = [];
      // pass helper attributes to link element
      for (let attributeName in options.hash) {
        if (typeof options.hash[attributeName] == 'string') {
          attributes.push(attributeName + '="' + options.hash[attributeName] + '"');
        }
      }

      return attributes.join(' ');
    }
  },

  /**
   * Check if is a NxN association
   *
   * @param  {Object}  association The sequelize association object
   * @return {Boolean}
   */
  isNNAssoc(association) {
    if ( singleAssociations.indexOf( association.associationType ) > -1 ) {
      return true;
    }

    return false;
  }
};

/**
 * List files in dir in parallel
 *
 * see: http://stackoverflow.com/questions/5827612/node-js-fs-readdir-recursive-directory-search
 *
 * @param  {String}   dir
 * @param  {Function} done run with error, files
 */
function walk(dir, done) {
  var results = [];

  fs.readdir(dir, (err, list)=> {
    if (err) {
      if (err.code === 'ENOENT') {
        return done(null, []);
      } else {
        return done(err);
      }
    }
    let pending = list.length;
    if (!pending) return done(null, results);

    list.forEach( (file)=> {
      file = path.resolve(dir, file);
      fs.stat(file, (err, stat)=> {
        if (stat && stat.isDirectory()) {
          walk(file, (err, res)=> {
            results = results.concat(res);
            if (!--pending) done(null, results);
          });
        } else {
          results.push(file);
          if (!--pending) done(null, results);
        }
      });
    });
  });
}

module.exports = utils;
<|endoftext|>


<commit_before>const colors = require('colors')
const ora = require('ora')
const CLITable = require('cli-table2')

/**
 * Sets the color scheme.
 */
colors.setTheme({
  highlight: 'cyan',
  info: 'reset',
  warning: 'yellow',
  success: 'green',
  error: 'red',
  line: 'grey',
  muted: 'grey'
})

/**
 * Print a blank line.
 */
function newline () {
  console.log('')
}

/**
 * Prints a divider line
 */
function divider () {
  console.log(colors.line('---------------------------------------------------------------'))
}

/**
 * Prints an object to table format.  The values will already be
 * stringified.
 *
 * @param {{}} object The object to turn into a table.
 */
function table (data, options) {
  let t
  if (options.markdown) {
    const header = data.shift()
    t = new CLITable({
      head: header,
      chars: {
        top: '',
        'top-mid': '',
        'top-left': '',
        'top-right': '',
        bottom: '',
        'bottom-mid': '',
        'bottom-left': '',
        'bottom-right': '',
        left: '|',
        'left-mid': '',
        mid: '',
        'mid-mid': '',
        right: '|',
        'right-mid': '',
        middle: '|'
      }
    })
    data.unshift(new Array(header.length).fill('---'))
    t.push(...data)
  } else if (options.lean) {
    t = new CLITable()
    t.push(...data)
  } else {
    t = new CLITable({
      chars: {
        top: '',
        'top-mid': '',
        'top-left': '',
        'top-right': '',
        bottom: '',
        'bottom-mid': '',
        'bottom-left': '',
        'bottom-right': '',
        left: ' ',
        'left-mid': '',
        mid: '',
        'mid-mid': '',
        right: '',
        'right-mid': '',
        middle: ' '
      }
    })
    t.push(...data)
  }
  console.log(t.toString())
}

/**
 * Prints text without theming.
 *
 * Use this when you're writing stuff outside the context of our
 * printing scheme.  hint: rarely.
 *
 * @param {string} message The message to write.
 */
function fancy (message) {
  console.log(message)
}

/**
 * Writes a normal information message.
 *
 * This is the default type you should use.
 *
 * @param {string} message The message to show.
 */
function info (message) {
  console.log(colors.info(message))
}

/**
 * Writes an error message.
 *
 * This is when something horribly goes wrong.
 *
 * @param {string} message The message to show.
 */
function error (message) {
  console.log(colors.error(message))
}

/**
 * Writes a warning message.
 *
 * This is when the user might not be getting what they're expecting.
 *
 * @param {string} message The message to show.
 */
function warning (message) {
  console.log(colors.warning(message))
}

/**
 * Writes a debug message.
 *
 * This is for devs only.
 *
 * @param {string} message The message to show.
 */
function debug (message, title = 'DEBUG') {
  const topLine = `vvv -----[ ${title} ]----- vvv`
  const botLine = `^^^ -----[ ${title} ]----- ^^^`

  console.log(colors.rainbow(topLine))
  console.log(message)
  console.log(colors.rainbow(botLine))
}

/**
 * Writes a success message.
 *
 * When something is successful.  Use sparingly.
 *
 * @param {string} message The message to show.
 */
function success (message) {
  console.log(colors.success(message))
}

/**
 * Creates a spinner and starts it up.
 *
 * @param {string|Object} config The text for the spinner or an ora configuration object.
 * @returns The spinner.
 */
function spin (config) {
  return ora(config).start()
}

module.exports = {
  info,
  warning,
  success,
  error,
  debug,
  fancy,
  divider,
  newline,
  table,
  spin,
  colors
}
<commit_msg>fix options with guard<commit_after>const colors = require('colors')
const ora = require('ora')
const CLITable = require('cli-table2')

/**
 * Sets the color scheme.
 */
colors.setTheme({
  highlight: 'cyan',
  info: 'reset',
  warning: 'yellow',
  success: 'green',
  error: 'red',
  line: 'grey',
  muted: 'grey'
})

/**
 * Print a blank line.
 */
function newline () {
  console.log('')
}

/**
 * Prints a divider line
 */
function divider () {
  console.log(colors.line('---------------------------------------------------------------'))
}

/**
 * Prints an object to table format.  The values will already be
 * stringified.
 *
 * @param {{}} object The object to turn into a table.
 */
function table (data, options) {
  let t
  if (options && options.markdown) {
    const header = data.shift()
    t = new CLITable({
      head: header,
      chars: {
        top: '',
        'top-mid': '',
        'top-left': '',
        'top-right': '',
        bottom: '',
        'bottom-mid': '',
        'bottom-left': '',
        'bottom-right': '',
        left: '|',
        'left-mid': '',
        mid: '',
        'mid-mid': '',
        right: '|',
        'right-mid': '',
        middle: '|'
      }
    })
    data.unshift(new Array(header.length).fill('---'))
    t.push(...data)
  } else if (options && options.lean) {
    t = new CLITable()
    t.push(...data)
  } else {
    t = new CLITable({
      chars: {
        top: '',
        'top-mid': '',
        'top-left': '',
        'top-right': '',
        bottom: '',
        'bottom-mid': '',
        'bottom-left': '',
        'bottom-right': '',
        left: ' ',
        'left-mid': '',
        mid: '',
        'mid-mid': '',
        right: '',
        'right-mid': '',
        middle: ' '
      }
    })
    t.push(...data)
  }
  console.log(t.toString())
}

/**
 * Prints text without theming.
 *
 * Use this when you're writing stuff outside the context of our
 * printing scheme.  hint: rarely.
 *
 * @param {string} message The message to write.
 */
function fancy (message) {
  console.log(message)
}

/**
 * Writes a normal information message.
 *
 * This is the default type you should use.
 *
 * @param {string} message The message to show.
 */
function info (message) {
  console.log(colors.info(message))
}

/**
 * Writes an error message.
 *
 * This is when something horribly goes wrong.
 *
 * @param {string} message The message to show.
 */
function error (message) {
  console.log(colors.error(message))
}

/**
 * Writes a warning message.
 *
 * This is when the user might not be getting what they're expecting.
 *
 * @param {string} message The message to show.
 */
function warning (message) {
  console.log(colors.warning(message))
}

/**
 * Writes a debug message.
 *
 * This is for devs only.
 *
 * @param {string} message The message to show.
 */
function debug (message, title = 'DEBUG') {
  const topLine = `vvv -----[ ${title} ]----- vvv`
  const botLine = `^^^ -----[ ${title} ]----- ^^^`

  console.log(colors.rainbow(topLine))
  console.log(message)
  console.log(colors.rainbow(botLine))
}

/**
 * Writes a success message.
 *
 * When something is successful.  Use sparingly.
 *
 * @param {string} message The message to show.
 */
function success (message) {
  console.log(colors.success(message))
}

/**
 * Creates a spinner and starts it up.
 *
 * @param {string|Object} config The text for the spinner or an ora configuration object.
 * @returns The spinner.
 */
function spin (config) {
  return ora(config).start()
}

module.exports = {
  info,
  warning,
  success,
  error,
  debug,
  fancy,
  divider,
  newline,
  table,
  spin,
  colors
}
<|endoftext|>


<commit_before>define([
    'intern!object',
    'intern/chai!expect',
    'intern/dojo/node!../exerptional' // Load as a NPM CommonJS module
], function (registerSuite, expect, exerptional) {
  registerSuite({
          name: 'exerptional',

          createClient: function () {
            var createClient = exerptional.createClient;
            var dummyBaseUrl = 'http://dummy.url/';

            expect(
              createClient(dummyBaseUrl),
              'Create a client with a specified base URL as required')
                .to.be.OK;

            expect(
              createClient,
              'Create a client without a specified base URL should result in an error')
                .to.throw(Error, 'A base URL must be defined!');
          }
      });
});
<commit_msg>Changed tests to use BDD style<commit_after>define([
    'intern!bdd',
    'intern/chai!expect',
    'intern/dojo/node!../exerptional' // Load as a NPM CommonJS module
], function (bdd, expect, exerptional) {
      var describe = bdd.describe,
          it = bdd.it;

      describe('Sanity check', function() {
        var createClient = exerptional.createClient;

        it('should successfully create a client', function () {
          var dummyBaseUrl = 'http://dummy.url/';

          expect(
            createClient(dummyBaseUrl),
            'Create a client with a specified base URL as required')
              .to.be.OK;
          }
        );

        it('should thrown an error for a client without a specified base URL', function () {
            expect(
              createClient,
              'Create a should result in an error')
                .to.throw(Error, 'A base URL must be defined!');
          }
        );
    });
});
<|endoftext|>


<commit_before>var assert = require('assert');
var numbers = require('../index.js');
var basic = numbers.basic;

suite('numbers', function() {

  console.log('\n\n\033[34mTesting Standard Mathematics\033[0m');

  // basic.sum
  test('sum should return the sum of items in an array', function (done) {
    assert.equal(6, basic.sum([0,1,2,3]));
    assert.equal(0, basic.sum([0,-3,5,-2]));
    done();
  });

  test('sum should throw an exception when given anything but an array', function (done) {
    assert.throws(
      function() {
        basic.sum(1);
      },
      /Input must be of type Array/
    );
    done();
  });

  test('sum should throw an exception when given anything objects other than numbers', function (done) {
    assert.throws(
      function() {
        basic.sum([1,2,"error"]);
      },
      /All elements in array must be numbers/
    );
    done();
  });

  // basic.substraction
  test('subtraction should return the difference of items in an array', function (done) {
    assert.equal(0, basic.subtraction([0,1,2,3]));
    done();
  });

  test('subtraction should throw an exception when given anything but an array', function (done) {
    assert.throws(
      function() {
        basic.subtraction(1);
      },
      /Input must be of type Array/
    );
    done();
  });

  test('subtraction should throw an exception when given anything objects other than numbers', function (done) {
    assert.throws(
      function() {
        basic.subtraction(["test",1,1,2]);
      },
      /All elements in array must be numbers/
    );
    done();
  });

  // basic.product
  test('product should return the product of items in an array', function (done) {
    assert.equal(24, basic.product([1,2,3,4]));
    assert.equal(-6, basic.product([-3,2]));
    done();
  });

  test('product should throw an exception when given anything but an array', function (done) {
    assert.throws(
      function() {
        basic.product(1);
      },
      /Input must be of type Array/
    );
    done();
  });

  test('product should throw an exception when given anything objects other than numbers', function (done) {
    assert.throws(
      function() {
        basic.product([1,2,"error"]);
      },
      /All elements in array must be numbers/
    );
    done();
  });

  test('square should return the square of a number', function(done) {
    assert.equal(16, basic.square(4));
    done();
  });

  // basic.binomial
  test('binomial should return the binomial coefficient (n choose k) of two numbers', function(done) {
    assert.equal(10, basic.binomial(5, 3));
    done();
  });

  // basic.factorial
  test('factorial should return the product of n * (n - 1) * (n - 2) * ... * 1', function (done) {
    assert.equal(24, basic.factorial(4));
    assert.equal(120, basic.factorial(5));
    done();
  });

  // basic.gcd
  test('gcd should return the greatest common denominator of two integers', function (done) {
    assert.equal(6, basic.gcd(1254, 5298));
    assert.equal(1, basic.gcd(78699786, 78978965));
    done();
  });

  // basic.lcm
  test('lcm should return the least common multiple of two integers', function (done) {
    assert.equal(240, basic.lcm(12, 80));
    done();
  });

  // basic.max
  test('max should return the biggest number in an array', function (done) {
    assert.equal(42, basic.max([1,2,3,42]));
    done();
  });

  // basic.min
  test('min should return the smallest number in an array', function (done) {
    assert.equal(1, basic.min([2,1,3,42]));
    done();
  });

  // basic.range
  test('range should return an appropriate range for the given start, stop, and step parameters', function (done) {
    assert.deepEqual([1,2,3,4,5,6,7,8,9,10],basic.range(1,10));
    assert.deepEqual([10,9,8,7,6,5,4,3,2,1],basic.range(10,1));
    assert.deepEqual([1,1.5,2,2.5,3,3.5,4,4.5,5],basic.range(1,5,.5));
    assert.deepEqual([5,4.5,4,3.5,3,2.5,2,1.5,1],basic.range(5,1,.5));
    done();

  });

  // basic.isInt
  test('isInt checks for an integer', function (done) {
    assert.equal(false, basic.isInt(2.32));
    assert.equal(false, basic.isInt("true"));
    assert.equal(true, basic.isInt("2")); //based off impelementation change
    assert.equal(true, basic.isInt(2));
    done();
  });

  // basic.divMod
  test('divMod should return an array of both the division and modulus values of two integers', function (done) {
    assert.deepEqual([2, 0], basic.divMod(12, 6));
    assert.deepEqual([3, 1], basic.divMod(10, 3));
    done();
  });

  // basic.egcd
  test('egcd should return the array [a, x, y] which is the solved linear equation for GCD', function(done) {
    assert.deepEqual([5, -3, 5], basic.egcd(65, 40));
    assert.deepEqual([5, 5, -3], basic.egcd(40, 65));
    assert.deepEqual([21, -16, 27], basic.egcd(1239, 735));
    assert.deepEqual([21, 5, -2], basic.egcd(105, 252));
    assert.deepEqual([21, -2, 5], basic.egcd(252, 105));
    done();
  });

  // basic.modInverse
  test('modInverse will return the modulo m inverse of a', function(done) {
    assert.equal(1, basic.modInverse(1, 5));
    done();
  });

  test('modInverse will throw an exception if no modular inverse exists', function(done) {
    assert.throws(
      function() {
        basic.modInverse(65, 40);
      },
      /No modular inverse exists/
    );
    done();
  });

  // basic.powerMod
  test('powerMod should return the answer to a^b mod m', function (done) {
    assert.equal(1, basic.powerMod(1, -1, 5));
    assert.equal(1, basic.powerMod(2, 10, 3));
    assert.equal(16, basic.powerMod(2, Math.pow(10, 9), 18));
    assert.equal(6, basic.powerMod(6, .5, 10));
    done();
  });

});

<commit_msg>Add powerMod test from https://github.com/sjkaliski/numbers.js/pull/60<commit_after>var assert = require('assert');
var numbers = require('../index.js');
var basic = numbers.basic;

suite('numbers', function() {

  console.log('\n\n\033[34mTesting Standard Mathematics\033[0m');

  // basic.sum
  test('sum should return the sum of items in an array', function (done) {
    assert.equal(6, basic.sum([0,1,2,3]));
    assert.equal(0, basic.sum([0,-3,5,-2]));
    done();
  });

  test('sum should throw an exception when given anything but an array', function (done) {
    assert.throws(
      function() {
        basic.sum(1);
      },
      /Input must be of type Array/
    );
    done();
  });

  test('sum should throw an exception when given anything objects other than numbers', function (done) {
    assert.throws(
      function() {
        basic.sum([1,2,"error"]);
      },
      /All elements in array must be numbers/
    );
    done();
  });

  // basic.substraction
  test('subtraction should return the difference of items in an array', function (done) {
    assert.equal(0, basic.subtraction([0,1,2,3]));
    done();
  });

  test('subtraction should throw an exception when given anything but an array', function (done) {
    assert.throws(
      function() {
        basic.subtraction(1);
      },
      /Input must be of type Array/
    );
    done();
  });

  test('subtraction should throw an exception when given anything objects other than numbers', function (done) {
    assert.throws(
      function() {
        basic.subtraction(["test",1,1,2]);
      },
      /All elements in array must be numbers/
    );
    done();
  });

  // basic.product
  test('product should return the product of items in an array', function (done) {
    assert.equal(24, basic.product([1,2,3,4]));
    assert.equal(-6, basic.product([-3,2]));
    done();
  });

  test('product should throw an exception when given anything but an array', function (done) {
    assert.throws(
      function() {
        basic.product(1);
      },
      /Input must be of type Array/
    );
    done();
  });

  test('product should throw an exception when given anything objects other than numbers', function (done) {
    assert.throws(
      function() {
        basic.product([1,2,"error"]);
      },
      /All elements in array must be numbers/
    );
    done();
  });

  test('square should return the square of a number', function(done) {
    assert.equal(16, basic.square(4));
    done();
  });

  // basic.binomial
  test('binomial should return the binomial coefficient (n choose k) of two numbers', function(done) {
    assert.equal(10, basic.binomial(5, 3));
    done();
  });

  // basic.factorial
  test('factorial should return the product of n * (n - 1) * (n - 2) * ... * 1', function (done) {
    assert.equal(24, basic.factorial(4));
    assert.equal(120, basic.factorial(5));
    done();
  });

  // basic.gcd
  test('gcd should return the greatest common denominator of two integers', function (done) {
    assert.equal(6, basic.gcd(1254, 5298));
    assert.equal(1, basic.gcd(78699786, 78978965));
    done();
  });

  // basic.lcm
  test('lcm should return the least common multiple of two integers', function (done) {
    assert.equal(240, basic.lcm(12, 80));
    done();
  });

  // basic.max
  test('max should return the biggest number in an array', function (done) {
    assert.equal(42, basic.max([1,2,3,42]));
    done();
  });

  // basic.min
  test('min should return the smallest number in an array', function (done) {
    assert.equal(1, basic.min([2,1,3,42]));
    done();
  });

  // basic.range
  test('range should return an appropriate range for the given start, stop, and step parameters', function (done) {
    assert.deepEqual([1,2,3,4,5,6,7,8,9,10],basic.range(1,10));
    assert.deepEqual([10,9,8,7,6,5,4,3,2,1],basic.range(10,1));
    assert.deepEqual([1,1.5,2,2.5,3,3.5,4,4.5,5],basic.range(1,5,.5));
    assert.deepEqual([5,4.5,4,3.5,3,2.5,2,1.5,1],basic.range(5,1,.5));
    done();

  });

  // basic.isInt
  test('isInt checks for an integer', function (done) {
    assert.equal(false, basic.isInt(2.32));
    assert.equal(false, basic.isInt("true"));
    assert.equal(true, basic.isInt("2")); //based off impelementation change
    assert.equal(true, basic.isInt(2));
    done();
  });

  // basic.divMod
  test('divMod should return an array of both the division and modulus values of two integers', function (done) {
    assert.deepEqual([2, 0], basic.divMod(12, 6));
    assert.deepEqual([3, 1], basic.divMod(10, 3));
    done();
  });

  // basic.egcd
  test('egcd should return the array [a, x, y] which is the solved linear equation for GCD', function(done) {
    assert.deepEqual([5, -3, 5], basic.egcd(65, 40));
    assert.deepEqual([5, 5, -3], basic.egcd(40, 65));
    assert.deepEqual([21, -16, 27], basic.egcd(1239, 735));
    assert.deepEqual([21, 5, -2], basic.egcd(105, 252));
    assert.deepEqual([21, -2, 5], basic.egcd(252, 105));
    done();
  });

  // basic.modInverse
  test('modInverse will return the modulo m inverse of a', function(done) {
    assert.equal(1, basic.modInverse(1, 5));
    done();
  });

  test('modInverse will throw an exception if no modular inverse exists', function(done) {
    assert.throws(
      function() {
        basic.modInverse(65, 40);
      },
      /No modular inverse exists/
    );
    done();
  });

  // basic.powerMod
  test('powerMod should return the answer to a^b mod m', function (done) {
    assert.equal(1, basic.powerMod(1, -1, 5));
    assert.equal(1, basic.powerMod(2, 10, 3));
    assert.equal(16, basic.powerMod(2, Math.pow(10, 9), 18));
    assert.equal(6, basic.powerMod(6, .5, 10));
    assert.equal(445, basic.powerMod(4, 13, 497));
    done();
  });

});

<|endoftext|>


<commit_before>const should = require('should');
const spec = require('stream-spec');

const dropboxV2Api = require('../../src/dropbox-api-test.js');
const utils = require('../../src/utils.js');

const DROPBOX_TOKEN = process.env.DROPBOX_TOKEN;
let dropbox;

describe('Namespace', function() {
    this.timeout(6000);
    before(function() {
        dropbox = dropboxV2Api.authenticate({
            token: DROPBOX_TOKEN
        });
    });
    beforeEach(function(){
        console.log('-------------------------');
    });
    describe('files', () => {
        const timestamp = (+new Date());
        var dirName = `dropbox-api-test-${timestamp}`;
        var dirPath = `/${dirName}`

        it('create_folder', (done) => {
            dropbox({
                resource: 'files/create_folder',
                parameters: {
                    path: dirPath
                }
            }, (err, response) => {
                if(err){ throw err; }
                response.should.have.property('name', dirName);
                done();
            });
        });
        it('alpha/get_metadata', (done) => {
            dropbox({
                resource: 'files/alpha/get_metadata',
                parameters: {
                    path: dirPath,
                    include_media_info: false,
                    include_deleted: false,
                    include_has_explicit_shared_members: false
                }
            }, (err, response) => {
                if(err){ throw err; }
                response.should.have.property('.tag', 'folder');
                response.should.have.property('path_lower', dirPath);

                done();
            });
        });
        it('alpha/upload', (done) => {
            var filePath = `${dirPath}/alpha-upload.txt`;
            dropbox({
                resource: 'files/alpha/upload',
                parameters: {
                    path: filePath
                },
                readStream: utils.createMockedReadStream('1', 50)
            }, (err, response) => {
                if(err){ throw err; }
                response.should.have.property('path_lower', filePath);
                done();
            });
        });
        it('upload', (done) => {
            var filePath = `${dirPath}/upload.txt`;
            dropbox({
                resource: 'files/upload',
                parameters: {
                    path: filePath
                },
                readStream: utils.createMockedReadStream('2', 30)
            }, (err, response) => {
                if(err){ throw err; }
                response.should.have.property('path_lower', filePath);
                done();
            });
        });
        it('list_folder', (done) => {
            var filePath = `${dirPath}/alpha-upload.txt`;
            dropbox({
                resource: 'files/list_folder',
                parameters: {
                    path: dirPath
                }
            }, (err, response) => {
                if(err){ throw err; }
                response.entries[0].should.have.property('size', 50);
                response.entries[1].should.have.property('size', 30);
                done();
            });
        });
        it('download', (done) => {
            var filePath = `${dirPath}/upload.txt`;
            var dropboxStream = dropbox({
                resource: 'files/download',
                parameters: {
                    path: filePath
                }
            }, (err, response) => {
                if(err){ throw err; }
                response.should.have.property('path_lower', filePath);
                done();
            });
        });
        it('download -> upload combination', (done) => {
            var downloadFilePath = `${dirPath}/upload.txt`;
            var uploadFilePath = `${dirPath}/upload-2.txt`;

            const dlStream = dropbox({
                resource: 'files/download',
                parameters: {
                    path: downloadFilePath
                }
            });

            const uploadSteram = dropbox({
                resource: 'files/upload',
                parameters: {
                    path: uploadFilePath
                }
            }, (err, response) => {
                response.should.have.property('size', 30);
                done();
            });

            dlStream.pipe(uploadSteram);
        });
        it('copy', (done) => {
            const sourceFileName = `${dirPath}/upload-2.txt`;
            const targetFileName = `${dirPath}/upload-2-copied.txt`;
            dropbox({
                resource: 'files/copy',
                parameters: {
                    'from_path': sourceFileName,
                    'to_path': targetFileName
                }
            }, (err, response) => {
                if(err){ throw err; }
                response.should.have.property('path_lower', targetFileName);
                done();
            });
        });
        it('delete', (done) => {
            var fileToDeleteName = `${dirPath}/upload-2-copied.txt`;
            dropbox({
                resource: 'files/delete',
                parameters: {
                    'path': fileToDeleteName
                }
            }, (err, response) => {
                if(err){ throw err; }
                response.should.have.property('path_lower', fileToDeleteName);
                done();
            });
        });
        it('move', (done) => {
            var targetFileName = `${dirPath}/upload-moved.txt`;
            dropbox({
                resource: 'files/copy',
                parameters: {
                    'from_path': `${dirPath}/upload.txt`,
                    'to_path': targetFileName
                }
            }, (err, response) => {
                if(err){ throw err; }
                response.should.have.property('path_lower', targetFileName);
                done();
            });
        });
    });
});<commit_msg>tests fixed<commit_after>const should = require('should');
const spec = require('stream-spec');

const dropboxV2Api = require('../../src/dropbox-api-test.js');
const utils = require('../../src/utils.js');

const DROPBOX_TOKEN = process.env.DROPBOX_TOKEN;
let dropbox;

describe('Namespace', function() {
    this.timeout(6000);
    before(function() {
        dropbox = dropboxV2Api.authenticate({
            token: DROPBOX_TOKEN
        });
    });
    beforeEach(function(){
        console.log('-------------------------');
    });
    describe('files', () => {
        const timestamp = (+new Date());
        var dirName = `dropbox-api-test-${timestamp}`;
        var dirPath = `/${dirName}`

        it('create_folder_v2 ', (done) => {
            dropbox({
                resource: 'files/create_folder_v2',
                parameters: {
                    path: dirPath
                }
            }, (err, response) => {
                if(err){ throw err; }
                response.metadata.should.have.property('name', dirName);
                done();
            });
        });
        it('alpha/get_metadata', (done) => {
            dropbox({
                resource: 'files/alpha/get_metadata',
                parameters: {
                    path: dirPath,
                    include_media_info: false,
                    include_deleted: false,
                    include_has_explicit_shared_members: false
                }
            }, (err, response) => {
                if(err){ throw err; }
                response.should.have.property('.tag', 'folder');
                response.should.have.property('path_lower', dirPath);

                done();
            });
        });
        it('alpha/upload', (done) => {
            var filePath = `${dirPath}/alpha-upload.txt`;
            dropbox({
                resource: 'files/alpha/upload',
                parameters: {
                    path: filePath
                },
                readStream: utils.createMockedReadStream('1', 50)
            }, (err, response) => {
                if(err){ throw err; }
                response.should.have.property('path_lower', filePath);
                done();
            });
        });
        it('upload', (done) => {
            var filePath = `${dirPath}/upload.txt`;
            dropbox({
                resource: 'files/upload',
                parameters: {
                    path: filePath
                },
                readStream: utils.createMockedReadStream('2', 30)
            }, (err, response) => {
                if(err){ throw err; }
                response.should.have.property('path_lower', filePath);
                done();
            });
        });
        it('list_folder', (done) => {
            var filePath = `${dirPath}/alpha-upload.txt`;
            dropbox({
                resource: 'files/list_folder',
                parameters: {
                    path: dirPath
                }
            }, (err, response) => {
                if(err){ throw err; }
                response.entries[0].should.have.property('size', 50);
                response.entries[1].should.have.property('size', 30);
                done();
            });
        });
        it('download', (done) => {
            var filePath = `${dirPath}/upload.txt`;
            var dropboxStream = dropbox({
                resource: 'files/download',
                parameters: {
                    path: filePath
                }
            }, (err, response) => {
                if(err){ throw err; }
                response.should.have.property('path_lower', filePath);
                done();
            });
        });
        it('download -> upload combination', (done) => {
            var downloadFilePath = `${dirPath}/upload.txt`;
            var uploadFilePath = `${dirPath}/upload-2.txt`;

            const dlStream = dropbox({
                resource: 'files/download',
                parameters: {
                    path: downloadFilePath
                }
            });

            const uploadSteram = dropbox({
                resource: 'files/upload',
                parameters: {
                    path: uploadFilePath
                }
            }, (err, response) => {
                response.should.have.property('size', 30);
                done();
            });

            dlStream.pipe(uploadSteram);
        });
        it('copy_v2', (done) => {
            const sourceFileName = `${dirPath}/upload-2.txt`;
            const targetFileName = `${dirPath}/upload-2-copied.txt`;
            dropbox({
                resource: 'files/copy_v2',
                parameters: {
                    'from_path': sourceFileName,
                    'to_path': targetFileName
                }
            }, (err, response) => {
                if(err){ throw err; }
                response.metadata.should.have.property('path_lower', targetFileName);
                done();
            });
        });
        it('delete_v2', (done) => {
            var fileToDeleteName = `${dirPath}/upload-2-copied.txt`;
            dropbox({
                resource: 'files/delete_v2',
                parameters: {
                    'path': fileToDeleteName
                }
            }, (err, response) => {
                if(err){ throw err; }
                response.metadata.should.have.property('path_lower', fileToDeleteName);
                done();
            });
        });
        it('move', (done) => {
            var targetFileName = `${dirPath}/upload-moved.txt`;
            dropbox({
                resource: 'files/copy_v2',
                parameters: {
                    'from_path': `${dirPath}/upload.txt`,
                    'to_path': targetFileName
                }
            }, (err, response) => {
                if(err){ throw err; }
                response.metadata.should.have.property('path_lower', targetFileName);
                done();
            });
        });
    });
});<|endoftext|>


<commit_before>
var should = require('chai').should()
  , equal = require('..')

describe('Object strucures', function () {
  it('when structures match', function () {
    equal(
      { a : [ 2, 3 ], b : [ 4 ] },
      { a : [ 2, 3 ], b : [ 4 ] }
    ).should.be.true
  })

   it('when structures don\'t match', function () {
    equal(
      { x : 5, y : [6] },
      { x : 5, y : 6 }
    ).should.be.false
   })

   it('should handle nested nulls', function () {
    equal([ null, null, null ], [ null, null, null ]).should.be.true
    equal([ null, null, null ], [ null, 'null', null ]).should.be.false
   })

   it('should handle nested NaNs', function () {
    equal([ NaN, NaN, NaN ], [ NaN, NaN, NaN ]).should.be.true
    equal([ NaN, NaN, NaN ], [ NaN, 'NaN', NaN ]).should.be.false
   })
})

describe('Comparing arguments', function () {
  var a = (function a(a,b,c) {return arguments}(1,2,3))
  var b = (function b(a,b,c) {return arguments}(1,2,3))
  var c = (function c(a,b,c) {return arguments}(2,2,3))

  it('should not consider the callee', function () {
    equal(a,b).should.be.true
    equal(a,c).should.be.false
  })

  it('should be comparable to an Array', function () {
    equal(a,[1,2,3]).should.be.true
    equal(a,[1,2,4]).should.be.false
    equal(a,[1,2]).should.be.false
  })

  it.skip('should be comparable to an Object', function () {
    equal(a, {0:1,1:2,2:3,length:3}).should.be.true
    equal(a, {0:1,1:2,2:3,length:4}).should.be.false
    equal(a, {0:1,1:2,2:4,length:3}).should.be.false
    equal(a, {0:1,1:2,length:2}).should.be.false
  })
})

describe('export.object(a,b)', function () {
  it('should work just the same as equal for objects', function () {
    equal.object(
      { a : [ 2, 3 ], b : [ 4 ] },
      { a : [ 2, 3 ], b : [ 4 ] }
    ).should.be.true
  })
  it.skip('should work when comparing with Arrays', function () {
    equal.object(
      {0:'first', 1: 'second', length:2},
      ['first', 'second']
    ).should.be.true
  })
})

describe('Numbers', function () {
  it('should not coerce strings', function () {
    equal('1', 1).should.equal(false)
  })
  it('-0 should equal +0', function () {
    equal(-0, +0).should.be.true
  })
  describe('NaN', function () {
    it('should equal Nan', function () {
      equal(NaN, NaN).should.be.true
    })
    it('NaN should not equal undefined', function () {
      equal(NaN, undefined).should.be.false
    })
    it('NaN should not equal null', function () {
      equal(NaN, null).should.be.false
    })
    it('NaN should not equal empty string', function () {
      equal(NaN, '').should.be.false
    })
    it('should not equal zero', function () {
      equal(NaN, 0).should.be.false
    })
  })
})

describe('Strings', function () {
  it('should be case sensitive', function () {
    equal('hi', 'Hi').should.equal(false)
    equal('hi', 'hi').should.equal(true)
  })

  it('empty string should equal empty string', function () {
    equal('', "").should.be.true
  })
})

describe('undefined', function () {
  it('should equal only itself', function () {
    equal(undefined, null).should.be.false
    equal(undefined, '').should.be.false
    equal(undefined, 0).should.be.false
    equal(undefined, []).should.be.false
    equal(undefined, undefined).should.be.true
    equal(undefined, NaN).should.be.false
  })
})

describe('null', function () {
  it('should equal only itself', function () {
    equal(null, undefined).should.be.false
    equal(null, '').should.be.false
    equal(null, 0).should.be.false
    equal(null, []).should.be.false
    equal(null, null).should.be.true
    equal(null, NaN).should.be.false
  })
})

describe('Cyclic structures', function () {
  it('should not go into an infinite loop', function () {
    var a = {}
    var b = {}
    a.self = a
    b.self = b
    equal(a, b).should.equal(true)
  })
})

describe('functions', function () {
  it('should fail if they have different names', function () {
    equal(function a() {}, function b() {}).should.be.false
  })

  it('should pass if they are both anonamous', function () {
    equal(function () {}, function () {}).should.be.true
  })

  it.skip('handle the case where they have different argument names', function () {
    equal(function (b) {return b}, function (a) {return a}).should.be.true
  })

  it('should compare them as objects', function () {
    var a = function () {}
    var b = function () {}
    a.title = 'sometitle'
    equal(a, b).should.be.false
  })

  it('should compare their prototypes', function () {
    var a = function () {}
    var b = function () {}
    a.prototype.a = 1
    equal(a,b).should.be.false
  })

  it('should be able to compare object methods', function () {
    equal(
      {noop: function () {}},
      {noop: function () {}}
    ).should.be.true
    equal(
      {noop: function (a) {}},
      {noop: function () {}}
    ).should.be.false
  })
})

describe('many arguments', function () {
  it('should handle no values', function () {
    equal().should.be.true
  })

  it('should handle one value', function () {
    equal({}).should.be.true
  })

  it('should handle many values', function () {
    var vals = []
    for (var i = 0; i < 1000; i++) {
      vals.push({1:'I', 2:'am', 3:'equal'})
    }
    equal.apply(null, vals).should.be.true
  })

  it('should handle an odd number of values', function () {
    equal([1], {}, {}).should.be.false
  })
})

// Don't run these in the browser
if (typeof Buffer != 'undefined') {
  describe.skip('Buffer', function () {
    it('should compare on content', function () {
      equal(new Buffer('abc'), new Buffer('abc')).should.be.true
      equal(new Buffer('a'), new Buffer('b')).should.be.false
      equal(new Buffer('a'), new Buffer('ab')).should.be.false
    })

    it('should fail against anything other than a buffer', function () {
      equal(new Buffer('abc'), [97,98,99]).should.be.false
      equal(new Buffer('abc'), {0:97,1:98,2:99,length:3}).should.be.false
      equal([97,98,99], new Buffer('abc')).should.be.false
      equal({0:97,1:98,2:99,length:3}, new Buffer('abc')).should.be.false
    })
  })
}

describe.skip('configurable property exclusion', function () {
  it('should ignore properties that match the given regex', function () {
    var eq = equal.custom(/^_/)
    eq({_b:2}, {_b:3}).should.be.true
  })

  it('should default to not excluding any properties', function () {
    var eq = equal.custom()
    eq({a:1},{a:1}).should.be.true
    eq({"":1},{}).should.be.false
    eq({a:1},{}).should.be.false
    eq({b:1},{}).should.be.false
    eq({"!":1},{}).should.be.false
    eq({"~":1},{}).should.be.false
    eq({"#":1},{}).should.be.false
    eq({"$":1},{}).should.be.false
    eq({"%":1},{}).should.be.false
    eq({"^":1},{}).should.be.false
    eq({"&":1},{}).should.be.false
    eq({"*":1},{}).should.be.false
    eq({"(":1},{}).should.be.false
    eq({")":1},{}).should.be.false
    eq({"-":1},{}).should.be.false
    eq({"+":1},{}).should.be.false
    eq({"=":1},{}).should.be.false
  })
})

describe('possible regressions', function () {
  it('should handle objects with no constructor property', function () {
    var a = Object.create(null)
    equal(a, {}).should.be.true
    equal({}, a).should.be.true
    equal(a, {a:1}).should.be.false
    equal({a:1}, a).should.be.false
  })

  it('when comparing primitives to composites', function () {
    equal({}, undefined).should.be.false
    equal(undefined, {}).should.be.false

    equal(new String, {}).should.be.false
    equal({}, new String).should.be.false

    equal({}, new Number).should.be.false
    equal(new Number, {}).should.be.false

    equal(new Boolean, {}).should.be.false
    equal({}, new Boolean).should.be.false

    equal(new Date, {}).should.be.false
    equal({}, new Date).should.be.false

    equal(new RegExp, {}).should.be.false
    equal({}, new RegExp).should.be.false
  })
})

describe('compare', function(){
  it('should be usable', function(){
    equal.compare({}, new Date).should.be.false
    equal.compare({}, {}).should.be.true
    equal.compare([], []).should.be.true
  })
})<commit_msg>rm old test<commit_after>
var should = require('chai').should()
  , equal = require('..')

describe('Object strucures', function () {
  it('when structures match', function () {
    equal(
      { a : [ 2, 3 ], b : [ 4 ] },
      { a : [ 2, 3 ], b : [ 4 ] }
    ).should.be.true
  })

   it('when structures don\'t match', function () {
    equal(
      { x : 5, y : [6] },
      { x : 5, y : 6 }
    ).should.be.false
   })

   it('should handle nested nulls', function () {
    equal([ null, null, null ], [ null, null, null ]).should.be.true
    equal([ null, null, null ], [ null, 'null', null ]).should.be.false
   })

   it('should handle nested NaNs', function () {
    equal([ NaN, NaN, NaN ], [ NaN, NaN, NaN ]).should.be.true
    equal([ NaN, NaN, NaN ], [ NaN, 'NaN', NaN ]).should.be.false
   })
})

describe('Comparing arguments', function () {
  var a = (function a(a,b,c) {return arguments}(1,2,3))
  var b = (function b(a,b,c) {return arguments}(1,2,3))
  var c = (function c(a,b,c) {return arguments}(2,2,3))

  it('should not consider the callee', function () {
    equal(a,b).should.be.true
    equal(a,c).should.be.false
  })

  it('should be comparable to an Array', function () {
    equal(a,[1,2,3]).should.be.true
    equal(a,[1,2,4]).should.be.false
    equal(a,[1,2]).should.be.false
  })

  it.skip('should be comparable to an Object', function () {
    equal(a, {0:1,1:2,2:3,length:3}).should.be.true
    equal(a, {0:1,1:2,2:3,length:4}).should.be.false
    equal(a, {0:1,1:2,2:4,length:3}).should.be.false
    equal(a, {0:1,1:2,length:2}).should.be.false
  })
})

describe('Numbers', function () {
  it('should not coerce strings', function () {
    equal('1', 1).should.equal(false)
  })
  it('-0 should equal +0', function () {
    equal(-0, +0).should.be.true
  })
  describe('NaN', function () {
    it('should equal Nan', function () {
      equal(NaN, NaN).should.be.true
    })
    it('NaN should not equal undefined', function () {
      equal(NaN, undefined).should.be.false
    })
    it('NaN should not equal null', function () {
      equal(NaN, null).should.be.false
    })
    it('NaN should not equal empty string', function () {
      equal(NaN, '').should.be.false
    })
    it('should not equal zero', function () {
      equal(NaN, 0).should.be.false
    })
  })
})

describe('Strings', function () {
  it('should be case sensitive', function () {
    equal('hi', 'Hi').should.equal(false)
    equal('hi', 'hi').should.equal(true)
  })

  it('empty string should equal empty string', function () {
    equal('', "").should.be.true
  })
})

describe('undefined', function () {
  it('should equal only itself', function () {
    equal(undefined, null).should.be.false
    equal(undefined, '').should.be.false
    equal(undefined, 0).should.be.false
    equal(undefined, []).should.be.false
    equal(undefined, undefined).should.be.true
    equal(undefined, NaN).should.be.false
  })
})

describe('null', function () {
  it('should equal only itself', function () {
    equal(null, undefined).should.be.false
    equal(null, '').should.be.false
    equal(null, 0).should.be.false
    equal(null, []).should.be.false
    equal(null, null).should.be.true
    equal(null, NaN).should.be.false
  })
})

describe('Cyclic structures', function () {
  it('should not go into an infinite loop', function () {
    var a = {}
    var b = {}
    a.self = a
    b.self = b
    equal(a, b).should.equal(true)
  })
})

describe('functions', function () {
  it('should fail if they have different names', function () {
    equal(function a() {}, function b() {}).should.be.false
  })

  it('should pass if they are both anonamous', function () {
    equal(function () {}, function () {}).should.be.true
  })

  it.skip('handle the case where they have different argument names', function () {
    equal(function (b) {return b}, function (a) {return a}).should.be.true
  })

  it('should compare them as objects', function () {
    var a = function () {}
    var b = function () {}
    a.title = 'sometitle'
    equal(a, b).should.be.false
  })

  it('should compare their prototypes', function () {
    var a = function () {}
    var b = function () {}
    a.prototype.a = 1
    equal(a,b).should.be.false
  })

  it('should be able to compare object methods', function () {
    equal(
      {noop: function () {}},
      {noop: function () {}}
    ).should.be.true
    equal(
      {noop: function (a) {}},
      {noop: function () {}}
    ).should.be.false
  })
})

describe('many arguments', function () {
  it('should handle no values', function () {
    equal().should.be.true
  })

  it('should handle one value', function () {
    equal({}).should.be.true
  })

  it('should handle many values', function () {
    var vals = []
    for (var i = 0; i < 1000; i++) {
      vals.push({1:'I', 2:'am', 3:'equal'})
    }
    equal.apply(null, vals).should.be.true
  })

  it('should handle an odd number of values', function () {
    equal([1], {}, {}).should.be.false
  })
})

// Don't run these in the browser
if (typeof Buffer != 'undefined') {
  describe.skip('Buffer', function () {
    it('should compare on content', function () {
      equal(new Buffer('abc'), new Buffer('abc')).should.be.true
      equal(new Buffer('a'), new Buffer('b')).should.be.false
      equal(new Buffer('a'), new Buffer('ab')).should.be.false
    })

    it('should fail against anything other than a buffer', function () {
      equal(new Buffer('abc'), [97,98,99]).should.be.false
      equal(new Buffer('abc'), {0:97,1:98,2:99,length:3}).should.be.false
      equal([97,98,99], new Buffer('abc')).should.be.false
      equal({0:97,1:98,2:99,length:3}, new Buffer('abc')).should.be.false
    })
  })
}

describe.skip('configurable property exclusion', function () {
  it('should ignore properties that match the given regex', function () {
    var eq = equal.custom(/^_/)
    eq({_b:2}, {_b:3}).should.be.true
  })

  it('should default to not excluding any properties', function () {
    var eq = equal.custom()
    eq({a:1},{a:1}).should.be.true
    eq({"":1},{}).should.be.false
    eq({a:1},{}).should.be.false
    eq({b:1},{}).should.be.false
    eq({"!":1},{}).should.be.false
    eq({"~":1},{}).should.be.false
    eq({"#":1},{}).should.be.false
    eq({"$":1},{}).should.be.false
    eq({"%":1},{}).should.be.false
    eq({"^":1},{}).should.be.false
    eq({"&":1},{}).should.be.false
    eq({"*":1},{}).should.be.false
    eq({"(":1},{}).should.be.false
    eq({")":1},{}).should.be.false
    eq({"-":1},{}).should.be.false
    eq({"+":1},{}).should.be.false
    eq({"=":1},{}).should.be.false
  })
})

describe('possible regressions', function () {
  it('should handle objects with no constructor property', function () {
    var a = Object.create(null)
    equal(a, {}).should.be.true
    equal({}, a).should.be.true
    equal(a, {a:1}).should.be.false
    equal({a:1}, a).should.be.false
  })

  it('when comparing primitives to composites', function () {
    equal({}, undefined).should.be.false
    equal(undefined, {}).should.be.false

    equal(new String, {}).should.be.false
    equal({}, new String).should.be.false

    equal({}, new Number).should.be.false
    equal(new Number, {}).should.be.false

    equal(new Boolean, {}).should.be.false
    equal({}, new Boolean).should.be.false

    equal(new Date, {}).should.be.false
    equal({}, new Date).should.be.false

    equal(new RegExp, {}).should.be.false
    equal({}, new RegExp).should.be.false
  })
})

describe('compare', function(){
  it('should be usable', function(){
    equal.compare({}, new Date).should.be.false
    equal.compare({}, {}).should.be.true
    equal.compare([], []).should.be.true
  })
})<|endoftext|>