diff --git a/.gitignore b/.gitignore
index efa60d6..7f07a39 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,7 @@
.venv
.tox
.idea
+node_modules/*
+bower_components/*
+npm-debug.log
+
diff --git a/bower.json b/bower.json
index 5d4c2fa..f9e9a07 100644
--- a/bower.json
+++ b/bower.json
@@ -12,7 +12,9 @@
"angular-local-storage": "0.1.5",
"angular-elastic": "2.4.2",
"angular-moment": "0.9.0",
- "angular-cache": "3.2.5"
+ "angular-cache": "3.2.5",
+ "js-yaml": "3.2.7",
+ "underscore": "1.8.3"
},
"devDependencies": {
"angular-mocks": "1.3.10",
diff --git a/extensions/enabled/_50_add_mistral_panel.py b/extensions/enabled/_50_add_mistral_panel.py
index d8a8a60..3fd1d46 100644
--- a/extensions/enabled/_50_add_mistral_panel.py
+++ b/extensions/enabled/_50_add_mistral_panel.py
@@ -10,9 +10,8 @@ ADD_INSTALLED_APPS = ['merlin', 'mistral']
# Python panel class of the PANEL to be added.
ADD_PANEL = 'mistral.panel.MistralPanel'
-ADD_ANGULAR_MODULES = ['angular.filter', 'merlin', 'mistral']
-ADD_JS_FILES = ['merlin/js/lib/angular-filter.js',
- 'merlin/js/lib/ui-bootstrap-tpls-0.12.1.js',
+ADD_ANGULAR_MODULES = ['merlin', 'mistral']
+ADD_JS_FILES = ['merlin/js/custom-libs/ui-bootstrap-tpls-0.12.1.js',
'merlin/js/merlin.init.js',
'merlin/js/merlin.templates.js',
'mistral/js/mistral.init.js']
diff --git a/extensions/mistral/templates/mistral/create.html b/extensions/mistral/templates/mistral/create.html
index 35426a6..693e9da 100644
--- a/extensions/mistral/templates/mistral/create.html
+++ b/extensions/mistral/templates/mistral/create.html
@@ -11,9 +11,9 @@
{% block js %}
{% include "horizon/_scripts.html" %}
-
-
-
+
+
+
diff --git a/karma-unit.conf.js b/karma-unit.conf.js
index b210872..97b7327 100644
--- a/karma-unit.conf.js
+++ b/karma-unit.conf.js
@@ -36,28 +36,18 @@ module.exports = function (config) {
files: [
'bower_components/angular/angular.js',
'bower_components/angular-mocks/angular-mocks.js',
- 'merlin/static/merlin/js/lib/underscore-min.js',
+ 'merlin/static/merlin/js/libs/underscore/underscore-min.js',
+ 'merlin/static/merlin/js/libs/js-yaml/dist/js-yaml.min.js',
+ 'merlin/static/merlin/js/custom-libs/barricade.js',
+ // explicitly require first module definition file to avoid errors
'merlin/static/merlin/js/merlin.init.js',
- 'merlin/static/merlin/js/merlin.templates.js',
- 'merlin/static/merlin/js/merlin.directives.js',
- 'merlin/static/merlin/js/merlin.filters.js',
- 'merlin/static/merlin/js/merlin.field.models.js',
- 'merlin/static/merlin/js/merlin.panel.models.js',
- 'merlin/static/merlin/js/merlin.utils.js',
- 'merlin/static/merlin/js/lib/angular-filter.js',
- 'merlin/static/merlin/js/lib/barricade.js',
- 'merlin/static/merlin/js/lib/js-yaml.js',
+ 'merlin/static/merlin/js/merlin.*.js',
'merlin/static/merlin/templates/**/*.html',
-// 'merlin/static/merlin/templates/fields/*.html',
- 'merlin/test/js/utilsSpec.js',
- 'merlin/test/js/templatesSpec.js',
- 'merlin/test/js/filtersSpec.js',
- 'merlin/test/js/directivesSpec.js',
-
+ 'merlin/test/js/*Spec.js',
+ // explicitly require first module definition file to avoid errors
'extensions/mistral/static/mistral/js/mistral.init.js',
- 'extensions/mistral/static/mistral/js/mistral.workbook.models.js',
- 'extensions/mistral/static/mistral/js/mistral.workbook.controllers.js',
- 'extensions/mistral/test/js/workbookSpec.js'
+ 'extensions/mistral/static/mistral/js/mistral.*.js',
+ 'extensions/mistral/test/js/*Spec.js'
],
preprocessors: {
diff --git a/merlin/static/merlin/js/lib/barricade.js b/merlin/static/merlin/js/custom-libs/barricade.js
similarity index 100%
rename from merlin/static/merlin/js/lib/barricade.js
rename to merlin/static/merlin/js/custom-libs/barricade.js
diff --git a/merlin/static/merlin/js/lib/ui-bootstrap-tpls-0.12.0.js b/merlin/static/merlin/js/custom-libs/ui-bootstrap-tpls-0.12.0.js
similarity index 100%
rename from merlin/static/merlin/js/lib/ui-bootstrap-tpls-0.12.0.js
rename to merlin/static/merlin/js/custom-libs/ui-bootstrap-tpls-0.12.0.js
diff --git a/merlin/static/merlin/js/lib/ui-bootstrap-tpls-0.12.1.js b/merlin/static/merlin/js/custom-libs/ui-bootstrap-tpls-0.12.1.js
similarity index 100%
rename from merlin/static/merlin/js/lib/ui-bootstrap-tpls-0.12.1.js
rename to merlin/static/merlin/js/custom-libs/ui-bootstrap-tpls-0.12.1.js
diff --git a/merlin/static/merlin/js/lib/angular-filter.js b/merlin/static/merlin/js/lib/angular-filter.js
deleted file mode 100644
index 66bb33c..0000000
--- a/merlin/static/merlin/js/lib/angular-filter.js
+++ /dev/null
@@ -1,2186 +0,0 @@
-/**
- * Bunch of useful filters for angularJS(with no external dependencies!)
- * @version v0.5.1 - 2014-11-12 * @link https://github.com/a8m/angular-filter
- * @author Ariel Mashraki
- * @license MIT License, http://www.opensource.org/licenses/MIT
- */
-(function ( window, angular, undefined ) {
-/*jshint globalstrict:true*/
-'use strict';
-
-var isDefined = angular.isDefined,
- isUndefined = angular.isUndefined,
- isFunction = angular.isFunction,
- isString = angular.isString,
- isNumber = angular.isNumber,
- isObject = angular.isObject,
- isArray = angular.isArray,
- forEach = angular.forEach,
- extend = angular.extend,
- copy = angular.copy,
- equals = angular.equals;
-
-
-/**
- * @description
- * get an object and return array of values
- * @param object
- * @returns {Array}
- */
-function toArray(object) {
- return isArray(object) ? object :
- Object.keys(object).map(function(key) {
- return object[key];
- });
-}
-
-/**
- * @param value
- * @returns {boolean}
- */
-function isNull(value) {
- return value === null;
-}
-
-/**
- * @description
- * return if object contains partial object
- * @param partial{object}
- * @param object{object}
- * @returns {boolean}
- */
-function objectContains(partial, object) {
- var keys = Object.keys(partial);
-
- return keys.map(function(el) {
- return !(!object[el] || (object[el] != partial[el]));
- }).indexOf(false) == -1;
-
-}
-
-/**
- * @description
- * search for approximate pattern in string
- * @param word
- * @param pattern
- * @returns {*}
- */
-function hasApproxPattern(word, pattern) {
- if(pattern === '')
- return word;
-
- var index = word.indexOf(pattern.charAt(0));
-
- if(index === -1)
- return false;
-
- return hasApproxPattern(word.substr(index+1), pattern.substr(1))
-}
-
-/**
- * @description
- * return the first n element of an array,
- * if expression provided, is returns as long the expression return truthy
- * @param array
- * @param n {number}
- * @param expression {$parse}
- * @return array or single object
- */
-function getFirstMatches(array, n, expression) {
- var count = 0;
-
- return array.filter(function(elm) {
- var rest = isDefined(expression) ? (count < n && expression(elm)) : count < n;
- count = rest ? count+1 : count;
-
- return rest;
- });
-}
-/**
- * Polyfill to ECMA6 String.prototype.contains
- */
-if (!String.prototype.contains) {
- String.prototype.contains = function() {
- return String.prototype.indexOf.apply(this, arguments) !== -1;
- };
-}
-
-/**
- * @param num {Number}
- * @param decimal {Number}
- * @param $math
- * @returns {Number}
- */
-function convertToDecimal(num, decimal, $math){
- return $math.round(num * $math.pow(10,decimal)) / ($math.pow(10,decimal));
-}
-
-/**
- * @description
- * Get an object, and return an array composed of it's properties names(nested too).
- * @param obj {Object}
- * @param stack {Array}
- * @param parent {String}
- * @returns {Array}
- * @example
- * parseKeys({ a:1, b: { c:2, d: { e: 3 } } }) ==> ["a", "b.c", "b.d.e"]
- */
-function deepKeys(obj, stack, parent) {
- stack = stack || [];
- var keys = Object.keys(obj);
-
- keys.forEach(function(el) {
- //if it's a nested object
- if(isObject(obj[el]) && !isArray(obj[el])) {
- //concatenate the new parent if exist
- var p = parent ? parent + '.' + el : parent;
- deepKeys(obj[el], stack, p || el);
- } else {
- //create and save the key
- var key = parent ? parent + '.' + el : el;
- stack.push(key)
- }
- });
- return stack
-}
-
-/**
- * @description
- * Test if given object is a Scope instance
- * @param obj
- * @returns {Boolean}
- */
-function isScope(obj) {
- return obj && obj.$evalAsync && obj.$watch;
-}
-/**
- * @ngdoc filter
- * @name a8m.templates
- * @kind function
- *
- * @description
- * reference to templates function
- */
-
-angular.module('a8m.angular', [])
-
- .filter('isUndefined', function () {
- return function (input) {
- return angular.isUndefined(input);
- }
- })
- .filter('isDefined', function() {
- return function (input) {
- return angular.isDefined(input);
- }
- })
- .filter('isFunction', function() {
- return function (input) {
- return angular.isFunction(input);
- }
- })
- .filter('isString', function() {
- return function (input) {
- return angular.isString(input)
- }
- })
- .filter('isNumber', function() {
- return function (input) {
- return angular.isNumber(input);
- }
- })
- .filter('isArray', function() {
- return function (input) {
- return angular.isArray(input);
- }
- })
- .filter('isObject', function() {
- return function (input) {
- return angular.isObject(input);
- }
- })
- .filter('isEqual', function() {
- return function (o1, o2) {
- return angular.equals(o1, o2);
- }
- });
-
-/**
- * @ngdoc filter
- * @name a8m.conditions
- * @kind function
- *
- * @description
- * reference to math conditions
- */
- angular.module('a8m.conditions', [])
-
- .filter({
- isGreaterThan : isGreaterThanFilter,
- '>' : isGreaterThanFilter,
-
- isGreaterThanOrEqualTo : isGreaterThanOrEqualToFilter,
- '>=' : isGreaterThanOrEqualToFilter,
-
- isLessThan : isLessThanFilter,
- '<' : isLessThanFilter,
-
- isLessThanOrEqualTo : isLessThanOrEqualToFilter,
- '<=' : isLessThanOrEqualToFilter,
-
- isEqualTo : isEqualToFilter,
- '==' : isEqualToFilter,
-
- isNotEqualTo : isNotEqualToFilter,
- '!=' : isNotEqualToFilter,
-
- isIdenticalTo : isIdenticalToFilter,
- '===' : isIdenticalToFilter,
-
- isNotIdenticalTo : isNotIdenticalToFilter,
- '!==' : isNotIdenticalToFilter
- });
-
- function isGreaterThanFilter() {
- return function (input, check) {
- return input > check;
- };
- }
-
- function isGreaterThanOrEqualToFilter() {
- return function (input, check) {
- return input >= check;
- };
- }
-
- function isLessThanFilter() {
- return function (input, check) {
- return input < check;
- };
- }
-
- function isLessThanOrEqualToFilter() {
- return function (input, check) {
- return input <= check;
- };
- }
-
- function isEqualToFilter() {
- return function (input, check) {
- return input == check;
- };
- }
-
- function isNotEqualToFilter() {
- return function (input, check) {
- return input != check;
- };
- }
-
- function isIdenticalToFilter() {
- return function (input, check) {
- return input === check;
- };
- }
-
- function isNotIdenticalToFilter() {
- return function (input, check) {
- return input !== check;
- };
- }
-/**
- * @ngdoc filter
- * @name isNull
- * @kind function
- *
- * @description
- * checks if value is null or not
- * @return Boolean
- */
-
-angular.module('a8m.is-null', [])
-
- .filter('isNull', function () {
- return function(input) {
- return isNull(input);
- }
- });
-
-/**
- * @ngdoc filter
- * @name after-where
- * @kind function
- *
- * @description
- * get a collection and properties object, and returns all of the items
- * in the collection after the first that found with the given properties.
- *
- */
-
-angular.module('a8m.after-where', [])
- .filter('afterWhere', function() {
- return function (collection, object) {
-
- collection = (isObject(collection)) ?
- toArray(collection) :
- collection;
-
- if(!isArray(collection) || isUndefined(object))
- return collection;
-
- var index = collection.map( function( elm ) {
- return objectContains(object, elm);
- }).indexOf( true );
-
- return collection.slice((index === -1) ? 0 : index);
- }
- });
-
-/**
- * @ngdoc filter
- * @name after
- * @kind function
- *
- * @description
- * get a collection and specified count, and returns all of the items
- * in the collection after the specified count.
- *
- */
-
-angular.module('a8m.after', [])
- .filter('after', function() {
- return function (collection, count) {
-
- collection = (isObject(collection)) ?
- toArray(collection) :
- collection;
-
- return (isArray(collection)) ?
- collection.slice(count) :
- collection;
-
- }
- });
-
-/**
- * @ngdoc filter
- * @name before-where
- * @kind function
- *
- * @description
- * get a collection and properties object, and returns all of the items
- * in the collection before the first that found with the given properties.
- *
- */
-
-angular.module('a8m.before-where', [])
- .filter('beforeWhere', function() {
- return function (collection, object) {
-
- collection = (isObject(collection)) ?
- toArray(collection) :
- collection;
-
- if(!isArray(collection) || isUndefined(object))
- return collection;
-
- var index = collection.map( function( elm ) {
- return objectContains(object, elm);
- }).indexOf( true );
-
- return collection.slice(0, (index === -1) ? collection.length : ++index);
- }
- });
-
-/**
- * @ngdoc filter
- * @name before
- * @kind function
- *
- * @description
- * get a collection and specified count, and returns all of the items
- * in the collection before the specified count.
- *
- */
-
-angular.module('a8m.before', [])
- .filter('before', function() {
- return function (collection, count) {
-
- collection = (isObject(collection)) ?
- toArray(collection) :
- collection;
-
- return (isArray(collection)) ?
- collection.slice(0, (!count) ? count : --count) :
- collection;
-
- }
- });
-
-/**
- * @ngdoc filter
- * @name concat
- * @kind function
- *
- * @description
- * get (array/object, object/array) and return merged collection
- *
- */
-
-angular.module('a8m.concat', [])
- //TODO:unique option ? or use unique filter to filter result
- .filter('concat', [function () {
- return function (collection, joined) {
-
- if (isUndefined(joined)) {
- return collection;
- }
- if (isArray(collection)) {
- return (isObject(joined)) ?
- collection.concat(toArray(joined)) :
- collection.concat(joined);
- }
-
- if (isObject(collection)) {
- var array = toArray(collection);
- return (isObject(joined)) ?
- array.concat(toArray(joined)) :
- array.concat(joined);
- }
- return collection;
- };
- }
-]);
-
-/**
- * @ngdoc filter
- * @name contains
- * @kind function
- *
- * @description
- * Checks if given expression is present in one or more object in the collection
- */
-
-angular.module('a8m.contains', [])
- .filter({
- contains: ['$parse', containsFilter],
- some: ['$parse', containsFilter]
- });
-
-function containsFilter( $parse ) {
- return function (collection, expression) {
-
- collection = (isObject(collection)) ? toArray(collection) : collection;
-
- if(!isArray(collection) || isUndefined(expression)) {
- return true;
- }
-
- return collection.some( function(elm) {
-
- return (isObject(elm) || isFunction(expression)) ?
- $parse(expression)(elm) :
- elm === expression;
-
- });
-
- }
- }
-
-/**
- * @ngdoc filter
- * @name countBy
- * @kind function
- *
- * @description
- * Sorts a list into groups and returns a count for the number of objects in each group.
- */
-
-angular.module('a8m.count-by', [])
-
- .filter('countBy', [ '$parse', function ( $parse ) {
- return function (collection, property) {
-
- var result = {},
- get = $parse(property),
- prop;
-
- collection = (isObject(collection)) ? toArray(collection) : collection;
-
- if(!isArray(collection) || isUndefined(property)) {
- return collection;
- }
-
- collection.forEach( function( elm ) {
- prop = get(elm);
-
- if(!result[prop]) {
- result[prop] = 0;
- }
-
- result[prop]++;
- });
-
- return result;
- }
- }]);
-
-/**
- * @ngdoc filter
- * @name defaults
- * @kind function
- *
- * @description
- * defaultsFilter allows to specify a default fallback value for properties that resolve to undefined.
- */
-
-angular.module('a8m.defaults', [])
- .filter('defaults', ['$parse', function( $parse ) {
- return function(collection, defaults) {
-
- collection = (isObject(collection)) ? toArray(collection) : collection;
-
- if(!isArray(collection) || !isObject(defaults)) {
- return collection;
- }
-
- var keys = deepKeys(defaults);
-
- collection.forEach(function(elm) {
- //loop through all the keys
- keys.forEach(function(key) {
- var getter = $parse(key);
- var setter = getter.assign;
- //if it's not exist
- if(isUndefined(getter(elm))) {
- //get from defaults, and set to the returned object
- setter(elm, getter(defaults))
- }
- });
- });
-
- return collection;
- }
- }]);
-/**
- * @ngdoc filter
- * @name every
- * @kind function
- *
- * @description
- * Checks if given expression is present in all members in the collection
- *
- */
-
-angular.module('a8m.every', [])
- .filter('every', ['$parse', function($parse) {
- return function (collection, expression) {
-
- collection = (isObject(collection)) ? toArray(collection) : collection;
-
- if(!isArray(collection) || isUndefined(expression)) {
- return true;
- }
-
- return collection.every( function(elm) {
-
- return (isObject(elm) || isFunction(expression)) ?
- $parse(expression)(elm) :
- elm === expression;
- });
-
- }
- }]);
-
-/**
- * @ngdoc filter
- * @name filterBy
- * @kind function
- *
- * @description
- * filter by specific properties, avoid the rest
- */
-angular.module('a8m.filter-by', [])
-
- .filter('filterBy', ['$parse', function( $parse ) {
- return function(collection, properties, search) {
-
- var comparator;
-
- search = (isString(search) || isNumber(search)) ?
- String(search).toLowerCase() : undefined;
-
- collection = (isObject(collection)) ? toArray(collection) : collection;
-
- if(!isArray(collection) || isUndefined(search)) {
- return collection;
- }
-
- return collection.filter(function(elm) {
-
- return properties.some(function(prop) {
-
- /**
- * check if there is concatenate properties
- * example:
- * object: { first: 'foo', last:'bar' }
- * filterBy: ['first + last'] => search by full name(i.e 'foo bar')
- */
- if(!~prop.indexOf('+')) {
- comparator = $parse(prop)(elm)
- } else {
- var propList = prop.replace(new RegExp('\\s', 'g'), '').split('+');
- comparator = propList.reduce(function(prev, cur, index) {
- return (index === 1) ? $parse(prev)(elm) + ' ' + $parse(cur)(elm) :
- prev + ' ' + $parse(cur)(elm);
- });
- }
-
- return (isString(comparator) || isNumber(comparator)) ?
- String(comparator).toLowerCase().contains(search) :
- false;
- })
-
- });
-
- }
- }]);
-
-/**
- * @ngdoc filter
- * @name first
- * @kind function
- *
- * @description
- * Gets the first element or first n elements of an array
- * if callback is provided, is returns as long the callback return truthy
- */
-angular.module('a8m.first', [])
-
- .filter('first', ['$parse', function( $parse ) {
- return function(collection) {
-
- var n,
- getter,
- args;
-
- collection = (isObject(collection)) ? toArray(collection) :
- collection;
-
- if(!isArray(collection)) {
- return collection;
- }
-
- args = Array.prototype.slice.call(arguments, 1);
- n = (isNumber(args[0])) ? args[0] : 1;
- getter = (!isNumber(args[0])) ? args[0] : (!isNumber(args[1])) ? args[1] : undefined;
-
- return (args.length) ? getFirstMatches(collection, n,(getter) ? $parse(getter) : getter) :
- collection[0];
- }
- }]);
-
-/**
- * @ngdoc filter
- * @name flatten
- * @kind function
- *
- * @description
- * Flattens a nested array (the nesting can be to any depth).
- * If you pass shallow, the array will only be flattened a single level
- */
-
-angular.module('a8m.flatten', [])
- .filter('flatten', function () {
- return function(collection, shallow) {
-
- shallow = shallow || false;
- collection = (isObject(collection)) ? toArray(collection)
- : collection;
-
- if(!isArray(collection)) {
- return collection;
- }
-
- return (!shallow) ? flatten(collection, 0) :
- [].concat.apply([], collection);
- }
- });
-
-/**
- * flatten nested array (the nesting can be to any depth).
- * @param array {Array}
- * @param i {int}
- * @returns {Array}
- * @private
- */
-function flatten(array, i) {
- i = i || 0;
-
- if(i >= array.length)
- return array;
-
- if(isArray(array[i])) {
- return flatten(array.slice(0,i)
- .concat(array[i], array.slice(i+1)), i);
- }
- return flatten(array, i+1);
-}
-
-/**
- * @ngdoc filter
- * @name fuzzyByKey
- * @kind function
- *
- * @description
- * fuzzy string searching by key
- */
-
-angular.module('a8m.fuzzy-by', [])
- .filter('fuzzyBy', ['$parse', function ( $parse ) {
- return function (collection, property, search, csensitive) {
-
- var sensitive = csensitive || false,
- prop, getter;
-
- collection = (isObject(collection)) ? toArray(collection) : collection;
-
- if(!isArray(collection) || isUndefined(property)
- || isUndefined(search)) {
- return collection;
- }
-
- getter = $parse(property);
-
- return collection.filter(function(elm) {
-
- prop = getter(elm);
- if(!isString(prop)) {
- return false;
- }
-
- prop = (sensitive) ? prop : prop.toLowerCase();
- search = (sensitive) ? search : search.toLowerCase();
-
- return hasApproxPattern(prop, search) !== false
- })
- }
-
- }]);
-/**
- * @ngdoc filter
- * @name fuzzy
- * @kind function
- *
- * @description
- * fuzzy string searching for array of strings, objects
- */
-
-angular.module('a8m.fuzzy', [])
- .filter('fuzzy', function () {
- return function (collection, search, csensitive) {
-
- var sensitive = csensitive || false;
-
- collection = (isObject(collection)) ? toArray(collection) : collection;
-
- if(!isArray(collection) || isUndefined(search)) {
- return collection;
- }
-
- search = (sensitive) ? search : search.toLowerCase();
-
- return collection.filter(function(elm) {
-
- if(isString(elm)) {
- elm = (sensitive) ? elm : elm.toLowerCase();
- return hasApproxPattern(elm, search) !== false
- }
-
- return (isObject(elm)) ? _hasApproximateKey(elm, search) : false;
-
- });
-
- /**
- * checks if object has key{string} that match
- * to fuzzy search pattern
- * @param object
- * @param search
- * @returns {boolean}
- * @private
- */
- function _hasApproximateKey(object, search) {
- var properties = Object.keys(object),
- prop, flag;
- return 0 < properties.filter(function (elm) {
- prop = object[elm];
-
- //avoid iteration if we found some key that equal[performance]
- if(flag) return true;
-
- if (isString(prop)) {
- prop = (sensitive) ? prop : prop.toLowerCase();
- return flag = (hasApproxPattern(prop, search) !== false);
- }
-
- return false;
-
- }).length;
- }
-
- }
- });
-
-/**
- * @ngdoc filter
- * @name groupBy
- * @kind function
- *
- * @description
- * Create an object composed of keys generated from the result of running each element of a collection,
- * each key is an array of the elements.
- */
-
-angular.module('a8m.group-by', [ 'a8m.filter-watcher' ])
-
- .filter('groupBy', [ '$parse', 'filterWatcher', function ( $parse, filterWatcher ) {
- return function (collection, property) {
-
- if(!isObject(collection) || isUndefined(property)) {
- return collection;
- }
-
- var getterFn = $parse(property);
-
- return filterWatcher.isMemoized('groupBy', arguments) ||
- filterWatcher.memoize('groupBy', arguments, this,
- _groupBy(collection, getterFn));
-
- /**
- * groupBy function
- * @param collection
- * @param getter
- * @returns {{}}
- */
- function _groupBy(collection, getter) {
- var result = {};
- var prop;
-
- forEach( collection, function( elm ) {
- prop = getter(elm);
-
- if(!result[prop]) {
- result[prop] = [];
- }
- result[prop].push(elm);
- });
- return result;
- }
- }
- }]);
-
-/**
- * @ngdoc filter
- * @name isEmpty
- * @kind function
- *
- * @description
- * get collection or string and return if it empty
- */
-
-angular.module('a8m.is-empty', [])
- .filter('isEmpty', function () {
- return function(collection) {
- return (isObject(collection)) ?
- !toArray(collection).length :
- !collection.length;
- }
- });
-
-/**
- * @ngdoc filter
- * @name last
- * @kind function
- *
- * @description
- * Gets the last element or last n elements of an array
- * if callback is provided, is returns as long the callback return truthy
- */
-angular.module('a8m.last', [])
-
- .filter('last', ['$parse', function( $parse ) {
- return function(collection) {
-
- var n,
- getter,
- args,
- //cuz reverse change our src collection
- //and we don't want side effects
- reversed = copy(collection);
-
- reversed = (isObject(reversed)) ? toArray(reversed) :
- reversed;
-
- if(!isArray(reversed)) {
- return reversed;
- }
-
- args = Array.prototype.slice.call(arguments, 1);
- n = (isNumber(args[0])) ? args[0] : 1;
- getter = (!isNumber(args[0])) ? args[0] : (!isNumber(args[1])) ? args[1] : undefined;
-
- return (args.length) ?
- //send reversed collection as arguments, and reverse it back as result
- getFirstMatches(reversed.reverse(), n,(getter) ? $parse(getter) : getter).reverse() :
- //get the last element
- reversed[reversed.length-1];
- }
- }]);
-
-/**
- * @ngdoc filter
- * @name map
- * @kind function
- *
- * @description
- * Returns a new collection of the results of each expression execution.
- */
-
-angular.module('a8m.map', [])
-
- .filter('map', ['$parse', function($parse) {
- return function (collection, expression) {
-
- collection = (isObject(collection)) ?
- toArray(collection) : collection;
-
- if(!isArray(collection) || isUndefined(expression)) {
- return collection;
- }
-
- return collection.map(function (elm) {
-
- return $parse(expression)(elm);
- });
- }
- }]);
-
-/**
- * @ngdoc filter
- * @name omit
- * @kind function
- *
- * @description
- * filter collection by expression
- */
-
-angular.module('a8m.omit', [])
-
- .filter('omit', ['$parse', function($parse) {
- return function (collection, expression) {
-
- collection = (isObject(collection)) ?
- toArray(collection) : collection;
-
- if(!isArray(collection) || isUndefined(expression)) {
- return collection;
- }
-
- return collection.filter(function (elm) {
-
- return !($parse(expression)(elm));
- });
- }
- }]);
-
-/**
- * @ngdoc filter
- * @name omit
- * @kind function
- *
- * @description
- * filter collection by expression
- */
-
-angular.module('a8m.pick', [])
-
- .filter('pick', ['$parse', function($parse) {
- return function (collection, expression) {
-
- collection = (isObject(collection)) ?
- toArray(collection) : collection;
-
- if(!isArray(collection) || isUndefined(expression)) {
- return collection;
- }
-
- return collection.filter(function (elm) {
-
- return $parse(expression)(elm);
- });
- }
- }]);
-
-/**
- * @ngdoc filter
- * @name removeWith
- * @kind function
- *
- * @description
- * get collection and properties object, and removed elements
- * with this properties
- */
-
-angular.module('a8m.remove-with', [])
- .filter('removeWith', function() {
- return function (collection, object) {
-
- if(isUndefined(object)) {
- return collection;
- }
- collection = (isObject(collection)) ?
- toArray(collection) : collection;
-
- return collection.filter(function (elm) {
- return !objectContains(object, elm);
- });
- }
- });
-
-
-/**
- * @ngdoc filter
- * @name remove
- * @kind function
- *
- * @description
- * remove specific members from collection
- */
-
-angular.module('a8m.remove', [])
-
- .filter('remove', function () {
- return function (collection) {
-
- collection = (isObject(collection)) ? toArray(collection) : collection;
-
- var args = Array.prototype.slice.call(arguments, 1);
-
- if(!isArray(collection)) {
- return collection;
- }
-
- return collection.filter( function( member ) {
- return !args.some(function(nest) {
- return equals(nest, member);
- })
- });
-
- }
- });
-
-/**
- * @ngdoc filter
- * @name reverse
- * @kind function
- *
- * @description
- * Reverses a string or collection
- */
-
-angular.module('a8m.reverse', [])
-
- .filter('reverse',[ function () {
- return function (input) {
-
- input = (isObject(input)) ? toArray(input) : input;
-
- if(isString(input)) {
- return input.split('').reverse().join('');
- }
-
- return (isArray(input)) ? input.slice().reverse() : input;
- }
- }]);
-
-
-/**
- * @ngdoc filter
- * @name searchField
- * @kind function
- *
- * @description
- * for each member, join several strings field and add them to
- * new field called 'searchField' (use for search filtering)
- */
-
-angular.module('a8m.search-field', [])
-
- .filter('searchField', ['$parse', function ($parse) {
- return function (collection) {
-
- var get, field;
-
- collection = (isObject(collection)) ? toArray(collection) : collection;
-
- var args = Array.prototype.slice.call(arguments, 1);
-
- if(!isArray(collection) || !args.length) {
- return collection;
- }
-
- return collection.map(function(member) {
-
- field = args.map(function(field) {
- get = $parse(field);
- return get(member);
- }).join(' ');
-
- return extend(member, { searchField: field });
- });
- }
- }]);
-
-/**
- * @ngdoc filter
- * @name toArray
- * @kind function
- *
- * @description
- * Convert objects into stable arrays.
- * if addKey set to true,the filter also attaches a new property
- * $key to the value containing the original key that was used in
- * the object we are iterating over to reference the property
- */
-
-angular.module('a8m.to-array', [])
-
- .filter('toArray', function() {
- return function (collection, addKey) {
-
- if(!isObject(collection)) {
- return collection;
- }
-
- return (!addKey) ? toArray(collection) :
-
- Object.keys(collection).map(function (key) {
- return extend(collection[key], { $key: key });
- });
- }
- });
-
-/**
- * @ngdoc filter
- * @name unique/uniq
- * @kind function
- *
- * @description
- * get collection and filter duplicate members
- * if uniqueFilter get a property(nested to) as argument it's
- * filter by this property as unique identifier
- */
-
-angular.module('a8m.unique', [])
- .filter({
- unique: ['$parse', uniqFilter],
- uniq: ['$parse', uniqFilter]
- });
-
-function uniqFilter($parse) {
- return function (collection, property) {
-
- collection = (isObject(collection)) ? toArray(collection) : collection;
-
- if (!isArray(collection)) {
- return collection;
- }
-
- //store all unique identifiers
- var uniqueItems = [],
- get = $parse(property);
-
- return (isUndefined(property)) ?
- //if it's kind of primitive array
- collection.filter(function (elm, pos, self) {
- return self.indexOf(elm) === pos;
- }) :
- //else compare with equals
- collection.filter(function (elm) {
- var prop = get(elm);
- if(some(uniqueItems, prop)) {
- return false;
- }
- uniqueItems.push(prop);
- return true;
- });
-
- //checked if the unique identifier is already exist
- function some(array, member) {
- if(isUndefined(member)) {
- return false;
- }
- return array.some(function(el) {
- return equals(el, member);
- });
- }
-
- }
-}
-
-/**
- * @ngdoc filter
- * @name where
- * @kind function
- *
- * @description
- * of each element in a collection to the given properties object,
- * returning an array of all elements that have equivalent property values.
- *
- */
-
-angular.module('a8m.where', [])
- .filter('where', function() {
- return function (collection, object) {
-
- if(isUndefined(object)) {
- return collection;
- }
- collection = (isObject(collection)) ?
- toArray(collection) : collection;
-
- return collection.filter(function (elm) {
- return objectContains(object, elm);
- });
- }
- });
-
-/**
- * @ngdoc filter
- * @name xor
- * @kind function
- *
- * @description
- * Exclusive or filter by expression
- */
-
-angular.module('a8m.xor', [])
-
- .filter('xor', ['$parse', function($parse) {
- return function (col1, col2, expression) {
-
- expression = expression || false;
-
- col1 = (isObject(col1)) ? toArray(col1) : col1;
- col2 = (isObject(col2)) ? toArray(col2) : col2;
-
- if(!isArray(col1) || !isArray(col2)) return col1;
-
- return col1.concat(col2)
- .filter(function(elm) {
- return !(some(elm, col1) && some(elm, col2));
- });
-
- function some(el, col) {
- var getter = $parse(expression);
- return col.some(function(dElm) {
- return expression ?
- equals(getter(dElm), getter(el)) :
- equals(dElm, el);
- })
- }
- }
- }]);
-
-/**
- * @ngdoc filter
- * @name formatBytes
- * @kind function
- *
- * @description
- * Convert bytes into appropriate display
- * 1024 bytes => 1 KB
- */
-
-angular.module('a8m.math.byteFmt', ['a8m.math'])
-
- .filter('byteFmt', ['$math', function ($math) {
- return function (bytes, decimal) {
-
- if(isNumber(decimal) && isFinite(decimal) && decimal%1===0 && decimal >= 0 &&
- isNumber(bytes) && isFinite(bytes)) {
-
- if(bytes < 1024) { // within 1 KB so B
- return convertToDecimal(bytes, decimal, $math) + ' B';
- } else if(bytes < 1048576) { // within 1 MB so KB
- return convertToDecimal((bytes / 1024), decimal, $math) + ' KB';
- } else if(bytes < 1073741824){ // within 1 GB so MB
- return convertToDecimal((bytes / 1048576), decimal, $math) + ' MB';
- } else { // GB or more
- return convertToDecimal((bytes / 1073741824), decimal, $math) + ' GB';
- }
-
- } else {
- return "NaN";
- }
- }
- }]);
-/**
- * @ngdoc filter
- * @name degrees
- * @kind function
- *
- * @description
- * Convert angle from radians to degrees
- *
- */
-
-angular.module('a8m.math.degrees', ['a8m.math'])
-
- .filter('degrees', ['$math', function ($math) {
- return function (radians, decimal) {
- // if decimal is not an integer greater than -1, we cannot do. quit with error "NaN"
- // if degrees is not a real number, we cannot do also. quit with error "NaN"
- if(isNumber(decimal) && isFinite(decimal) && decimal%1===0 && decimal >= 0 &&
- isNumber(radians) && isFinite(radians)) {
- var degrees = (radians * 180) / $math.PI;
- return $math.round(degrees * $math.pow(10,decimal)) / ($math.pow(10,decimal));
- } else {
- return "NaN";
- }
- }
-}]);
-
-
-
-/**
- * @ngdoc filter
- * @name formatBytes
- * @kind function
- *
- * @description
- * Convert bytes into appropriate display
- * 1024 kilobytes => 1 MB
- */
-
-angular.module('a8m.math.kbFmt', ['a8m.math'])
-
- .filter('kbFmt', ['$math', function ($math) {
- return function (bytes, decimal) {
-
- if(isNumber(decimal) && isFinite(decimal) && decimal%1===0 && decimal >= 0 &&
- isNumber(bytes) && isFinite(bytes)) {
-
- if(bytes < 1024) { // within 1 MB so KB
- return convertToDecimal(bytes, decimal, $math) + ' KB';
- } else if(bytes < 1048576) { // within 1 GB so MB
- return convertToDecimal((bytes / 1024), decimal, $math) + ' MB';
- } else {
- return convertToDecimal((bytes / 1048576), decimal, $math) + ' GB';
- }
-
- } else {
- return "NaN";
- }
- }
-}]);
-/**
- * @ngdoc module
- * @name math
- * @description
- * reference to global Math object
- */
-
-angular.module('a8m.math', [])
- .factory('$math', ['$window', function ($window) {
-
- return $window.Math;
-
- }]);
-
-/**
- * @ngdoc filter
- * @name max
- * @kind function
- *
- * @description
- * Math.max will get an array and return the max value. if an expression
- * is provided, will return max value by expression.
- */
-
-angular.module('a8m.math.max', ['a8m.math'])
-
- .filter('max', ['$math', '$parse', function ($math, $parse) {
- return function (input, expression) {
-
- if(!isArray(input)) {
- return input;
- }
- return isUndefined(expression)
- ? $math.max.apply($math, input)
- : input[indexByMax(input, expression)];
- };
-
- /**
- * @private
- * @param array
- * @param exp
- * @returns {number|*|Number}
- */
- function indexByMax(array, exp) {
- var mappedArray = array.map(function(elm){
- return $parse(exp)(elm);
- });
- return mappedArray.indexOf($math.max.apply($math, mappedArray));
- }
-
- }]);
-/**
- * @ngdoc filter
- * @name min
- * @kind function
- *
- * @description
- * Math.min will get an array and return the min value. if an expression
- * is provided, will return min value by expression.
- */
-
-angular.module('a8m.math.min', ['a8m.math'])
-
- .filter('min', ['$math', '$parse', function ($math, $parse) {
- return function (input, expression) {
-
- if(!isArray(input)) {
- return input;
- }
- return isUndefined(expression)
- ? $math.min.apply($math, input)
- : input[indexByMin(input, expression)];
- };
-
- /**
- * @private
- * @param array
- * @param exp
- * @returns {number|*|Number}
- */
- function indexByMin(array, exp) {
- var mappedArray = array.map(function(elm){
- return $parse(exp)(elm);
- });
- return mappedArray.indexOf($math.min.apply($math, mappedArray));
- }
-
- }]);
-/**
- * @ngdoc filter
- * @name Percent
- * @kind function
- *
- * @description
- * percentage between two numbers
- *
- */
-
-angular.module('a8m.math.percent', ['a8m.math'])
-
- .filter('percent', ['$math', '$window', function ($math, $window) {
-
- return function (input, divided, round) {
-
- var divider = (isString(input)) ? $window.Number(input) : input;
- divided = divided || 100;
- round = round || false;
-
- if (!isNumber(divider) || $window.isNaN(divider)) return input;
-
- return (round) ? $math.round((divider / divided) * 100) :
- ((divider / divided) * 100);
- }
-
- }]);
-
-/**
- * @ngdoc filter
- * @name toRadians
- * @kind function
- *
- * @description
- * Convert angle from degrees to radians
- *
- */
-
-angular.module('a8m.math.radians', ['a8m.math'])
-
- .filter('radians', ['$math', function ($math) {
- return function (degrees, decimal) {
- // if decimal is not an integer greater than -1, we cannot do. quit with error "NaN"
- // if degrees is not a real number, we cannot do also. quit with error "NaN"
- if(isNumber(decimal) && isFinite(decimal) && decimal%1===0 && decimal >= 0 &&
- isNumber(degrees) && isFinite(degrees)) {
- var radians = (degrees * 3.14159265359) / 180;
- return $math.round(radians * $math.pow(10,decimal)) / ($math.pow(10,decimal));
- } else {
- return "NaN";
- }
- }
-}]);
-
-
-
-/**
- * @ngdoc filter
- * @name Radix
- * @kind function
- *
- * @description
- * converting decimal numbers to different bases(radix)
- */
-
-angular.module('a8m.math.radix', [])
-
- .filter('radix', function () {
-
- return function (input, radix) {
-
- var RANGE = /^[2-9]$|^[1-2]\d$|^3[0-6]$/;
-
- if(!isNumber(input) || !RANGE.test(radix)) {
- return input;
- }
-
- return input.toString(radix).toUpperCase();
-
- }
-
- });
-
-/**
- * @ngdoc filter
- * @name formatBytes
- * @kind function
- *
- * @description
- * Convert number into abbreviations.
- * i.e: K for one thousand, M for Million, B for billion
- * e.g: number of users:235,221, decimal:1 => 235.2 K
- */
-
-angular.module('a8m.math.shortFmt', ['a8m.math'])
-
- .filter('shortFmt', ['$math', function ($math) {
- return function (number, decimal) {
- if(isNumber(decimal) && isFinite(decimal) && decimal%1===0 && decimal >= 0 &&
- isNumber(number) && isFinite(number)){
-
- if(number < 1e3) {
- return number;
- } else if(number < 1e6) {
- return convertToDecimal((number / 1e3), decimal, $math) + ' K';
- } else if(number < 1e9){
- return convertToDecimal((number / 1e6), decimal, $math) + ' M';
- } else {
- return convertToDecimal((number / 1e9), decimal, $math) + ' B';
- }
-
- }else{
- return "NaN";
- }
- }
-}]);
-/**
- * @ngdoc filter
- * @name sum
- * @kind function
- *
- * @description
- * Sum up all values within an array
- *
- */
-
-angular.module('a8m.math.sum', [])
-
- .filter('sum', function () {
- return function (input, initial) {
-
- return (!isArray(input)) ? input :
- input.reduce(function(prev, curr) {
- return prev + curr;
- }, initial || 0);
-
- }
-
- });
-
-/**
- * @ngdoc filter
- * @name endsWith
- * @kind function
- *
- * @description
- * checks whether string ends with the ends parameter.
- */
-
-angular.module('a8m.ends-with', [])
-
- .filter('endsWith', function () {
- return function (input, ends, csensitive) {
-
- var sensitive = csensitive || false,
- position;
-
- if(!isString(input) || isUndefined(ends)) {
- return input;
- }
-
- input = (sensitive) ? input : input.toLowerCase();
- position = input.length - ends.length;
-
- return input.indexOf((sensitive) ? ends : ends.toLowerCase(), position) !== -1;
- }
- });
-
-/**
- * @ngdoc filter
- * @name ltrim
- * @kind function
- *
- * @description
- * Left trim. Similar to trimFilter, but only for left side.
- */
-
-angular.module('a8m.ltrim', [])
-
- .filter('ltrim', function () {
- return function(input, chars) {
-
- var trim = chars || '\\s';
-
- if(!isString(input)) {
- return input;
- }
-
- return input.replace(new RegExp('^' + trim + '+'), '');
- }
- });
-
-/**
- * @ngdoc filter
- * @name repeat
- * @kind function
- *
- * @description
- * Repeats a string n times
- */
-
-angular.module('a8m.repeat', [])
-
- .filter('repeat',[ function () {
- return function (input, n, separator) {
-
- var times = ~~n;
-
- if(!isString(input)) {
- return input;
- }
-
- return (!times) ? input : strRepeat(input, --n, separator || '');
- }
- }]);
-
-/**
- * Repeats a string n times with given separator
- * @param str string to repeat
- * @param n number of times
- * @param sep separator
- * @returns {*}
- */
-function strRepeat(str, n, sep) {
- if(!n) {
- return str;
- }
- return str + sep + strRepeat(str, --n, sep);
-}
-/**
-* @ngdoc filter
-* @name rtrim
-* @kind function
-*
-* @description
-* Right trim. Similar to trimFilter, but only for right side.
-*/
-
-angular.module('a8m.rtrim', [])
-
- .filter('rtrim', function () {
- return function(input, chars) {
-
- var trim = chars || '\\s';
-
- if(!isString(input)) {
- return input;
- }
-
- return input.replace(new RegExp(trim + '+$'), '');
- }
- });
-
-/**
- * @ngdoc filter
- * @name slugify
- * @kind function
- *
- * @description
- * remove spaces from string, replace with "-" or given argument
- */
-
-angular.module('a8m.slugify', [])
-
- .filter('slugify',[ function () {
- return function (input, sub) {
-
- var replace = (isUndefined(sub)) ? '-' : sub;
-
- if(isString(input)) {
- return input.toLowerCase()
- .replace(/\s+/g, replace);
- }
-
- return input;
- }
- }]);
-
-/**
- * @ngdoc filter
- * @name startWith
- * @kind function
- *
- * @description
- * checks whether string starts with the starts parameter.
- */
-
-angular.module('a8m.starts-with', [])
-
- .filter('startsWith', function () {
- return function (input, start, csensitive) {
-
- var sensitive = csensitive || false;
-
- if(!isString(input) || isUndefined(start)) {
- return input;
- }
-
- input = (sensitive) ? input : input.toLowerCase();
-
- return !input.indexOf((sensitive) ? start : start.toLowerCase());
- }
- });
-
-/**
- * @ngdoc filter
- * @name stringular
- * @kind function
- *
- * @description
- * get string with {n} and replace match with enumeration values
- */
-
-angular.module('a8m.stringular', [])
- .filter('stringular', function () {
- return function(input) {
-
- var args = Array.prototype.slice.call(arguments, 1);
-
- return input.replace(/{(\d+)}/g, function (match, number) {
- return isUndefined(args[number]) ? match : args[number];
- });
-
- }
- });
-
-/**
- * @ngdoc filter
- * @name stripTags
- * @kind function
- *
- * @description
- * strip html tags from string
- */
-
-angular.module('a8m.strip-tags', [])
- .filter('stripTags', function () {
- return function(input) {
- if(isString(input)) {
- return input.replace(/<\S[^><]*>/g, '');
- }
- return input;
- }
- });
-
-/**
- * @ngdoc filter
- * @name trim
- * @kind function
- *
- * @description
- * Strip whitespace (or other characters) from the beginning and end of a string
- */
-
-angular.module('a8m.trim', [])
-
- .filter('trim', function () {
- return function(input, chars) {
-
- var trim = chars || '\\s';
-
- if(!isString(input)) {
- return input;
- }
-
- return input.replace(new RegExp('^' + trim + '+|' + trim + '+$', 'g'), '');
- }
- });
-
-/**
- * @ngdoc filter
- * @name truncate
- * @kind function
- *
- * @description
- * truncates a string given a specified length, providing a custom string to denote an omission.
- */
-
-angular.module('a8m.truncate', [])
- .filter('truncate', function () {
- return function(input, length, suffix, preserve) {
-
- length = isUndefined(length) ? input.length : length;
- preserve = preserve || false;
- suffix = suffix || '';
-
- if(!isString(input) || (input.length <= length)) return input;
-
- return input.substring(0, (preserve) ?
- ((input.indexOf(' ', length) === -1) ? input.length : input.indexOf(' ', length)) :
- length) + suffix;
-
- };
- });
-
-/**
- * @ngdoc filter
- * @name ucfirst
- * @kind function
- *
- * @description
- * ucfirst
- *
- */
-
-angular.module('a8m.ucfirst', [])
-
- .filter('ucfirst', [function() {
- return function(input) {
- return angular.isString(input) ? input.split(' ')
- .map(function (char) {
- return char.charAt(0).toUpperCase() + char.substring(1);
- }).join(' ') : input;
- }
-
- }]);
-
-/**
- * @ngdoc filter
- * @name uriComponentEncode
- * @kind function
- *
- * @description
- * get string as parameter and return encoded string
- */
-
-angular.module('a8m.uri-component-encode', [])
-
- .filter('uriComponentEncode',['$window', function ($window) {
- return function (input) {
-
- if(isString(input)) {
- return $window.encodeURIComponent(input);
- }
-
- return input;
- }
- }]);
-
-/**
- * @ngdoc filter
- * @name uriEncode
- * @kind function
- *
- * @description
- * get string as parameter and return encoded string
- */
-
-angular.module('a8m.uri-encode', [])
-
- .filter('uriEncode',['$window', function ($window) {
- return function (input) {
-
- if(isString(input)) {
- return $window.encodeURI(input);
- }
-
- return input;
- }
- }]);
-
-/**
- * @ngdoc filter
- * @name wrap
- * @kind function
- *
- * @description
- * Wrap a string with another string
- */
-
-angular.module('a8m.wrap', [])
-
- .filter('wrap', function () {
- return function(input, wrap, ends) {
-
- if(!isString(input) || isUndefined(wrap)) {
- return input;
- }
-
- return [wrap, input, ends || wrap].join('');
-
- }
- });
-
-/**
- * @ngdoc provider
- * @name filterWatcher
- * @kind function
- *
- * @description
- * store specific filters result in $$cache, based on scope life time(avoid memory leak).
- * on scope.$destroy remove it's cache from $$cache container
- */
-
-angular.module('a8m.filter-watcher', [])
- .provider('filterWatcher', function() {
-
- this.$get = ['$window', '$rootScope', function($window, $rootScope) {
-
- /**
- * Cache storing
- * @type {Object}
- */
- var $$cache = {};
-
- /**
- * Scope listeners container
- * scope.$destroy => remove all cache keys
- * bind to current scope.
- * @type {Object}
- */
- var $$listeners = {};
-
- /**
- * $timeout without triggering the digest cycle
- * @type {function}
- */
- var $$timeout = $window.setTimeout;
-
- /**
- * @description
- * get `HashKey` string based on the given arguments.
- * @param fName
- * @param args
- * @returns {string}
- */
- function getHashKey(fName, args) {
- return [fName, JSON.stringify(args)]
- .join('#')
- .replace(/"/g,'');
- }
-
- /**
- * @description
- * fir on $scope.$destroy,
- * remove cache based scope from `$$cache`,
- * and remove itself from `$$listeners`
- * @param event
- */
- function removeCache(event) {
- var id = event.targetScope.$id;
- forEach($$listeners[id], function(key) {
- delete $$cache[key];
- });
- delete $$listeners[id];
- }
-
- /**
- * @description
- * for templates version that greater than v.1.3.0
- * if clear cache when the digest cycle end.
- */
- function cleanStateless() {
- $$timeout(function() {
- if(!$rootScope.$$phase)
- $$cache = {};
- });
- }
-
- /**
- * @description
- * Store hashKeys in $$listeners container
- * on scope.$destroy, remove them all(bind an event).
- * @param scope
- * @param hashKey
- * @returns {*}
- */
- function addListener(scope, hashKey) {
- var id = scope.$id;
- if(isUndefined($$listeners[id])) {
- scope.$on('$destroy', removeCache);
- $$listeners[id] = [];
- }
- return $$listeners[id].push(hashKey);
- }
-
- /**
- * @description
- * return the `cacheKey` or undefined.
- * @param filterName
- * @param args
- * @returns {*}
- */
- function $$isMemoized(filterName, args) {
- var hashKey = getHashKey(filterName, args);
- return $$cache[hashKey];
- }
-
- /**
- * @description
- * store `result` in `$$cache` container, based on the hashKey.
- * add $destroy listener and return result
- * @param filterName
- * @param args
- * @param scope
- * @param result
- * @returns {*}
- */
- function $$memoize(filterName, args, scope, result) {
- var hashKey = getHashKey(filterName, args);
- //store result in `$$cache` container
- $$cache[hashKey] = result;
- // for templates versions that less than 1.3
- // add to `$destroy` listener, a cleaner callback
- if(isScope(scope)) {
- addListener(scope, hashKey);
- } else {
- cleanStateless();
- }
- return result;
- }
-
- return {
- isMemoized: $$isMemoized,
- memoize: $$memoize
- }
-
- }];
- });
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-/**
- * @ngdoc module
- * @name templates.filters
- * @description
- * Bunch of useful filters for angularJS
- */
-
-angular.module('angular.filter', [
-
- 'a8m.ucfirst',
- 'a8m.uri-encode',
- 'a8m.uri-component-encode',
- 'a8m.slugify',
- 'a8m.strip-tags',
- 'a8m.stringular',
- 'a8m.truncate',
- 'a8m.starts-with',
- 'a8m.ends-with',
- 'a8m.wrap',
- 'a8m.trim',
- 'a8m.ltrim',
- 'a8m.rtrim',
- 'a8m.repeat',
-
- 'a8m.to-array',
- 'a8m.concat',
- 'a8m.contains',
- 'a8m.unique',
- 'a8m.is-empty',
- 'a8m.after',
- 'a8m.after-where',
- 'a8m.before',
- 'a8m.before-where',
- 'a8m.defaults',
- 'a8m.where',
- 'a8m.reverse',
- 'a8m.remove',
- 'a8m.remove-with',
- 'a8m.group-by',
- 'a8m.count-by',
- 'a8m.search-field',
- 'a8m.fuzzy-by',
- 'a8m.fuzzy',
- 'a8m.omit',
- 'a8m.pick',
- 'a8m.every',
- 'a8m.filter-by',
- 'a8m.xor',
- 'a8m.map',
- 'a8m.first',
- 'a8m.last',
- 'a8m.flatten',
-
- 'a8m.math',
- 'a8m.math.max',
- 'a8m.math.min',
- 'a8m.math.percent',
- 'a8m.math.radix',
- 'a8m.math.sum',
- 'a8m.math.degrees',
- 'a8m.math.radians',
- 'a8m.math.byteFmt',
- 'a8m.math.kbFmt',
- 'a8m.math.shortFmt',
-
- 'a8m.angular',
- 'a8m.conditions',
- 'a8m.is-null',
-
- 'a8m.filter-watcher'
-]);
-})( window, window.angular );
\ No newline at end of file
diff --git a/merlin/static/merlin/js/lib/angular-filter.min.js b/merlin/static/merlin/js/lib/angular-filter.min.js
deleted file mode 100644
index 44aa6b2..0000000
--- a/merlin/static/merlin/js/lib/angular-filter.min.js
+++ /dev/null
@@ -1,6 +0,0 @@
-/**
- * Bunch of useful filters for angularJS(with no external dependencies!)
- * @version v0.5.1 - 2014-11-12 * @link https://github.com/a8m/angular-filter
- * @author Ariel Mashraki
- * @license MIT License, http://www.opensource.org/licenses/MIT
- */!function(a,b,c){"use strict";function d(a){return D(a)?a:Object.keys(a).map(function(b){return a[b]})}function e(a){return null===a}function f(a,b){var c=Object.keys(a);return-1==c.map(function(c){return!(!b[c]||b[c]!=a[c])}).indexOf(!1)}function g(a,b){if(""===b)return a;var c=a.indexOf(b.charAt(0));return-1===c?!1:g(a.substr(c+1),b.substr(1))}function h(a,b,c){var d=0;return a.filter(function(a){var e=x(c)?b>d&&c(a):b>d;return d=e?d+1:d,e})}function i(a,b,c){return c.round(a*c.pow(10,b))/c.pow(10,b)}function j(a,b,c){b=b||[];var d=Object.keys(a);return d.forEach(function(d){if(C(a[d])&&!D(a[d])){var e=c?c+"."+d:c;j(a[d],b,e||d)}else{var f=c?c+"."+d:d;b.push(f)}}),b}function k(a){return a&&a.$evalAsync&&a.$watch}function l(){return function(a,b){return a>b}}function m(){return function(a,b){return a>=b}}function n(){return function(a,b){return b>a}}function o(){return function(a,b){return b>=a}}function p(){return function(a,b){return a==b}}function q(){return function(a,b){return a!=b}}function r(){return function(a,b){return a===b}}function s(){return function(a,b){return a!==b}}function t(a){return function(b,c){return b=C(b)?d(b):b,!D(b)||y(c)?!0:b.some(function(b){return C(b)||z(c)?a(c)(b):b===c})}}function u(a,b){return b=b||0,b>=a.length?a:D(a[b])?u(a.slice(0,b).concat(a[b],a.slice(b+1)),b):u(a,b+1)}function v(a){return function(b,c){function e(a,b){return y(b)?!1:a.some(function(a){return H(a,b)})}if(b=C(b)?d(b):b,!D(b))return b;var f=[],g=a(c);return b.filter(y(c)?function(a,b,c){return c.indexOf(a)===b}:function(a){var b=g(a);return e(f,b)?!1:(f.push(b),!0)})}}function w(a,b,c){return b?a+c+w(a,--b,c):a}var x=b.isDefined,y=b.isUndefined,z=b.isFunction,A=b.isString,B=b.isNumber,C=b.isObject,D=b.isArray,E=b.forEach,F=b.extend,G=b.copy,H=b.equals;String.prototype.contains||(String.prototype.contains=function(){return-1!==String.prototype.indexOf.apply(this,arguments)}),b.module("a8m.angular",[]).filter("isUndefined",function(){return function(a){return b.isUndefined(a)}}).filter("isDefined",function(){return function(a){return b.isDefined(a)}}).filter("isFunction",function(){return function(a){return b.isFunction(a)}}).filter("isString",function(){return function(a){return b.isString(a)}}).filter("isNumber",function(){return function(a){return b.isNumber(a)}}).filter("isArray",function(){return function(a){return b.isArray(a)}}).filter("isObject",function(){return function(a){return b.isObject(a)}}).filter("isEqual",function(){return function(a,c){return b.equals(a,c)}}),b.module("a8m.conditions",[]).filter({isGreaterThan:l,">":l,isGreaterThanOrEqualTo:m,">=":m,isLessThan:n,"<":n,isLessThanOrEqualTo:o,"<=":o,isEqualTo:p,"==":p,isNotEqualTo:q,"!=":q,isIdenticalTo:r,"===":r,isNotIdenticalTo:s,"!==":s}),b.module("a8m.is-null",[]).filter("isNull",function(){return function(a){return e(a)}}),b.module("a8m.after-where",[]).filter("afterWhere",function(){return function(a,b){if(a=C(a)?d(a):a,!D(a)||y(b))return a;var c=a.map(function(a){return f(b,a)}).indexOf(!0);return a.slice(-1===c?0:c)}}),b.module("a8m.after",[]).filter("after",function(){return function(a,b){return a=C(a)?d(a):a,D(a)?a.slice(b):a}}),b.module("a8m.before-where",[]).filter("beforeWhere",function(){return function(a,b){if(a=C(a)?d(a):a,!D(a)||y(b))return a;var c=a.map(function(a){return f(b,a)}).indexOf(!0);return a.slice(0,-1===c?a.length:++c)}}),b.module("a8m.before",[]).filter("before",function(){return function(a,b){return a=C(a)?d(a):a,D(a)?a.slice(0,b?--b:b):a}}),b.module("a8m.concat",[]).filter("concat",[function(){return function(a,b){if(y(b))return a;if(D(a))return a.concat(C(b)?d(b):b);if(C(a)){var c=d(a);return c.concat(C(b)?d(b):b)}return a}}]),b.module("a8m.contains",[]).filter({contains:["$parse",t],some:["$parse",t]}),b.module("a8m.count-by",[]).filter("countBy",["$parse",function(a){return function(b,c){var e,f={},g=a(c);return b=C(b)?d(b):b,!D(b)||y(c)?b:(b.forEach(function(a){e=g(a),f[e]||(f[e]=0),f[e]++}),f)}}]),b.module("a8m.defaults",[]).filter("defaults",["$parse",function(a){return function(b,c){if(b=C(b)?d(b):b,!D(b)||!C(c))return b;var e=j(c);return b.forEach(function(b){e.forEach(function(d){var e=a(d),f=e.assign;y(e(b))&&f(b,e(c))})}),b}}]),b.module("a8m.every",[]).filter("every",["$parse",function(a){return function(b,c){return b=C(b)?d(b):b,!D(b)||y(c)?!0:b.every(function(b){return C(b)||z(c)?a(c)(b):b===c})}}]),b.module("a8m.filter-by",[]).filter("filterBy",["$parse",function(a){return function(b,e,f){var g;return f=A(f)||B(f)?String(f).toLowerCase():c,b=C(b)?d(b):b,!D(b)||y(f)?b:b.filter(function(b){return e.some(function(c){if(~c.indexOf("+")){var d=c.replace(new RegExp("\\s","g"),"").split("+");g=d.reduce(function(c,d,e){return 1===e?a(c)(b)+" "+a(d)(b):c+" "+a(d)(b)})}else g=a(c)(b);return A(g)||B(g)?String(g).toLowerCase().contains(f):!1})})}}]),b.module("a8m.first",[]).filter("first",["$parse",function(a){return function(b){var e,f,g;return b=C(b)?d(b):b,D(b)?(g=Array.prototype.slice.call(arguments,1),e=B(g[0])?g[0]:1,f=B(g[0])?B(g[1])?c:g[1]:g[0],g.length?h(b,e,f?a(f):f):b[0]):b}}]),b.module("a8m.flatten",[]).filter("flatten",function(){return function(a,b){return b=b||!1,a=C(a)?d(a):a,D(a)?b?[].concat.apply([],a):u(a,0):a}}),b.module("a8m.fuzzy-by",[]).filter("fuzzyBy",["$parse",function(a){return function(b,c,e,f){var h,i,j=f||!1;return b=C(b)?d(b):b,!D(b)||y(c)||y(e)?b:(i=a(c),b.filter(function(a){return h=i(a),A(h)?(h=j?h:h.toLowerCase(),e=j?e:e.toLowerCase(),g(h,e)!==!1):!1}))}}]),b.module("a8m.fuzzy",[]).filter("fuzzy",function(){return function(a,b,c){function e(a,b){var c,d,e=Object.keys(a);return 0=0&&B(b)&&isFinite(b)?1024>b?i(b,c,a)+" B":1048576>b?i(b/1024,c,a)+" KB":1073741824>b?i(b/1048576,c,a)+" MB":i(b/1073741824,c,a)+" GB":"NaN"}}]),b.module("a8m.math.degrees",["a8m.math"]).filter("degrees",["$math",function(a){return function(b,c){if(B(c)&&isFinite(c)&&c%1===0&&c>=0&&B(b)&&isFinite(b)){var d=180*b/a.PI;return a.round(d*a.pow(10,c))/a.pow(10,c)}return"NaN"}}]),b.module("a8m.math.kbFmt",["a8m.math"]).filter("kbFmt",["$math",function(a){return function(b,c){return B(c)&&isFinite(c)&&c%1===0&&c>=0&&B(b)&&isFinite(b)?1024>b?i(b,c,a)+" KB":1048576>b?i(b/1024,c,a)+" MB":i(b/1048576,c,a)+" GB":"NaN"}}]),b.module("a8m.math",[]).factory("$math",["$window",function(a){return a.Math}]),b.module("a8m.math.max",["a8m.math"]).filter("max",["$math","$parse",function(a,b){function c(c,d){var e=c.map(function(a){return b(d)(a)});return e.indexOf(a.max.apply(a,e))}return function(b,d){return D(b)?y(d)?a.max.apply(a,b):b[c(b,d)]:b}}]),b.module("a8m.math.min",["a8m.math"]).filter("min",["$math","$parse",function(a,b){function c(c,d){var e=c.map(function(a){return b(d)(a)});return e.indexOf(a.min.apply(a,e))}return function(b,d){return D(b)?y(d)?a.min.apply(a,b):b[c(b,d)]:b}}]),b.module("a8m.math.percent",["a8m.math"]).filter("percent",["$math","$window",function(a,b){return function(c,d,e){var f=A(c)?b.Number(c):c;return d=d||100,e=e||!1,!B(f)||b.isNaN(f)?c:e?a.round(f/d*100):f/d*100}}]),b.module("a8m.math.radians",["a8m.math"]).filter("radians",["$math",function(a){return function(b,c){if(B(c)&&isFinite(c)&&c%1===0&&c>=0&&B(b)&&isFinite(b)){var d=3.14159265359*b/180;return a.round(d*a.pow(10,c))/a.pow(10,c)}return"NaN"}}]),b.module("a8m.math.radix",[]).filter("radix",function(){return function(a,b){var c=/^[2-9]$|^[1-2]\d$|^3[0-6]$/;return B(a)&&c.test(b)?a.toString(b).toUpperCase():a}}),b.module("a8m.math.shortFmt",["a8m.math"]).filter("shortFmt",["$math",function(a){return function(b,c){return B(c)&&isFinite(c)&&c%1===0&&c>=0&&B(b)&&isFinite(b)?1e3>b?b:1e6>b?i(b/1e3,c,a)+" K":1e9>b?i(b/1e6,c,a)+" M":i(b/1e9,c,a)+" B":"NaN"}}]),b.module("a8m.math.sum",[]).filter("sum",function(){return function(a,b){return D(a)?a.reduce(function(a,b){return a+b},b||0):a}}),b.module("a8m.ends-with",[]).filter("endsWith",function(){return function(a,b,c){var d,e=c||!1;return!A(a)||y(b)?a:(a=e?a:a.toLowerCase(),d=a.length-b.length,-1!==a.indexOf(e?b:b.toLowerCase(),d))}}),b.module("a8m.ltrim",[]).filter("ltrim",function(){return function(a,b){var c=b||"\\s";return A(a)?a.replace(new RegExp("^"+c+"+"),""):a}}),b.module("a8m.repeat",[]).filter("repeat",[function(){return function(a,b,c){var d=~~b;return A(a)&&d?w(a,--b,c||""):a}}]),b.module("a8m.rtrim",[]).filter("rtrim",function(){return function(a,b){var c=b||"\\s";return A(a)?a.replace(new RegExp(c+"+$"),""):a}}),b.module("a8m.slugify",[]).filter("slugify",[function(){return function(a,b){var c=y(b)?"-":b;return A(a)?a.toLowerCase().replace(/\s+/g,c):a}}]),b.module("a8m.starts-with",[]).filter("startsWith",function(){return function(a,b,c){var d=c||!1;return!A(a)||y(b)?a:(a=d?a:a.toLowerCase(),!a.indexOf(d?b:b.toLowerCase()))}}),b.module("a8m.stringular",[]).filter("stringular",function(){return function(a){var b=Array.prototype.slice.call(arguments,1);return a.replace(/{(\d+)}/g,function(a,c){return y(b[c])?a:b[c]})}}),b.module("a8m.strip-tags",[]).filter("stripTags",function(){return function(a){return A(a)?a.replace(/<\S[^><]*>/g,""):a}}),b.module("a8m.trim",[]).filter("trim",function(){return function(a,b){var c=b||"\\s";return A(a)?a.replace(new RegExp("^"+c+"+|"+c+"+$","g"),""):a}}),b.module("a8m.truncate",[]).filter("truncate",function(){return function(a,b,c,d){return b=y(b)?a.length:b,d=d||!1,c=c||"",!A(a)||a.length<=b?a:a.substring(0,d?-1===a.indexOf(" ",b)?a.length:a.indexOf(" ",b):b)+c}}),b.module("a8m.ucfirst",[]).filter("ucfirst",[function(){return function(a){return b.isString(a)?a.split(" ").map(function(a){return a.charAt(0).toUpperCase()+a.substring(1)}).join(" "):a}}]),b.module("a8m.uri-component-encode",[]).filter("uriComponentEncode",["$window",function(a){return function(b){return A(b)?a.encodeURIComponent(b):b}}]),b.module("a8m.uri-encode",[]).filter("uriEncode",["$window",function(a){return function(b){return A(b)?a.encodeURI(b):b}}]),b.module("a8m.wrap",[]).filter("wrap",function(){return function(a,b,c){return!A(a)||y(b)?a:[b,a,c||b].join("")}}),b.module("a8m.filter-watcher",[]).provider("filterWatcher",function(){this.$get=["$window","$rootScope",function(a,b){function c(a,b){return[a,JSON.stringify(b)].join("#").replace(/"/g,"")}function d(a){var b=a.targetScope.$id;E(j[b],function(a){delete i[a]}),delete j[b]}function e(){l(function(){b.$$phase||(i={})})}function f(a,b){var c=a.$id;return y(j[c])&&(a.$on("$destroy",d),j[c]=[]),j[c].push(b)}function g(a,b){var d=c(a,b);return i[d]}function h(a,b,d,g){var h=c(a,b);return i[h]=g,k(d)?f(d,h):e(),g}var i={},j={},l=a.setTimeout;return{isMemoized:g,memoize:h}}]}),b.module("angular.filter",["a8m.ucfirst","a8m.uri-encode","a8m.uri-component-encode","a8m.slugify","a8m.strip-tags","a8m.stringular","a8m.truncate","a8m.starts-with","a8m.ends-with","a8m.wrap","a8m.trim","a8m.ltrim","a8m.rtrim","a8m.repeat","a8m.to-array","a8m.concat","a8m.contains","a8m.unique","a8m.is-empty","a8m.after","a8m.after-where","a8m.before","a8m.before-where","a8m.defaults","a8m.where","a8m.reverse","a8m.remove","a8m.remove-with","a8m.group-by","a8m.count-by","a8m.search-field","a8m.fuzzy-by","a8m.fuzzy","a8m.omit","a8m.pick","a8m.every","a8m.filter-by","a8m.xor","a8m.map","a8m.first","a8m.last","a8m.flatten","a8m.math","a8m.math.max","a8m.math.min","a8m.math.percent","a8m.math.radix","a8m.math.sum","a8m.math.degrees","a8m.math.radians","a8m.math.byteFmt","a8m.math.kbFmt","a8m.math.shortFmt","a8m.angular","a8m.conditions","a8m.is-null","a8m.filter-watcher"])}(window,window.angular);
\ No newline at end of file
diff --git a/merlin/static/merlin/js/lib/js-yaml.js b/merlin/static/merlin/js/lib/js-yaml.js
deleted file mode 100644
index ca6c84c..0000000
--- a/merlin/static/merlin/js/lib/js-yaml.js
+++ /dev/null
@@ -1,3515 +0,0 @@
-/* js-yaml 3.2.0 https://github.com/nodeca/js-yaml */!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.jsyaml=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o */
-var CHAR_QUESTION = 0x3F; /* ? */
-var CHAR_COMMERCIAL_AT = 0x40; /* @ */
-var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */
-var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */
-var CHAR_GRAVE_ACCENT = 0x60; /* ` */
-var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */
-var CHAR_VERTICAL_LINE = 0x7C; /* | */
-var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */
-
-
-var ESCAPE_SEQUENCES = {};
-
-ESCAPE_SEQUENCES[0x00] = '\\0';
-ESCAPE_SEQUENCES[0x07] = '\\a';
-ESCAPE_SEQUENCES[0x08] = '\\b';
-ESCAPE_SEQUENCES[0x09] = '\\t';
-ESCAPE_SEQUENCES[0x0A] = '\\n';
-ESCAPE_SEQUENCES[0x0B] = '\\v';
-ESCAPE_SEQUENCES[0x0C] = '\\f';
-ESCAPE_SEQUENCES[0x0D] = '\\r';
-ESCAPE_SEQUENCES[0x1B] = '\\e';
-ESCAPE_SEQUENCES[0x22] = '\\"';
-ESCAPE_SEQUENCES[0x5C] = '\\\\';
-ESCAPE_SEQUENCES[0x85] = '\\N';
-ESCAPE_SEQUENCES[0xA0] = '\\_';
-ESCAPE_SEQUENCES[0x2028] = '\\L';
-ESCAPE_SEQUENCES[0x2029] = '\\P';
-
-
-var DEPRECATED_BOOLEANS_SYNTAX = [
- 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON',
- 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'
-];
-
-
-function compileStyleMap(schema, map) {
- var result, keys, index, length, tag, style, type;
-
- if (null === map) {
- return {};
- }
-
- result = {};
- keys = Object.keys(map);
-
- for (index = 0, length = keys.length; index < length; index += 1) {
- tag = keys[index];
- style = String(map[tag]);
-
- if ('!!' === tag.slice(0, 2)) {
- tag = 'tag:yaml.org,2002:' + tag.slice(2);
- }
-
- type = schema.compiledTypeMap[tag];
-
- if (type && _hasOwnProperty.call(type.styleAliases, style)) {
- style = type.styleAliases[style];
- }
-
- result[tag] = style;
- }
-
- return result;
-}
-
-
-function encodeHex(character) {
- var string, handle, length;
-
- string = character.toString(16).toUpperCase();
-
- if (character <= 0xFF) {
- handle = 'x';
- length = 2;
- } else if (character <= 0xFFFF) {
- handle = 'u';
- length = 4;
- } else if (character <= 0xFFFFFFFF) {
- handle = 'U';
- length = 8;
- } else {
- throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF');
- }
-
- return '\\' + handle + common.repeat('0', length - string.length) + string;
-}
-
-
-function State(options) {
- this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
- this.indent = Math.max(1, (options['indent'] || 2));
- this.skipInvalid = options['skipInvalid'] || false;
- this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']);
- this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
-
- this.implicitTypes = this.schema.compiledImplicit;
- this.explicitTypes = this.schema.compiledExplicit;
-
- this.tag = null;
- this.result = '';
-}
-
-
-function generateNextLine(state, level) {
- return '\n' + common.repeat(' ', state.indent * level);
-}
-
-function testImplicitResolving(state, str) {
- var index, length, type;
-
- for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
- type = state.implicitTypes[index];
-
- if (type.resolve(str)) {
- return true;
- }
- }
-
- return false;
-}
-
-function writeScalar(state, object) {
- var isQuoted, checkpoint, position, length, character, first;
-
- state.dump = '';
- isQuoted = false;
- checkpoint = 0;
- first = object.charCodeAt(0) || 0;
-
- if (-1 !== DEPRECATED_BOOLEANS_SYNTAX.indexOf(object)) {
- // Ensure compatibility with YAML 1.0/1.1 loaders.
- isQuoted = true;
- } else if (0 === object.length) {
- // Quote empty string
- isQuoted = true;
- } else if (CHAR_SPACE === first ||
- CHAR_SPACE === object.charCodeAt(object.length - 1)) {
- isQuoted = true;
- } else if (CHAR_MINUS === first ||
- CHAR_QUESTION === first) {
- // Don't check second symbol for simplicity
- isQuoted = true;
- }
-
- for (position = 0, length = object.length; position < length; position += 1) {
- character = object.charCodeAt(position);
-
- if (!isQuoted) {
- if (CHAR_TAB === character ||
- CHAR_LINE_FEED === character ||
- CHAR_CARRIAGE_RETURN === character ||
- CHAR_COMMA === character ||
- CHAR_LEFT_SQUARE_BRACKET === character ||
- CHAR_RIGHT_SQUARE_BRACKET === character ||
- CHAR_LEFT_CURLY_BRACKET === character ||
- CHAR_RIGHT_CURLY_BRACKET === character ||
- CHAR_SHARP === character ||
- CHAR_AMPERSAND === character ||
- CHAR_ASTERISK === character ||
- CHAR_EXCLAMATION === character ||
- CHAR_VERTICAL_LINE === character ||
- CHAR_GREATER_THAN === character ||
- CHAR_SINGLE_QUOTE === character ||
- CHAR_DOUBLE_QUOTE === character ||
- CHAR_PERCENT === character ||
- CHAR_COMMERCIAL_AT === character ||
- CHAR_COLON === character ||
- CHAR_GRAVE_ACCENT === character) {
- isQuoted = true;
- }
- }
-
- if (ESCAPE_SEQUENCES[character] ||
- !((0x00020 <= character && character <= 0x00007E) ||
- (0x00085 === character) ||
- (0x000A0 <= character && character <= 0x00D7FF) ||
- (0x0E000 <= character && character <= 0x00FFFD) ||
- (0x10000 <= character && character <= 0x10FFFF))) {
- state.dump += object.slice(checkpoint, position);
- state.dump += ESCAPE_SEQUENCES[character] || encodeHex(character);
- checkpoint = position + 1;
- isQuoted = true;
- }
- }
-
- if (checkpoint < position) {
- state.dump += object.slice(checkpoint, position);
- }
-
- if (!isQuoted && testImplicitResolving(state, state.dump)) {
- isQuoted = true;
- }
-
- if (isQuoted) {
- state.dump = '"' + state.dump + '"';
- }
-}
-
-function writeFlowSequence(state, level, object) {
- var _result = '',
- _tag = state.tag,
- index,
- length;
-
- for (index = 0, length = object.length; index < length; index += 1) {
- // Write only valid elements.
- if (writeNode(state, level, object[index], false, false)) {
- if (0 !== index) {
- _result += ', ';
- }
- _result += state.dump;
- }
- }
-
- state.tag = _tag;
- state.dump = '[' + _result + ']';
-}
-
-function writeBlockSequence(state, level, object, compact) {
- var _result = '',
- _tag = state.tag,
- index,
- length;
-
- for (index = 0, length = object.length; index < length; index += 1) {
- // Write only valid elements.
- if (writeNode(state, level + 1, object[index], true, true)) {
- if (!compact || 0 !== index) {
- _result += generateNextLine(state, level);
- }
- _result += '- ' + state.dump;
- }
- }
-
- state.tag = _tag;
- state.dump = _result || '[]'; // Empty sequence if no valid values.
-}
-
-function writeFlowMapping(state, level, object) {
- var _result = '',
- _tag = state.tag,
- objectKeyList = Object.keys(object),
- index,
- length,
- objectKey,
- objectValue,
- pairBuffer;
-
- for (index = 0, length = objectKeyList.length; index < length; index += 1) {
- pairBuffer = '';
-
- if (0 !== index) {
- pairBuffer += ', ';
- }
-
- objectKey = objectKeyList[index];
- objectValue = object[objectKey];
-
- if (!writeNode(state, level, objectKey, false, false)) {
- continue; // Skip this pair because of invalid key;
- }
-
- if (state.dump.length > 1024) {
- pairBuffer += '? ';
- }
-
- pairBuffer += state.dump + ': ';
-
- if (!writeNode(state, level, objectValue, false, false)) {
- continue; // Skip this pair because of invalid value.
- }
-
- pairBuffer += state.dump;
-
- // Both key and value are valid.
- _result += pairBuffer;
- }
-
- state.tag = _tag;
- state.dump = '{' + _result + '}';
-}
-
-function writeBlockMapping(state, level, object, compact) {
- var _result = '',
- _tag = state.tag,
- objectKeyList = Object.keys(object),
- index,
- length,
- objectKey,
- objectValue,
- explicitPair,
- pairBuffer;
-
- for (index = 0, length = objectKeyList.length; index < length; index += 1) {
- pairBuffer = '';
-
- if (!compact || 0 !== index) {
- pairBuffer += generateNextLine(state, level);
- }
-
- objectKey = objectKeyList[index];
- objectValue = object[objectKey];
-
- if (!writeNode(state, level + 1, objectKey, true, true)) {
- continue; // Skip this pair because of invalid key.
- }
-
- explicitPair = (null !== state.tag && '?' !== state.tag) ||
- (state.dump && state.dump.length > 1024);
-
- if (explicitPair) {
- if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
- pairBuffer += '?';
- } else {
- pairBuffer += '? ';
- }
- }
-
- pairBuffer += state.dump;
-
- if (explicitPair) {
- pairBuffer += generateNextLine(state, level);
- }
-
- if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
- continue; // Skip this pair because of invalid value.
- }
-
- if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
- pairBuffer += ':';
- } else {
- pairBuffer += ': ';
- }
-
- pairBuffer += state.dump;
-
- // Both key and value are valid.
- _result += pairBuffer;
- }
-
- state.tag = _tag;
- state.dump = _result || '{}'; // Empty mapping if no valid pairs.
-}
-
-function detectType(state, object, explicit) {
- var _result, typeList, index, length, type, style;
-
- typeList = explicit ? state.explicitTypes : state.implicitTypes;
-
- for (index = 0, length = typeList.length; index < length; index += 1) {
- type = typeList[index];
-
- if ((type.instanceOf || type.predicate) &&
- (!type.instanceOf || (('object' === typeof object) && (object instanceof type.instanceOf))) &&
- (!type.predicate || type.predicate(object))) {
-
- state.tag = explicit ? type.tag : '?';
-
- if (type.represent) {
- style = state.styleMap[type.tag] || type.defaultStyle;
-
- if ('[object Function]' === _toString.call(type.represent)) {
- _result = type.represent(object, style);
- } else if (_hasOwnProperty.call(type.represent, style)) {
- _result = type.represent[style](object, style);
- } else {
- throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style');
- }
-
- state.dump = _result;
- }
-
- return true;
- }
- }
-
- return false;
-}
-
-// Serializes `object` and writes it to global `result`.
-// Returns true on success, or false on invalid object.
-//
-function writeNode(state, level, object, block, compact) {
- state.tag = null;
- state.dump = object;
-
- if (!detectType(state, object, false)) {
- detectType(state, object, true);
- }
-
- var type = _toString.call(state.dump);
-
- if (block) {
- block = (0 > state.flowLevel || state.flowLevel > level);
- }
-
- if ((null !== state.tag && '?' !== state.tag) || (2 !== state.indent && level > 0)) {
- compact = false;
- }
-
- if ('[object Object]' === type) {
- if (block && (0 !== Object.keys(state.dump).length)) {
- writeBlockMapping(state, level, state.dump, compact);
- } else {
- writeFlowMapping(state, level, state.dump);
- }
- } else if ('[object Array]' === type) {
- if (block && (0 !== state.dump.length)) {
- writeBlockSequence(state, level, state.dump, compact);
- } else {
- writeFlowSequence(state, level, state.dump);
- }
- } else if ('[object String]' === type) {
- if ('?' !== state.tag) {
- writeScalar(state, state.dump);
- }
- } else if (state.skipInvalid) {
- return false;
- } else {
- throw new YAMLException('unacceptable kind of an object to dump ' + type);
- }
-
- if (null !== state.tag && '?' !== state.tag) {
- state.dump = '!<' + state.tag + '> ' + state.dump;
- }
- return true;
-}
-
-
-function dump(input, options) {
- options = options || {};
-
- var state = new State(options);
-
- if (writeNode(state, 0, input, true, true)) {
- return state.dump + '\n';
- } else {
- return '';
- }
-}
-
-
-function safeDump(input, options) {
- return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
-}
-
-
-module.exports.dump = dump;
-module.exports.safeDump = safeDump;
-
-},{"./common":3,"./exception":5,"./schema/default_full":10,"./schema/default_safe":11}],5:[function(_dereq_,module,exports){
-'use strict';
-
-
-function YAMLException(reason, mark) {
- this.name = 'YAMLException';
- this.reason = reason;
- this.mark = mark;
- this.message = this.toString(false);
-}
-
-
-YAMLException.prototype.toString = function toString(compact) {
- var result;
-
- result = 'JS-YAML: ' + (this.reason || '(unknown reason)');
-
- if (!compact && this.mark) {
- result += ' ' + this.mark.toString();
- }
-
- return result;
-};
-
-
-module.exports = YAMLException;
-
-},{}],6:[function(_dereq_,module,exports){
-'use strict';
-
-
-var common = _dereq_('./common');
-var YAMLException = _dereq_('./exception');
-var Mark = _dereq_('./mark');
-var DEFAULT_SAFE_SCHEMA = _dereq_('./schema/default_safe');
-var DEFAULT_FULL_SCHEMA = _dereq_('./schema/default_full');
-
-
-var _hasOwnProperty = Object.prototype.hasOwnProperty;
-
-
-var CONTEXT_FLOW_IN = 1;
-var CONTEXT_FLOW_OUT = 2;
-var CONTEXT_BLOCK_IN = 3;
-var CONTEXT_BLOCK_OUT = 4;
-
-
-var CHOMPING_CLIP = 1;
-var CHOMPING_STRIP = 2;
-var CHOMPING_KEEP = 3;
-
-
-var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uD800-\uDFFF\uFFFE\uFFFF]/;
-var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
-var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
-var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
-var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
-
-
-function is_EOL(c) {
- return (c === 0x0A/* LF */) || (c === 0x0D/* CR */);
-}
-
-function is_WHITE_SPACE(c) {
- return (c === 0x09/* Tab */) || (c === 0x20/* Space */);
-}
-
-function is_WS_OR_EOL(c) {
- return (c === 0x09/* Tab */) ||
- (c === 0x20/* Space */) ||
- (c === 0x0A/* LF */) ||
- (c === 0x0D/* CR */);
-}
-
-function is_FLOW_INDICATOR(c) {
- return 0x2C/* , */ === c ||
- 0x5B/* [ */ === c ||
- 0x5D/* ] */ === c ||
- 0x7B/* { */ === c ||
- 0x7D/* } */ === c;
-}
-
-function fromHexCode(c) {
- var lc;
-
- if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
- return c - 0x30;
- }
-
- lc = c | 0x20;
- if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) {
- return lc - 0x61 + 10;
- }
-
- return -1;
-}
-
-function escapedHexLen(c) {
- if (c === 0x78/* x */) { return 2; }
- if (c === 0x75/* u */) { return 4; }
- if (c === 0x55/* U */) { return 8; }
- return 0;
-}
-
-function fromDecimalCode(c) {
- if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
- return c - 0x30;
- }
-
- return -1;
-}
-
-function simpleEscapeSequence(c) {
- return (c === 0x30/* 0 */) ? '\x00' :
- (c === 0x61/* a */) ? '\x07' :
- (c === 0x62/* b */) ? '\x08' :
- (c === 0x74/* t */) ? '\x09' :
- (c === 0x09/* Tab */) ? '\x09' :
- (c === 0x6E/* n */) ? '\x0A' :
- (c === 0x76/* v */) ? '\x0B' :
- (c === 0x66/* f */) ? '\x0C' :
- (c === 0x72/* r */) ? '\x0D' :
- (c === 0x65/* e */) ? '\x1B' :
- (c === 0x20/* Space */) ? ' ' :
- (c === 0x22/* " */) ? '\x22' :
- (c === 0x2F/* / */) ? '/' :
- (c === 0x5C/* \ */) ? '\x5C' :
- (c === 0x4E/* N */) ? '\x85' :
- (c === 0x5F/* _ */) ? '\xA0' :
- (c === 0x4C/* L */) ? '\u2028' :
- (c === 0x50/* P */) ? '\u2029' : '';
-}
-
-var simpleEscapeCheck = new Array(256); // integer, for fast access
-var simpleEscapeMap = new Array(256);
-for (var i = 0; i < 256; i++) {
- simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
- simpleEscapeMap[i] = simpleEscapeSequence(i);
-}
-
-
-function State(input, options) {
- this.input = input;
-
- this.filename = options['filename'] || null;
- this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
- this.onWarning = options['onWarning'] || null;
- this.legacy = options['legacy'] || false;
-
- this.implicitTypes = this.schema.compiledImplicit;
- this.typeMap = this.schema.compiledTypeMap;
-
- this.length = input.length;
- this.position = 0;
- this.line = 0;
- this.lineStart = 0;
- this.lineIndent = 0;
-
- this.documents = [];
-
- /*
- this.version;
- this.checkLineBreaks;
- this.tagMap;
- this.anchorMap;
- this.tag;
- this.anchor;
- this.kind;
- this.result;*/
-
-}
-
-
-function generateError(state, message) {
- return new YAMLException(
- message,
- new Mark(state.filename, state.input, state.position, state.line, (state.position - state.lineStart)));
-}
-
-function throwError(state, message) {
- throw generateError(state, message);
-}
-
-function throwWarning(state, message) {
- var error = generateError(state, message);
-
- if (state.onWarning) {
- state.onWarning.call(null, error);
- } else {
- throw error;
- }
-}
-
-
-var directiveHandlers = {
-
- 'YAML': function handleYamlDirective(state, name, args) {
-
- var match, major, minor;
-
- if (null !== state.version) {
- throwError(state, 'duplication of %YAML directive');
- }
-
- if (1 !== args.length) {
- throwError(state, 'YAML directive accepts exactly one argument');
- }
-
- match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
-
- if (null === match) {
- throwError(state, 'ill-formed argument of the YAML directive');
- }
-
- major = parseInt(match[1], 10);
- minor = parseInt(match[2], 10);
-
- if (1 !== major) {
- throwError(state, 'unacceptable YAML version of the document');
- }
-
- state.version = args[0];
- state.checkLineBreaks = (minor < 2);
-
- if (1 !== minor && 2 !== minor) {
- throwWarning(state, 'unsupported YAML version of the document');
- }
- },
-
- 'TAG': function handleTagDirective(state, name, args) {
-
- var handle, prefix;
-
- if (2 !== args.length) {
- throwError(state, 'TAG directive accepts exactly two arguments');
- }
-
- handle = args[0];
- prefix = args[1];
-
- if (!PATTERN_TAG_HANDLE.test(handle)) {
- throwError(state, 'ill-formed tag handle (first argument) of the TAG directive');
- }
-
- if (_hasOwnProperty.call(state.tagMap, handle)) {
- throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
- }
-
- if (!PATTERN_TAG_URI.test(prefix)) {
- throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive');
- }
-
- state.tagMap[handle] = prefix;
- }
-};
-
-
-function captureSegment(state, start, end, checkJson) {
- var _position, _length, _character, _result;
-
- if (start < end) {
- _result = state.input.slice(start, end);
-
- if (checkJson) {
- for (_position = 0, _length = _result.length;
- _position < _length;
- _position += 1) {
- _character = _result.charCodeAt(_position);
- if (!(0x09 === _character ||
- 0x20 <= _character && _character <= 0x10FFFF)) {
- throwError(state, 'expected valid JSON character');
- }
- }
- }
-
- state.result += _result;
- }
-}
-
-function mergeMappings(state, destination, source) {
- var sourceKeys, key, index, quantity;
-
- if (!common.isObject(source)) {
- throwError(state, 'cannot merge mappings; the provided source object is unacceptable');
- }
-
- sourceKeys = Object.keys(source);
-
- for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
- key = sourceKeys[index];
-
- if (!_hasOwnProperty.call(destination, key)) {
- destination[key] = source[key];
- }
- }
-}
-
-function storeMappingPair(state, _result, keyTag, keyNode, valueNode) {
- var index, quantity;
-
- keyNode = String(keyNode);
-
- if (null === _result) {
- _result = {};
- }
-
- if ('tag:yaml.org,2002:merge' === keyTag) {
- if (Array.isArray(valueNode)) {
- for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
- mergeMappings(state, _result, valueNode[index]);
- }
- } else {
- mergeMappings(state, _result, valueNode);
- }
- } else {
- _result[keyNode] = valueNode;
- }
-
- return _result;
-}
-
-function readLineBreak(state) {
- var ch;
-
- ch = state.input.charCodeAt(state.position);
-
- if (0x0A/* LF */ === ch) {
- state.position++;
- } else if (0x0D/* CR */ === ch) {
- state.position++;
- if (0x0A/* LF */ === state.input.charCodeAt(state.position)) {
- state.position++;
- }
- } else {
- throwError(state, 'a line break is expected');
- }
-
- state.line += 1;
- state.lineStart = state.position;
-}
-
-function skipSeparationSpace(state, allowComments, checkIndent) {
- var lineBreaks = 0,
- ch = state.input.charCodeAt(state.position);
-
- while (0 !== ch) {
- while (is_WHITE_SPACE(ch)) {
- ch = state.input.charCodeAt(++state.position);
- }
-
- if (allowComments && 0x23/* # */ === ch) {
- do {
- ch = state.input.charCodeAt(++state.position);
- } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && 0 !== ch);
- }
-
- if (is_EOL(ch)) {
- readLineBreak(state);
-
- ch = state.input.charCodeAt(state.position);
- lineBreaks++;
- state.lineIndent = 0;
-
- while (0x20/* Space */ === ch) {
- state.lineIndent++;
- ch = state.input.charCodeAt(++state.position);
- }
-
- if (state.lineIndent < checkIndent) {
- throwWarning(state, 'deficient indentation');
- }
- } else {
- break;
- }
- }
-
- return lineBreaks;
-}
-
-function testDocumentSeparator(state) {
- var _position = state.position,
- ch;
-
- ch = state.input.charCodeAt(_position);
-
- // Condition state.position === state.lineStart is tested
- // in parent on each call, for efficiency. No needs to test here again.
- if ((0x2D/* - */ === ch || 0x2E/* . */ === ch) &&
- state.input.charCodeAt(_position + 1) === ch &&
- state.input.charCodeAt(_position+ 2) === ch) {
-
- _position += 3;
-
- ch = state.input.charCodeAt(_position);
-
- if (ch === 0 || is_WS_OR_EOL(ch)) {
- return true;
- }
- }
-
- return false;
-}
-
-function writeFoldedLines(state, count) {
- if (1 === count) {
- state.result += ' ';
- } else if (count > 1) {
- state.result += common.repeat('\n', count - 1);
- }
-}
-
-
-function readPlainScalar(state, nodeIndent, withinFlowCollection) {
- var preceding,
- following,
- captureStart,
- captureEnd,
- hasPendingContent,
- _line,
- _lineStart,
- _lineIndent,
- _kind = state.kind,
- _result = state.result,
- ch;
-
- ch = state.input.charCodeAt(state.position);
-
- if (is_WS_OR_EOL(ch) ||
- is_FLOW_INDICATOR(ch) ||
- 0x23/* # */ === ch ||
- 0x26/* & */ === ch ||
- 0x2A/* * */ === ch ||
- 0x21/* ! */ === ch ||
- 0x7C/* | */ === ch ||
- 0x3E/* > */ === ch ||
- 0x27/* ' */ === ch ||
- 0x22/* " */ === ch ||
- 0x25/* % */ === ch ||
- 0x40/* @ */ === ch ||
- 0x60/* ` */ === ch) {
- return false;
- }
-
- if (0x3F/* ? */ === ch || 0x2D/* - */ === ch) {
- following = state.input.charCodeAt(state.position + 1);
-
- if (is_WS_OR_EOL(following) ||
- withinFlowCollection && is_FLOW_INDICATOR(following)) {
- return false;
- }
- }
-
- state.kind = 'scalar';
- state.result = '';
- captureStart = captureEnd = state.position;
- hasPendingContent = false;
-
- while (0 !== ch) {
- if (0x3A/* : */ === ch) {
- following = state.input.charCodeAt(state.position+1);
-
- if (is_WS_OR_EOL(following) ||
- withinFlowCollection && is_FLOW_INDICATOR(following)) {
- break;
- }
-
- } else if (0x23/* # */ === ch) {
- preceding = state.input.charCodeAt(state.position - 1);
-
- if (is_WS_OR_EOL(preceding)) {
- break;
- }
-
- } else if ((state.position === state.lineStart && testDocumentSeparator(state)) ||
- withinFlowCollection && is_FLOW_INDICATOR(ch)) {
- break;
-
- } else if (is_EOL(ch)) {
- _line = state.line;
- _lineStart = state.lineStart;
- _lineIndent = state.lineIndent;
- skipSeparationSpace(state, false, -1);
-
- if (state.lineIndent >= nodeIndent) {
- hasPendingContent = true;
- ch = state.input.charCodeAt(state.position);
- continue;
- } else {
- state.position = captureEnd;
- state.line = _line;
- state.lineStart = _lineStart;
- state.lineIndent = _lineIndent;
- break;
- }
- }
-
- if (hasPendingContent) {
- captureSegment(state, captureStart, captureEnd, false);
- writeFoldedLines(state, state.line - _line);
- captureStart = captureEnd = state.position;
- hasPendingContent = false;
- }
-
- if (!is_WHITE_SPACE(ch)) {
- captureEnd = state.position + 1;
- }
-
- ch = state.input.charCodeAt(++state.position);
- }
-
- captureSegment(state, captureStart, captureEnd, false);
-
- if (state.result) {
- return true;
- } else {
- state.kind = _kind;
- state.result = _result;
- return false;
- }
-}
-
-function readSingleQuotedScalar(state, nodeIndent) {
- var ch,
- captureStart, captureEnd;
-
- ch = state.input.charCodeAt(state.position);
-
- if (0x27/* ' */ !== ch) {
- return false;
- }
-
- state.kind = 'scalar';
- state.result = '';
- state.position++;
- captureStart = captureEnd = state.position;
-
- while (0 !== (ch = state.input.charCodeAt(state.position))) {
- if (0x27/* ' */ === ch) {
- captureSegment(state, captureStart, state.position, true);
- ch = state.input.charCodeAt(++state.position);
-
- if (0x27/* ' */ === ch) {
- captureStart = captureEnd = state.position;
- state.position++;
- } else {
- return true;
- }
-
- } else if (is_EOL(ch)) {
- captureSegment(state, captureStart, captureEnd, true);
- writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
- captureStart = captureEnd = state.position;
-
- } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
- throwError(state, 'unexpected end of the document within a single quoted scalar');
-
- } else {
- state.position++;
- captureEnd = state.position;
- }
- }
-
- throwError(state, 'unexpected end of the stream within a single quoted scalar');
-}
-
-function readDoubleQuotedScalar(state, nodeIndent) {
- var captureStart,
- captureEnd,
- hexLength,
- hexResult,
- tmp, tmpEsc,
- ch;
-
- ch = state.input.charCodeAt(state.position);
-
- if (0x22/* " */ !== ch) {
- return false;
- }
-
- state.kind = 'scalar';
- state.result = '';
- state.position++;
- captureStart = captureEnd = state.position;
-
- while (0 !== (ch = state.input.charCodeAt(state.position))) {
- if (0x22/* " */ === ch) {
- captureSegment(state, captureStart, state.position, true);
- state.position++;
- return true;
-
- } else if (0x5C/* \ */ === ch) {
- captureSegment(state, captureStart, state.position, true);
- ch = state.input.charCodeAt(++state.position);
-
- if (is_EOL(ch)) {
- skipSeparationSpace(state, false, nodeIndent);
-
- //TODO: rework to inline fn with no type cast?
- } else if (ch < 256 && simpleEscapeCheck[ch]) {
- state.result += simpleEscapeMap[ch];
- state.position++;
-
- } else if ((tmp = escapedHexLen(ch)) > 0) {
- hexLength = tmp;
- hexResult = 0;
-
- for (; hexLength > 0; hexLength--) {
- ch = state.input.charCodeAt(++state.position);
-
- if ((tmp = fromHexCode(ch)) >= 0) {
- hexResult = (hexResult << 4) + tmp;
-
- } else {
- throwError(state, 'expected hexadecimal character');
- }
- }
-
- state.result += String.fromCharCode(hexResult);
- state.position++;
-
- } else {
- throwError(state, 'unknown escape sequence');
- }
-
- captureStart = captureEnd = state.position;
-
- } else if (is_EOL(ch)) {
- captureSegment(state, captureStart, captureEnd, true);
- writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
- captureStart = captureEnd = state.position;
-
- } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
- throwError(state, 'unexpected end of the document within a double quoted scalar');
-
- } else {
- state.position++;
- captureEnd = state.position;
- }
- }
-
- throwError(state, 'unexpected end of the stream within a double quoted scalar');
-}
-
-function readFlowCollection(state, nodeIndent) {
- var readNext = true,
- _line,
- _tag = state.tag,
- _result,
- following,
- terminator,
- isPair,
- isExplicitPair,
- isMapping,
- keyNode,
- keyTag,
- valueNode,
- ch;
-
- ch = state.input.charCodeAt(state.position);
-
- if (ch === 0x5B/* [ */) {
- terminator = 0x5D/* ] */;
- isMapping = false;
- _result = [];
- } else if (ch === 0x7B/* { */) {
- terminator = 0x7D/* } */;
- isMapping = true;
- _result = {};
- } else {
- return false;
- }
-
- if (null !== state.anchor) {
- state.anchorMap[state.anchor] = _result;
- }
-
- ch = state.input.charCodeAt(++state.position);
-
- while (0 !== ch) {
- skipSeparationSpace(state, true, nodeIndent);
-
- ch = state.input.charCodeAt(state.position);
-
- if (ch === terminator) {
- state.position++;
- state.tag = _tag;
- state.kind = isMapping ? 'mapping' : 'sequence';
- state.result = _result;
- return true;
- } else if (!readNext) {
- throwError(state, 'missed comma between flow collection entries');
- }
-
- keyTag = keyNode = valueNode = null;
- isPair = isExplicitPair = false;
-
- if (0x3F/* ? */ === ch) {
- following = state.input.charCodeAt(state.position + 1);
-
- if (is_WS_OR_EOL(following)) {
- isPair = isExplicitPair = true;
- state.position++;
- skipSeparationSpace(state, true, nodeIndent);
- }
- }
-
- _line = state.line;
- composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
- keyTag = state.tag;
- keyNode = state.result;
- skipSeparationSpace(state, true, nodeIndent);
-
- ch = state.input.charCodeAt(state.position);
-
- if ((isExplicitPair || state.line === _line) && 0x3A/* : */ === ch) {
- isPair = true;
- ch = state.input.charCodeAt(++state.position);
- skipSeparationSpace(state, true, nodeIndent);
- composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
- valueNode = state.result;
- }
-
- if (isMapping) {
- storeMappingPair(state, _result, keyTag, keyNode, valueNode);
- } else if (isPair) {
- _result.push(storeMappingPair(state, null, keyTag, keyNode, valueNode));
- } else {
- _result.push(keyNode);
- }
-
- skipSeparationSpace(state, true, nodeIndent);
-
- ch = state.input.charCodeAt(state.position);
-
- if (0x2C/* , */ === ch) {
- readNext = true;
- ch = state.input.charCodeAt(++state.position);
- } else {
- readNext = false;
- }
- }
-
- throwError(state, 'unexpected end of the stream within a flow collection');
-}
-
-function readBlockScalar(state, nodeIndent) {
- var captureStart,
- folding,
- chomping = CHOMPING_CLIP,
- detectedIndent = false,
- textIndent = nodeIndent,
- emptyLines = 0,
- atMoreIndented = false,
- tmp,
- ch;
-
- ch = state.input.charCodeAt(state.position);
-
- if (ch === 0x7C/* | */) {
- folding = false;
- } else if (ch === 0x3E/* > */) {
- folding = true;
- } else {
- return false;
- }
-
- state.kind = 'scalar';
- state.result = '';
-
- while (0 !== ch) {
- ch = state.input.charCodeAt(++state.position);
-
- if (0x2B/* + */ === ch || 0x2D/* - */ === ch) {
- if (CHOMPING_CLIP === chomping) {
- chomping = (0x2B/* + */ === ch) ? CHOMPING_KEEP : CHOMPING_STRIP;
- } else {
- throwError(state, 'repeat of a chomping mode identifier');
- }
-
- } else if ((tmp = fromDecimalCode(ch)) >= 0) {
- if (tmp === 0) {
- throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one');
- } else if (!detectedIndent) {
- textIndent = nodeIndent + tmp - 1;
- detectedIndent = true;
- } else {
- throwError(state, 'repeat of an indentation width identifier');
- }
-
- } else {
- break;
- }
- }
-
- if (is_WHITE_SPACE(ch)) {
- do { ch = state.input.charCodeAt(++state.position); }
- while (is_WHITE_SPACE(ch));
-
- if (0x23/* # */ === ch) {
- do { ch = state.input.charCodeAt(++state.position); }
- while (!is_EOL(ch) && (0 !== ch));
- }
- }
-
- while (0 !== ch) {
- readLineBreak(state);
- state.lineIndent = 0;
-
- ch = state.input.charCodeAt(state.position);
-
- while ((!detectedIndent || state.lineIndent < textIndent) &&
- (0x20/* Space */ === ch)) {
- state.lineIndent++;
- ch = state.input.charCodeAt(++state.position);
- }
-
- if (!detectedIndent && state.lineIndent > textIndent) {
- textIndent = state.lineIndent;
- }
-
- if (is_EOL(ch)) {
- emptyLines++;
- continue;
- }
-
- // End of the scalar.
- if (state.lineIndent < textIndent) {
-
- // Perform the chomping.
- if (chomping === CHOMPING_KEEP) {
- state.result += common.repeat('\n', emptyLines);
- } else if (chomping === CHOMPING_CLIP) {
- if (detectedIndent) { // i.e. only if the scalar is not empty.
- state.result += '\n';
- }
- }
-
- // Break this `while` cycle and go to the funciton's epilogue.
- break;
- }
-
- // Folded style: use fancy rules to handle line breaks.
- if (folding) {
-
- // Lines starting with white space characters (more-indented lines) are not folded.
- if (is_WHITE_SPACE(ch)) {
- atMoreIndented = true;
- state.result += common.repeat('\n', emptyLines + 1);
-
- // End of more-indented block.
- } else if (atMoreIndented) {
- atMoreIndented = false;
- state.result += common.repeat('\n', emptyLines + 1);
-
- // Just one line break - perceive as the same line.
- } else if (0 === emptyLines) {
- if (detectedIndent) { // i.e. only if we have already read some scalar content.
- state.result += ' ';
- }
-
- // Several line breaks - perceive as different lines.
- } else {
- state.result += common.repeat('\n', emptyLines);
- }
-
- // Literal style: just add exact number of line breaks between content lines.
- } else {
-
- // If current line isn't the first one - count line break from the last content line.
- if (detectedIndent) {
- state.result += common.repeat('\n', emptyLines + 1);
-
- // In case of the first content line - count only empty lines.
- } else {
- state.result += common.repeat('\n', emptyLines);
- }
- }
-
- detectedIndent = true;
- emptyLines = 0;
- captureStart = state.position;
-
- do { ch = state.input.charCodeAt(++state.position); }
- while (!is_EOL(ch) && (0 !== ch));
-
- captureSegment(state, captureStart, state.position, false);
-
- ch = state.input.charCodeAt(state.position);
- }
-
- return true;
-}
-
-function readBlockSequence(state, nodeIndent) {
- var _line,
- _tag = state.tag,
- _result = [],
- following,
- detected = false,
- ch;
-
- if (null !== state.anchor) {
- state.anchorMap[state.anchor] = _result;
- }
-
- ch = state.input.charCodeAt(state.position);
-
- while (0 !== ch) {
-
- if (0x2D/* - */ !== ch) {
- break;
- }
-
- following = state.input.charCodeAt(state.position + 1);
-
- if (!is_WS_OR_EOL(following)) {
- break;
- }
-
- detected = true;
- state.position++;
-
- if (skipSeparationSpace(state, true, -1)) {
- if (state.lineIndent <= nodeIndent) {
- _result.push(null);
- ch = state.input.charCodeAt(state.position);
- continue;
- }
- }
-
- _line = state.line;
- composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
- _result.push(state.result);
- skipSeparationSpace(state, true, -1);
-
- ch = state.input.charCodeAt(state.position);
-
- if ((state.line === _line || state.lineIndent > nodeIndent) && (0 !== ch)) {
- throwError(state, 'bad indentation of a sequence entry');
- } else if (state.lineIndent < nodeIndent) {
- break;
- }
- }
-
- if (detected) {
- state.tag = _tag;
- state.kind = 'sequence';
- state.result = _result;
- return true;
- } else {
- return false;
- }
-}
-
-function readBlockMapping(state, nodeIndent, flowIndent) {
- var following,
- allowCompact,
- _line,
- _tag = state.tag,
- _result = {},
- keyTag = null,
- keyNode = null,
- valueNode = null,
- atExplicitKey = false,
- detected = false,
- ch;
-
- if (null !== state.anchor) {
- state.anchorMap[state.anchor] = _result;
- }
-
- ch = state.input.charCodeAt(state.position);
-
- while (0 !== ch) {
- following = state.input.charCodeAt(state.position + 1);
- _line = state.line; // Save the current line.
-
- //
- // Explicit notation case. There are two separate blocks:
- // first for the key (denoted by "?") and second for the value (denoted by ":")
- //
- if ((0x3F/* ? */ === ch || 0x3A/* : */ === ch) && is_WS_OR_EOL(following)) {
-
- if (0x3F/* ? */ === ch) {
- if (atExplicitKey) {
- storeMappingPair(state, _result, keyTag, keyNode, null);
- keyTag = keyNode = valueNode = null;
- }
-
- detected = true;
- atExplicitKey = true;
- allowCompact = true;
-
- } else if (atExplicitKey) {
- // i.e. 0x3A/* : */ === character after the explicit key.
- atExplicitKey = false;
- allowCompact = true;
-
- } else {
- throwError(state, 'incomplete explicit mapping pair; a key node is missed');
- }
-
- state.position += 1;
- ch = following;
-
- //
- // Implicit notation case. Flow-style node as the key first, then ":", and the value.
- //
- } else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
-
- if (state.line === _line) {
- ch = state.input.charCodeAt(state.position);
-
- while (is_WHITE_SPACE(ch)) {
- ch = state.input.charCodeAt(++state.position);
- }
-
- if (0x3A/* : */ === ch) {
- ch = state.input.charCodeAt(++state.position);
-
- if (!is_WS_OR_EOL(ch)) {
- throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping');
- }
-
- if (atExplicitKey) {
- storeMappingPair(state, _result, keyTag, keyNode, null);
- keyTag = keyNode = valueNode = null;
- }
-
- detected = true;
- atExplicitKey = false;
- allowCompact = false;
- keyTag = state.tag;
- keyNode = state.result;
-
- } else if (detected) {
- throwError(state, 'can not read an implicit mapping pair; a colon is missed');
-
- } else {
- state.tag = _tag;
- return true; // Keep the result of `composeNode`.
- }
-
- } else if (detected) {
- throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key');
-
- } else {
- state.tag = _tag;
- return true; // Keep the result of `composeNode`.
- }
-
- } else {
- break; // Reading is done. Go to the epilogue.
- }
-
- //
- // Common reading code for both explicit and implicit notations.
- //
- if (state.line === _line || state.lineIndent > nodeIndent) {
- if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
- if (atExplicitKey) {
- keyNode = state.result;
- } else {
- valueNode = state.result;
- }
- }
-
- if (!atExplicitKey) {
- storeMappingPair(state, _result, keyTag, keyNode, valueNode);
- keyTag = keyNode = valueNode = null;
- }
-
- skipSeparationSpace(state, true, -1);
- ch = state.input.charCodeAt(state.position);
- }
-
- if (state.lineIndent > nodeIndent && (0 !== ch)) {
- throwError(state, 'bad indentation of a mapping entry');
- } else if (state.lineIndent < nodeIndent) {
- break;
- }
- }
-
- //
- // Epilogue.
- //
-
- // Special case: last mapping's node contains only the key in explicit notation.
- if (atExplicitKey) {
- storeMappingPair(state, _result, keyTag, keyNode, null);
- }
-
- // Expose the resulting mapping.
- if (detected) {
- state.tag = _tag;
- state.kind = 'mapping';
- state.result = _result;
- }
-
- return detected;
-}
-
-function readTagProperty(state) {
- var _position,
- isVerbatim = false,
- isNamed = false,
- tagHandle,
- tagName,
- ch;
-
- ch = state.input.charCodeAt(state.position);
-
- if (0x21/* ! */ !== ch) {
- return false;
- }
-
- if (null !== state.tag) {
- throwError(state, 'duplication of a tag property');
- }
-
- ch = state.input.charCodeAt(++state.position);
-
- if (0x3C/* < */ === ch) {
- isVerbatim = true;
- ch = state.input.charCodeAt(++state.position);
-
- } else if (0x21/* ! */ === ch) {
- isNamed = true;
- tagHandle = '!!';
- ch = state.input.charCodeAt(++state.position);
-
- } else {
- tagHandle = '!';
- }
-
- _position = state.position;
-
- if (isVerbatim) {
- do { ch = state.input.charCodeAt(++state.position); }
- while (0 !== ch && 0x3E/* > */ !== ch);
-
- if (state.position < state.length) {
- tagName = state.input.slice(_position, state.position);
- ch = state.input.charCodeAt(++state.position);
- } else {
- throwError(state, 'unexpected end of the stream within a verbatim tag');
- }
- } else {
- while (0 !== ch && !is_WS_OR_EOL(ch)) {
-
- if (0x21/* ! */ === ch) {
- if (!isNamed) {
- tagHandle = state.input.slice(_position - 1, state.position + 1);
-
- if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
- throwError(state, 'named tag handle cannot contain such characters');
- }
-
- isNamed = true;
- _position = state.position + 1;
- } else {
- throwError(state, 'tag suffix cannot contain exclamation marks');
- }
- }
-
- ch = state.input.charCodeAt(++state.position);
- }
-
- tagName = state.input.slice(_position, state.position);
-
- if (PATTERN_FLOW_INDICATORS.test(tagName)) {
- throwError(state, 'tag suffix cannot contain flow indicator characters');
- }
- }
-
- if (tagName && !PATTERN_TAG_URI.test(tagName)) {
- throwError(state, 'tag name cannot contain such characters: ' + tagName);
- }
-
- if (isVerbatim) {
- state.tag = tagName;
-
- } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
- state.tag = state.tagMap[tagHandle] + tagName;
-
- } else if ('!' === tagHandle) {
- state.tag = '!' + tagName;
-
- } else if ('!!' === tagHandle) {
- state.tag = 'tag:yaml.org,2002:' + tagName;
-
- } else {
- throwError(state, 'undeclared tag handle "' + tagHandle + '"');
- }
-
- return true;
-}
-
-function readAnchorProperty(state) {
- var _position,
- ch;
-
- ch = state.input.charCodeAt(state.position);
-
- if (0x26/* & */ !== ch) {
- return false;
- }
-
- if (null !== state.anchor) {
- throwError(state, 'duplication of an anchor property');
- }
-
- ch = state.input.charCodeAt(++state.position);
- _position = state.position;
-
- while (0 !== ch && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
- ch = state.input.charCodeAt(++state.position);
- }
-
- if (state.position === _position) {
- throwError(state, 'name of an anchor node must contain at least one character');
- }
-
- state.anchor = state.input.slice(_position, state.position);
- return true;
-}
-
-function readAlias(state) {
- var _position, alias,
- len = state.length,
- input = state.input,
- ch;
-
- ch = state.input.charCodeAt(state.position);
-
- if (0x2A/* * */ !== ch) {
- return false;
- }
-
- ch = state.input.charCodeAt(++state.position);
- _position = state.position;
-
- while (0 !== ch && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
- ch = state.input.charCodeAt(++state.position);
- }
-
- if (state.position === _position) {
- throwError(state, 'name of an alias node must contain at least one character');
- }
-
- alias = state.input.slice(_position, state.position);
-
- if (!state.anchorMap.hasOwnProperty(alias)) {
- throwError(state, 'unidentified alias "' + alias + '"');
- }
-
- state.result = state.anchorMap[alias];
- skipSeparationSpace(state, true, -1);
- return true;
-}
-
-function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
- var allowBlockStyles,
- allowBlockScalars,
- allowBlockCollections,
- atNewLine = false,
- isIndented = true,
- hasContent = false,
- typeIndex,
- typeQuantity,
- type,
- flowIndent,
- blockIndent,
- _result;
-
- state.tag = null;
- state.anchor = null;
- state.kind = null;
- state.result = null;
-
- allowBlockStyles = allowBlockScalars = allowBlockCollections =
- CONTEXT_BLOCK_OUT === nodeContext ||
- CONTEXT_BLOCK_IN === nodeContext;
-
- if (allowToSeek) {
- if (skipSeparationSpace(state, true, -1)) {
- atNewLine = true;
-
- if (state.lineIndent === parentIndent) {
- isIndented = false;
-
- } else if (state.lineIndent > parentIndent) {
- isIndented = true;
-
- } else {
- return false;
- }
- }
- }
-
- if (isIndented) {
- while (readTagProperty(state) || readAnchorProperty(state)) {
- if (skipSeparationSpace(state, true, -1)) {
- atNewLine = true;
-
- if (state.lineIndent > parentIndent) {
- isIndented = true;
- allowBlockCollections = allowBlockStyles;
-
- } else if (state.lineIndent === parentIndent) {
- isIndented = false;
- allowBlockCollections = allowBlockStyles;
-
- } else {
- return true;
- }
- } else {
- allowBlockCollections = false;
- }
- }
- }
-
- if (allowBlockCollections) {
- allowBlockCollections = atNewLine || allowCompact;
- }
-
- if (isIndented || CONTEXT_BLOCK_OUT === nodeContext) {
- if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
- flowIndent = parentIndent;
- } else {
- flowIndent = parentIndent + 1;
- }
-
- blockIndent = state.position - state.lineStart;
-
- if (isIndented) {
- if (allowBlockCollections &&
- (readBlockSequence(state, blockIndent) ||
- readBlockMapping(state, blockIndent, flowIndent)) ||
- readFlowCollection(state, flowIndent)) {
- hasContent = true;
- } else {
- if ((allowBlockScalars && readBlockScalar(state, flowIndent)) ||
- readSingleQuotedScalar(state, flowIndent) ||
- readDoubleQuotedScalar(state, flowIndent)) {
- hasContent = true;
-
- } else if (readAlias(state)) {
- hasContent = true;
-
- if (null !== state.tag || null !== state.anchor) {
- throwError(state, 'alias node should not have any properties');
- }
-
- } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
- hasContent = true;
-
- if (null === state.tag) {
- state.tag = '?';
- }
- }
-
- if (null !== state.anchor) {
- state.anchorMap[state.anchor] = state.result;
- }
- }
- } else {
- hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
- }
- }
-
- if (null !== state.tag && '!' !== state.tag) {
- if ('?' === state.tag) {
- for (typeIndex = 0, typeQuantity = state.implicitTypes.length;
- typeIndex < typeQuantity;
- typeIndex += 1) {
- type = state.implicitTypes[typeIndex];
-
- // Implicit resolving is not allowed for non-scalar types, and '?'
- // non-specific tag is only assigned to plain scalars. So, it isn't
- // needed to check for 'kind' conformity.
-
- if (type.resolve(state.result)) { // `state.result` updated in resolver if matched
- state.result = type.construct(state.result);
- state.tag = type.tag;
- break;
- }
- }
- } else if (_hasOwnProperty.call(state.typeMap, state.tag)) {
- type = state.typeMap[state.tag];
-
- if (null !== state.result && type.kind !== state.kind) {
- throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
- }
-
- if (!type.resolve(state.result)) { // `state.result` updated in resolver if matched
- throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag');
- } else {
- state.result = type.construct(state.result);
- }
- } else {
- throwWarning(state, 'unknown tag !<' + state.tag + '>');
- }
- }
-
- return null !== state.tag || null !== state.anchor || hasContent;
-}
-
-function readDocument(state) {
- var documentStart = state.position,
- _position,
- directiveName,
- directiveArgs,
- hasDirectives = false,
- ch;
-
- state.version = null;
- state.checkLineBreaks = state.legacy;
- state.tagMap = {};
- state.anchorMap = {};
-
- while (0 !== (ch = state.input.charCodeAt(state.position))) {
- skipSeparationSpace(state, true, -1);
-
- ch = state.input.charCodeAt(state.position);
-
- if (state.lineIndent > 0 || 0x25/* % */ !== ch) {
- break;
- }
-
- hasDirectives = true;
- ch = state.input.charCodeAt(++state.position);
- _position = state.position;
-
- while (0 !== ch && !is_WS_OR_EOL(ch)) {
- ch = state.input.charCodeAt(++state.position);
- }
-
- directiveName = state.input.slice(_position, state.position);
- directiveArgs = [];
-
- if (directiveName.length < 1) {
- throwError(state, 'directive name must not be less than one character in length');
- }
-
- while (0 !== ch) {
- while (is_WHITE_SPACE(ch)) {
- ch = state.input.charCodeAt(++state.position);
- }
-
- if (0x23/* # */ === ch) {
- do { ch = state.input.charCodeAt(++state.position); }
- while (0 !== ch && !is_EOL(ch));
- break;
- }
-
- if (is_EOL(ch)) {
- break;
- }
-
- _position = state.position;
-
- while (0 !== ch && !is_WS_OR_EOL(ch)) {
- ch = state.input.charCodeAt(++state.position);
- }
-
- directiveArgs.push(state.input.slice(_position, state.position));
- }
-
- if (0 !== ch) {
- readLineBreak(state);
- }
-
- if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
- directiveHandlers[directiveName](state, directiveName, directiveArgs);
- } else {
- throwWarning(state, 'unknown document directive "' + directiveName + '"');
- }
- }
-
- skipSeparationSpace(state, true, -1);
-
- if (0 === state.lineIndent &&
- 0x2D/* - */ === state.input.charCodeAt(state.position) &&
- 0x2D/* - */ === state.input.charCodeAt(state.position + 1) &&
- 0x2D/* - */ === state.input.charCodeAt(state.position + 2)) {
- state.position += 3;
- skipSeparationSpace(state, true, -1);
-
- } else if (hasDirectives) {
- throwError(state, 'directives end mark is expected');
- }
-
- composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
- skipSeparationSpace(state, true, -1);
-
- if (state.checkLineBreaks &&
- PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
- throwWarning(state, 'non-ASCII line breaks are interpreted as content');
- }
-
- state.documents.push(state.result);
-
- if (state.position === state.lineStart && testDocumentSeparator(state)) {
-
- if (0x2E/* . */ === state.input.charCodeAt(state.position)) {
- state.position += 3;
- skipSeparationSpace(state, true, -1);
- }
- return;
- }
-
- if (state.position < (state.length - 1)) {
- throwError(state, 'end of the stream or a document separator is expected');
- } else {
- return;
- }
-}
-
-
-function loadDocuments(input, options) {
- input = String(input);
- options = options || {};
-
- if (0 !== input.length &&
- 0x0A/* LF */ !== input.charCodeAt(input.length - 1) &&
- 0x0D/* CR */ !== input.charCodeAt(input.length - 1)) {
- input += '\n';
- }
-
- var state = new State(input, options);
-
- if (PATTERN_NON_PRINTABLE.test(state.input)) {
- throwError(state, 'the stream contains non-printable characters');
- }
-
- // Use 0 as string terminator. That significantly simplifies bounds check.
- state.input += '\0';
-
- while (0x20/* Space */ === state.input.charCodeAt(state.position)) {
- state.lineIndent += 1;
- }
-
- while (state.position < (state.length - 1)) {
- readDocument(state);
- }
-
- return state.documents;
-}
-
-
-function loadAll(input, iterator, options) {
- var documents = loadDocuments(input, options), index, length;
-
- for (index = 0, length = documents.length; index < length; index += 1) {
- iterator(documents[index]);
- }
-}
-
-
-function load(input, options) {
- var documents = loadDocuments(input, options), index, length;
-
- if (0 === documents.length) {
- return undefined;
- } else if (1 === documents.length) {
- return documents[0];
- } else {
- throw new YAMLException('expected a single document in the stream, but found more');
- }
-}
-
-
-function safeLoadAll(input, output, options) {
- loadAll(input, output, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
-}
-
-
-function safeLoad(input, options) {
- return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
-}
-
-
-module.exports.loadAll = loadAll;
-module.exports.load = load;
-module.exports.safeLoadAll = safeLoadAll;
-module.exports.safeLoad = safeLoad;
-
-},{"./common":3,"./exception":5,"./mark":7,"./schema/default_full":10,"./schema/default_safe":11}],7:[function(_dereq_,module,exports){
-'use strict';
-
-
-var common = _dereq_('./common');
-
-
-function Mark(name, buffer, position, line, column) {
- this.name = name;
- this.buffer = buffer;
- this.position = position;
- this.line = line;
- this.column = column;
-}
-
-
-Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
- var head, start, tail, end, snippet;
-
- if (!this.buffer) {
- return null;
- }
-
- indent = indent || 4;
- maxLength = maxLength || 75;
-
- head = '';
- start = this.position;
-
- while (start > 0 && -1 === '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1))) {
- start -= 1;
- if (this.position - start > (maxLength / 2 - 1)) {
- head = ' ... ';
- start += 5;
- break;
- }
- }
-
- tail = '';
- end = this.position;
-
- while (end < this.buffer.length && -1 === '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end))) {
- end += 1;
- if (end - this.position > (maxLength / 2 - 1)) {
- tail = ' ... ';
- end -= 5;
- break;
- }
- }
-
- snippet = this.buffer.slice(start, end);
-
- return common.repeat(' ', indent) + head + snippet + tail + '\n' +
- common.repeat(' ', indent + this.position - start + head.length) + '^';
-};
-
-
-Mark.prototype.toString = function toString(compact) {
- var snippet, where = '';
-
- if (this.name) {
- where += 'in "' + this.name + '" ';
- }
-
- where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1);
-
- if (!compact) {
- snippet = this.getSnippet();
-
- if (snippet) {
- where += ':\n' + snippet;
- }
- }
-
- return where;
-};
-
-
-module.exports = Mark;
-
-},{"./common":3}],8:[function(_dereq_,module,exports){
-'use strict';
-
-
-var common = _dereq_('./common');
-var YAMLException = _dereq_('./exception');
-var Type = _dereq_('./type');
-
-
-function compileList(schema, name, result) {
- var exclude = [];
-
- schema.include.forEach(function (includedSchema) {
- result = compileList(includedSchema, name, result);
- });
-
- schema[name].forEach(function (currentType) {
- result.forEach(function (previousType, previousIndex) {
- if (previousType.tag === currentType.tag) {
- exclude.push(previousIndex);
- }
- });
-
- result.push(currentType);
- });
-
- return result.filter(function (type, index) {
- return -1 === exclude.indexOf(index);
- });
-}
-
-
-function compileMap(/* lists... */) {
- var result = {}, index, length;
-
- function collectType(type) {
- result[type.tag] = type;
- }
-
- for (index = 0, length = arguments.length; index < length; index += 1) {
- arguments[index].forEach(collectType);
- }
-
- return result;
-}
-
-
-function Schema(definition) {
- this.include = definition.include || [];
- this.implicit = definition.implicit || [];
- this.explicit = definition.explicit || [];
-
- this.implicit.forEach(function (type) {
- if (type.loadKind && 'scalar' !== type.loadKind) {
- throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.');
- }
- });
-
- this.compiledImplicit = compileList(this, 'implicit', []);
- this.compiledExplicit = compileList(this, 'explicit', []);
- this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit);
-}
-
-
-Schema.DEFAULT = null;
-
-
-Schema.create = function createSchema() {
- var schemas, types;
-
- switch (arguments.length) {
- case 1:
- schemas = Schema.DEFAULT;
- types = arguments[0];
- break;
-
- case 2:
- schemas = arguments[0];
- types = arguments[1];
- break;
-
- default:
- throw new YAMLException('Wrong number of arguments for Schema.create function');
- }
-
- schemas = common.toArray(schemas);
- types = common.toArray(types);
-
- if (!schemas.every(function (schema) { return schema instanceof Schema; })) {
- throw new YAMLException('Specified list of super schemas (or a single Schema object) contains a non-Schema object.');
- }
-
- if (!types.every(function (type) { return type instanceof Type; })) {
- throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.');
- }
-
- return new Schema({
- include: schemas,
- explicit: types
- });
-};
-
-
-module.exports = Schema;
-
-},{"./common":3,"./exception":5,"./type":14}],9:[function(_dereq_,module,exports){
-// Standard YAML's Core schema.
-// http://www.yaml.org/spec/1.2/spec.html#id2804923
-//
-// NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
-// So, Core schema has no distinctions from JSON schema is JS-YAML.
-
-
-'use strict';
-
-
-var Schema = _dereq_('../schema');
-
-
-module.exports = new Schema({
- include: [
- _dereq_('./json')
- ]
-});
-
-},{"../schema":8,"./json":13}],10:[function(_dereq_,module,exports){
-// JS-YAML's default schema for `load` function.
-// It is not described in the YAML specification.
-//
-// This schema is based on JS-YAML's default safe schema and includes
-// JavaScript-specific types: !!js/undefined, !!js/regexp and !!js/function.
-//
-// Also this schema is used as default base schema at `Schema.create` function.
-
-
-'use strict';
-
-
-var Schema = _dereq_('../schema');
-
-
-module.exports = Schema.DEFAULT = new Schema({
- include: [
- _dereq_('./default_safe')
- ],
- explicit: [
- _dereq_('../type/js/undefined'),
- _dereq_('../type/js/regexp'),
- _dereq_('../type/js/function')
- ]
-});
-
-},{"../schema":8,"../type/js/function":19,"../type/js/regexp":20,"../type/js/undefined":21,"./default_safe":11}],11:[function(_dereq_,module,exports){
-// JS-YAML's default schema for `safeLoad` function.
-// It is not described in the YAML specification.
-//
-// This schema is based on standard YAML's Core schema and includes most of
-// extra types described at YAML tag repository. (http://yaml.org/type/)
-
-
-'use strict';
-
-
-var Schema = _dereq_('../schema');
-
-
-module.exports = new Schema({
- include: [
- _dereq_('./core')
- ],
- implicit: [
- _dereq_('../type/timestamp'),
- _dereq_('../type/merge')
- ],
- explicit: [
- _dereq_('../type/binary'),
- _dereq_('../type/omap'),
- _dereq_('../type/pairs'),
- _dereq_('../type/set')
- ]
-});
-
-},{"../schema":8,"../type/binary":15,"../type/merge":23,"../type/omap":25,"../type/pairs":26,"../type/set":28,"../type/timestamp":30,"./core":9}],12:[function(_dereq_,module,exports){
-// Standard YAML's Failsafe schema.
-// http://www.yaml.org/spec/1.2/spec.html#id2802346
-
-
-'use strict';
-
-
-var Schema = _dereq_('../schema');
-
-
-module.exports = new Schema({
- explicit: [
- _dereq_('../type/str'),
- _dereq_('../type/seq'),
- _dereq_('../type/map')
- ]
-});
-
-},{"../schema":8,"../type/map":22,"../type/seq":27,"../type/str":29}],13:[function(_dereq_,module,exports){
-// Standard YAML's JSON schema.
-// http://www.yaml.org/spec/1.2/spec.html#id2803231
-//
-// NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
-// So, this schema is not such strict as defined in the YAML specification.
-// It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc.
-
-
-'use strict';
-
-
-var Schema = _dereq_('../schema');
-
-
-module.exports = new Schema({
- include: [
- _dereq_('./failsafe')
- ],
- implicit: [
- _dereq_('../type/null'),
- _dereq_('../type/bool'),
- _dereq_('../type/int'),
- _dereq_('../type/float')
- ]
-});
-
-},{"../schema":8,"../type/bool":16,"../type/float":17,"../type/int":18,"../type/null":24,"./failsafe":12}],14:[function(_dereq_,module,exports){
-'use strict';
-
-var YAMLException = _dereq_('./exception');
-
-var TYPE_CONSTRUCTOR_OPTIONS = [
- 'kind',
- 'resolve',
- 'construct',
- 'instanceOf',
- 'predicate',
- 'represent',
- 'defaultStyle',
- 'styleAliases'
-];
-
-var YAML_NODE_KINDS = [
- 'scalar',
- 'sequence',
- 'mapping'
-];
-
-function compileStyleAliases(map) {
- var result = {};
-
- if (null !== map) {
- Object.keys(map).forEach(function (style) {
- map[style].forEach(function (alias) {
- result[String(alias)] = style;
- });
- });
- }
-
- return result;
-}
-
-function Type(tag, options) {
- options = options || {};
-
- Object.keys(options).forEach(function (name) {
- if (-1 === TYPE_CONSTRUCTOR_OPTIONS.indexOf(name)) {
- throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
- }
- });
-
- // TODO: Add tag format check.
- this.tag = tag;
- this.kind = options['kind'] || null;
- this.resolve = options['resolve'] || function () { return true; };
- this.construct = options['construct'] || function (data) { return data; };
- this.instanceOf = options['instanceOf'] || null;
- this.predicate = options['predicate'] || null;
- this.represent = options['represent'] || null;
- this.defaultStyle = options['defaultStyle'] || null;
- this.styleAliases = compileStyleAliases(options['styleAliases'] || null);
-
- if (-1 === YAML_NODE_KINDS.indexOf(this.kind)) {
- throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
- }
-}
-
-module.exports = Type;
-
-},{"./exception":5}],15:[function(_dereq_,module,exports){
-// Modified from:
-// https://raw.github.com/kanaka/noVNC/d890e8640f20fba3215ba7be8e0ff145aeb8c17c/include/base64.js
-
-'use strict';
-
-// A trick for browserified version.
-// Since we make browserifier to ignore `buffer` module, NodeBuffer will be undefined
-var NodeBuffer = _dereq_('buffer').Buffer;
-var Type = _dereq_('../type');
-
-var BASE64_PADDING = '=';
-
-var BASE64_BINTABLE = [
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
- 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, 0, -1, -1,
- -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
- -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1
-];
-
-var BASE64_CHARTABLE =
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
-
-function resolveYamlBinary(data) {
- var code, idx = 0, len = data.length, leftbits;
-
- leftbits = 0; // number of bits decoded, but yet to be appended
-
- // Convert one by one.
- for (idx = 0; idx < len; idx += 1) {
- code = data.charCodeAt(idx);
-
- // Skip LF(NL) || CR
- if (0x0A === code || 0x0D === code) { continue; }
-
- // Fail on illegal characters
- if (-1 === BASE64_BINTABLE[code & 0x7F]) {
- return false;
- }
-
- // update bitcount
- leftbits += 6;
-
- // If we have 8 or more bits, append 8 bits to the result
- if (leftbits >= 8) {
- leftbits -= 8;
- }
- }
-
- // If there are any bits left, the base64 string was corrupted
- if (leftbits) {
- return false;
- } else {
- return true;
- }
-}
-
-function constructYamlBinary(data) {
- var value, code, idx = 0, len = data.length, result = [], leftbits, leftdata;
-
- leftbits = 0; // number of bits decoded, but yet to be appended
- leftdata = 0; // bits decoded, but yet to be appended
-
- // Convert one by one.
- for (idx = 0; idx < len; idx += 1) {
- code = data.charCodeAt(idx);
- value = BASE64_BINTABLE[code & 0x7F];
-
- // Skip LF(NL) || CR
- if (0x0A === code || 0x0D === code) { continue; }
-
- // Collect data into leftdata, update bitcount
- leftdata = (leftdata << 6) | value;
- leftbits += 6;
-
- // If we have 8 or more bits, append 8 bits to the result
- if (leftbits >= 8) {
- leftbits -= 8;
-
- // Append if not padding.
- if (BASE64_PADDING !== data.charAt(idx)) {
- result.push((leftdata >> leftbits) & 0xFF);
- }
-
- leftdata &= (1 << leftbits) - 1;
- }
- }
-
- // Wrap into Buffer for NodeJS and leave Array for browser
- if (NodeBuffer) {
- return new NodeBuffer(result);
- }
-
- return result;
-}
-
-function representYamlBinary(object /*, style*/) {
- var result = '', index, length, rest;
-
- // Convert every three bytes to 4 ASCII characters.
- for (index = 0, length = object.length - 2; index < length; index += 3) {
- result += BASE64_CHARTABLE[object[index + 0] >> 2];
- result += BASE64_CHARTABLE[((object[index + 0] & 0x03) << 4) + (object[index + 1] >> 4)];
- result += BASE64_CHARTABLE[((object[index + 1] & 0x0F) << 2) + (object[index + 2] >> 6)];
- result += BASE64_CHARTABLE[object[index + 2] & 0x3F];
- }
-
- rest = object.length % 3;
-
- // Convert the remaining 1 or 2 bytes, padding out to 4 characters.
- if (0 !== rest) {
- index = object.length - rest;
- result += BASE64_CHARTABLE[object[index + 0] >> 2];
-
- if (2 === rest) {
- result += BASE64_CHARTABLE[((object[index + 0] & 0x03) << 4) + (object[index + 1] >> 4)];
- result += BASE64_CHARTABLE[(object[index + 1] & 0x0F) << 2];
- result += BASE64_PADDING;
- } else {
- result += BASE64_CHARTABLE[(object[index + 0] & 0x03) << 4];
- result += BASE64_PADDING + BASE64_PADDING;
- }
- }
-
- return result;
-}
-
-function isBinary(object) {
- return NodeBuffer && NodeBuffer.isBuffer(object);
-}
-
-module.exports = new Type('tag:yaml.org,2002:binary', {
- kind: 'scalar',
- resolve: resolveYamlBinary,
- construct: constructYamlBinary,
- predicate: isBinary,
- represent: representYamlBinary
-});
-
-},{"../type":14,"buffer":31}],16:[function(_dereq_,module,exports){
-'use strict';
-
-var Type = _dereq_('../type');
-
-function resolveYamlBoolean(data) {
- var max = data.length;
-
- return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) ||
- (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE'));
-}
-
-function constructYamlBoolean(data) {
- return data === 'true' ||
- data === 'True' ||
- data === 'TRUE';
-}
-
-function isBoolean(object) {
- return '[object Boolean]' === Object.prototype.toString.call(object);
-}
-
-module.exports = new Type('tag:yaml.org,2002:bool', {
- kind: 'scalar',
- resolve: resolveYamlBoolean,
- construct: constructYamlBoolean,
- predicate: isBoolean,
- represent: {
- lowercase: function (object) { return object ? 'true' : 'false'; },
- uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; },
- camelcase: function (object) { return object ? 'True' : 'False'; }
- },
- defaultStyle: 'lowercase'
-});
-
-},{"../type":14}],17:[function(_dereq_,module,exports){
-'use strict';
-
-var common = _dereq_('../common');
-var Type = _dereq_('../type');
-
-var YAML_FLOAT_PATTERN = new RegExp(
- '^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?' +
- '|\\.[0-9_]+(?:[eE][-+][0-9]+)?' +
- '|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' +
- '|[-+]?\\.(?:inf|Inf|INF)' +
- '|\\.(?:nan|NaN|NAN))$');
-
-function resolveYamlFloat(data) {
- var value, sign, base, digits;
-
- if (!YAML_FLOAT_PATTERN.test(data)) {
- return false;
- }
- return true;
-}
-
-function constructYamlFloat(data) {
- var value, sign, base, digits;
-
- value = data.replace(/_/g, '').toLowerCase();
- sign = '-' === value[0] ? -1 : 1;
- digits = [];
-
- if (0 <= '+-'.indexOf(value[0])) {
- value = value.slice(1);
- }
-
- if ('.inf' === value) {
- return (1 === sign) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
-
- } else if ('.nan' === value) {
- return NaN;
-
- } else if (0 <= value.indexOf(':')) {
- value.split(':').forEach(function (v) {
- digits.unshift(parseFloat(v, 10));
- });
-
- value = 0.0;
- base = 1;
-
- digits.forEach(function (d) {
- value += d * base;
- base *= 60;
- });
-
- return sign * value;
-
- } else {
- return sign * parseFloat(value, 10);
- }
-}
-
-function representYamlFloat(object, style) {
- if (isNaN(object)) {
- switch (style) {
- case 'lowercase':
- return '.nan';
- case 'uppercase':
- return '.NAN';
- case 'camelcase':
- return '.NaN';
- }
- } else if (Number.POSITIVE_INFINITY === object) {
- switch (style) {
- case 'lowercase':
- return '.inf';
- case 'uppercase':
- return '.INF';
- case 'camelcase':
- return '.Inf';
- }
- } else if (Number.NEGATIVE_INFINITY === object) {
- switch (style) {
- case 'lowercase':
- return '-.inf';
- case 'uppercase':
- return '-.INF';
- case 'camelcase':
- return '-.Inf';
- }
- } else if (common.isNegativeZero(object)) {
- return '-0.0';
- } else {
- return object.toString(10);
- }
-}
-
-function isFloat(object) {
- return ('[object Number]' === Object.prototype.toString.call(object)) &&
- (0 !== object % 1 || common.isNegativeZero(object));
-}
-
-module.exports = new Type('tag:yaml.org,2002:float', {
- kind: 'scalar',
- resolve: resolveYamlFloat,
- construct: constructYamlFloat,
- predicate: isFloat,
- represent: representYamlFloat,
- defaultStyle: 'lowercase'
-});
-
-},{"../common":3,"../type":14}],18:[function(_dereq_,module,exports){
-'use strict';
-
-var common = _dereq_('../common');
-var Type = _dereq_('../type');
-
-function isHexCode(c) {
- return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) ||
- ((0x41/* A */ <= c) && (c <= 0x46/* F */)) ||
- ((0x61/* a */ <= c) && (c <= 0x66/* f */));
-}
-
-function isOctCode(c) {
- return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */));
-}
-
-function isDecCode(c) {
- return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */));
-}
-
-function resolveYamlInteger(data) {
- var max = data.length,
- index = 0,
- hasDigits = false,
- ch;
-
- if (!max) { return false; }
-
- ch = data[index];
-
- // sign
- if (ch === '-' || ch === '+') {
- ch = data[++index];
- }
-
- if (ch === '0') {
- // 0
- if (index+1 === max) { return true; }
- ch = data[++index];
-
- // base 2, base 8, base 16
-
- if (ch === 'b') {
- // base 2
- index++;
-
- for (; index < max; index++) {
- ch = data[index];
- if (ch === '_') { continue; }
- if (ch !== '0' && ch !== '1') {
- return false;
- }
- hasDigits = true;
- }
- return hasDigits;
- }
-
-
- if (ch === 'x') {
- // base 16
- index++;
-
- for (; index < max; index++) {
- ch = data[index];
- if (ch === '_') { continue; }
- if (!isHexCode(data.charCodeAt(index))) {
- return false;
- }
- hasDigits = true;
- }
- return hasDigits;
- }
-
- // base 8
- for (; index < max; index++) {
- ch = data[index];
- if (ch === '_') { continue; }
- if (!isOctCode(data.charCodeAt(index))) {
- return false;
- }
- hasDigits = true;
- }
- return hasDigits;
- }
-
- // base 10 (except 0) or base 60
-
- for (; index < max; index++) {
- ch = data[index];
- if (ch === '_') { continue; }
- if (ch === ':') { break; }
- if (!isDecCode(data.charCodeAt(index))) {
- return false;
- }
- hasDigits = true;
- }
-
- if (!hasDigits) { return false; }
-
- // if !base60 - done;
- if (ch !== ':') { return true; }
-
- // base60 almost not used, no needs to optimize
- return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
-}
-
-function constructYamlInteger(data) {
- var value = data, sign = 1, ch, base, digits = [];
-
- if (value.indexOf('_') !== -1) {
- value = value.replace(/_/g, '');
- }
-
- ch = value[0];
-
- if (ch === '-' || ch === '+') {
- if (ch === '-') { sign = -1; }
- value = value.slice(1);
- ch = value[0];
- }
-
- if ('0' === value) {
- return 0;
- }
-
- if (ch === '0') {
- if (value[1] === 'b') {
- return sign * parseInt(value.slice(2), 2);
- }
- if (value[1] === 'x') {
- return sign * parseInt(value, 16);
- }
- return sign * parseInt(value, 8);
-
- }
-
- if (value.indexOf(':') !== -1) {
- value.split(':').forEach(function (v) {
- digits.unshift(parseInt(v, 10));
- });
-
- value = 0;
- base = 1;
-
- digits.forEach(function (d) {
- value += (d * base);
- base *= 60;
- });
-
- return sign * value;
-
- }
-
- return sign * parseInt(value, 10);
-}
-
-function isInteger(object) {
- return ('[object Number]' === Object.prototype.toString.call(object)) &&
- (0 === object % 1 && !common.isNegativeZero(object));
-}
-
-module.exports = new Type('tag:yaml.org,2002:int', {
- kind: 'scalar',
- resolve: resolveYamlInteger,
- construct: constructYamlInteger,
- predicate: isInteger,
- represent: {
- binary: function (object) { return '0b' + object.toString(2); },
- octal: function (object) { return '0' + object.toString(8); },
- decimal: function (object) { return object.toString(10); },
- hexadecimal: function (object) { return '0x' + object.toString(16).toUpperCase(); }
- },
- defaultStyle: 'decimal',
- styleAliases: {
- binary: [ 2, 'bin' ],
- octal: [ 8, 'oct' ],
- decimal: [ 10, 'dec' ],
- hexadecimal: [ 16, 'hex' ]
- }
-});
-
-},{"../common":3,"../type":14}],19:[function(_dereq_,module,exports){
-'use strict';
-
-var esprima;
-
-// Browserified version does not have esprima
-//
-// 1. For node.js just require module as deps
-// 2. For browser try to require mudule via external AMD system.
-// If not found - try to fallback to window.esprima. If not
-// found too - then fail to parse.
-//
-try {
- esprima = _dereq_('esprima');
-} catch (_) {
- /*global window */
- if (typeof window !== 'undefined') { esprima = window.esprima; }
-}
-
-var Type = _dereq_('../../type');
-
-function resolveJavascriptFunction(data) {
- try {
- var source = '(' + data + ')',
- ast = esprima.parse(source, { range: true }),
- params = [],
- body;
-
- if ('Program' !== ast.type ||
- 1 !== ast.body.length ||
- 'ExpressionStatement' !== ast.body[0].type ||
- 'FunctionExpression' !== ast.body[0].expression.type) {
- return false;
- }
-
- return true;
- } catch (err) {
- return false;
- }
-}
-
-function constructJavascriptFunction(data) {
- /*jslint evil:true*/
-
- var source = '(' + data + ')',
- ast = esprima.parse(source, { range: true }),
- params = [],
- body;
-
- if ('Program' !== ast.type ||
- 1 !== ast.body.length ||
- 'ExpressionStatement' !== ast.body[0].type ||
- 'FunctionExpression' !== ast.body[0].expression.type) {
- throw new Error('Failed to resolve function');
- }
-
- ast.body[0].expression.params.forEach(function (param) {
- params.push(param.name);
- });
-
- body = ast.body[0].expression.body.range;
-
- // Esprima's ranges include the first '{' and the last '}' characters on
- // function expressions. So cut them out.
- return new Function(params, source.slice(body[0]+1, body[1]-1));
-}
-
-function representJavascriptFunction(object /*, style*/) {
- return object.toString();
-}
-
-function isFunction(object) {
- return '[object Function]' === Object.prototype.toString.call(object);
-}
-
-module.exports = new Type('tag:yaml.org,2002:js/function', {
- kind: 'scalar',
- resolve: resolveJavascriptFunction,
- construct: constructJavascriptFunction,
- predicate: isFunction,
- represent: representJavascriptFunction
-});
-
-},{"../../type":14,"esprima":"Lkr711"}],20:[function(_dereq_,module,exports){
-'use strict';
-
-var Type = _dereq_('../../type');
-
-function resolveJavascriptRegExp(data) {
- var regexp = data,
- tail = /\/([gim]*)$/.exec(data),
- modifiers = '';
-
- // if regexp starts with '/' it can have modifiers and must be properly closed
- // `/foo/gim` - modifiers tail can be maximum 3 chars
- if ('/' === regexp[0]) {
- if (tail) {
- modifiers = tail[1];
- }
-
- if (modifiers.length > 3) { return false; }
- // if expression starts with /, is should be properly terminated
- if (regexp[regexp.length - modifiers.length - 1] !== '/') { return false; }
-
- regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
- }
-
- try {
- var dummy = new RegExp(regexp, modifiers);
- return true;
- } catch (error) {
- return false;
- }
-}
-
-function constructJavascriptRegExp(data) {
- var regexp = data,
- tail = /\/([gim]*)$/.exec(data),
- modifiers = '';
-
- // `/foo/gim` - tail can be maximum 4 chars
- if ('/' === regexp[0]) {
- if (tail) {
- modifiers = tail[1];
- }
- regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
- }
-
- return new RegExp(regexp, modifiers);
-}
-
-function representJavascriptRegExp(object /*, style*/) {
- var result = '/' + object.source + '/';
-
- if (object.global) {
- result += 'g';
- }
-
- if (object.multiline) {
- result += 'm';
- }
-
- if (object.ignoreCase) {
- result += 'i';
- }
-
- return result;
-}
-
-function isRegExp(object) {
- return '[object RegExp]' === Object.prototype.toString.call(object);
-}
-
-module.exports = new Type('tag:yaml.org,2002:js/regexp', {
- kind: 'scalar',
- resolve: resolveJavascriptRegExp,
- construct: constructJavascriptRegExp,
- predicate: isRegExp,
- represent: representJavascriptRegExp
-});
-
-},{"../../type":14}],21:[function(_dereq_,module,exports){
-'use strict';
-
-var Type = _dereq_('../../type');
-
-function resolveJavascriptUndefined() {
- return true;
-}
-
-function constructJavascriptUndefined() {
- return undefined;
-}
-
-function representJavascriptUndefined() {
- return '';
-}
-
-function isUndefined(object) {
- return 'undefined' === typeof object;
-}
-
-module.exports = new Type('tag:yaml.org,2002:js/undefined', {
- kind: 'scalar',
- resolve: resolveJavascriptUndefined,
- construct: constructJavascriptUndefined,
- predicate: isUndefined,
- represent: representJavascriptUndefined
-});
-
-},{"../../type":14}],22:[function(_dereq_,module,exports){
-'use strict';
-
-var Type = _dereq_('../type');
-
-module.exports = new Type('tag:yaml.org,2002:map', {
- kind: 'mapping'
-});
-
-},{"../type":14}],23:[function(_dereq_,module,exports){
-'use strict';
-
-var Type = _dereq_('../type');
-
-function resolveYamlMerge(data) {
- return '<<' === data;
-}
-
-module.exports = new Type('tag:yaml.org,2002:merge', {
- kind: 'scalar',
- resolve: resolveYamlMerge,
-});
-
-},{"../type":14}],24:[function(_dereq_,module,exports){
-'use strict';
-
-var Type = _dereq_('../type');
-
-function resolveYamlNull(data) {
- var max = data.length;
-
- return (max === 1 && data === '~') ||
- (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL'));
-}
-
-function constructYamlNull() {
- return null;
-}
-
-function isNull(object) {
- return null === object;
-}
-
-module.exports = new Type('tag:yaml.org,2002:null', {
- kind: 'scalar',
- resolve: resolveYamlNull,
- construct: constructYamlNull,
- predicate: isNull,
- represent: {
- canonical: function () { return '~'; },
- lowercase: function () { return 'null'; },
- uppercase: function () { return 'NULL'; },
- camelcase: function () { return 'Null'; }
- },
- defaultStyle: 'lowercase'
-});
-
-},{"../type":14}],25:[function(_dereq_,module,exports){
-'use strict';
-
-var Type = _dereq_('../type');
-
-var _hasOwnProperty = Object.prototype.hasOwnProperty;
-var _toString = Object.prototype.toString;
-
-function resolveYamlOmap(data) {
- var objectKeys = [], index, length, pair, pairKey, pairHasKey,
- object = data;
-
- for (index = 0, length = object.length; index < length; index += 1) {
- pair = object[index];
- pairHasKey = false;
-
- if ('[object Object]' !== _toString.call(pair)) {
- return false;
- }
-
- for (pairKey in pair) {
- if (_hasOwnProperty.call(pair, pairKey)) {
- if (!pairHasKey) {
- pairHasKey = true;
- } else {
- return false;
- }
- }
- }
-
- if (!pairHasKey) {
- return false;
- }
-
- if (-1 === objectKeys.indexOf(pairKey)) {
- objectKeys.push(pairKey);
- } else {
- return false;
- }
- }
-
- return true;
-}
-
-module.exports = new Type('tag:yaml.org,2002:omap', {
- kind: 'sequence',
- resolve: resolveYamlOmap
-});
-
-},{"../type":14}],26:[function(_dereq_,module,exports){
-'use strict';
-
-var Type = _dereq_('../type');
-
-var _toString = Object.prototype.toString;
-
-function resolveYamlPairs(data) {
- var index, length, pair, keys, result,
- object = data;
-
- result = new Array(object.length);
-
- for (index = 0, length = object.length; index < length; index += 1) {
- pair = object[index];
-
- if ('[object Object]' !== _toString.call(pair)) {
- return false;
- }
-
- keys = Object.keys(pair);
-
- if (1 !== keys.length) {
- return false;
- }
-
- result[index] = [ keys[0], pair[keys[0]] ];
- }
-
- return true;
-}
-
-function constructYamlPairs(data) {
- var index, length, pair, keys, result,
- object = data;
-
- result = new Array(object.length);
-
- for (index = 0, length = object.length; index < length; index += 1) {
- pair = object[index];
-
- keys = Object.keys(pair);
-
- result[index] = [ keys[0], pair[keys[0]] ];
- }
-
- return result;
-}
-
-module.exports = new Type('tag:yaml.org,2002:pairs', {
- kind: 'sequence',
- resolve: resolveYamlPairs,
- construct: constructYamlPairs
-});
-
-},{"../type":14}],27:[function(_dereq_,module,exports){
-'use strict';
-
-var Type = _dereq_('../type');
-
-module.exports = new Type('tag:yaml.org,2002:seq', {
- kind: 'sequence'
-});
-
-},{"../type":14}],28:[function(_dereq_,module,exports){
-'use strict';
-
-var Type = _dereq_('../type');
-
-var _hasOwnProperty = Object.prototype.hasOwnProperty;
-
-function resolveYamlSet(data) {
- var key, object = data;
-
- for (key in object) {
- if (_hasOwnProperty.call(object, key)) {
- if (null !== object[key]) {
- return false;
- }
- }
- }
-
- return true;
-}
-
-module.exports = new Type('tag:yaml.org,2002:set', {
- kind: 'mapping',
- resolve: resolveYamlSet
-});
-
-},{"../type":14}],29:[function(_dereq_,module,exports){
-'use strict';
-
-var Type = _dereq_('../type');
-
-module.exports = new Type('tag:yaml.org,2002:str', {
- kind: 'scalar'
-});
-
-},{"../type":14}],30:[function(_dereq_,module,exports){
-'use strict';
-
-var Type = _dereq_('../type');
-
-var YAML_TIMESTAMP_REGEXP = new RegExp(
- '^([0-9][0-9][0-9][0-9])' + // [1] year
- '-([0-9][0-9]?)' + // [2] month
- '-([0-9][0-9]?)' + // [3] day
- '(?:(?:[Tt]|[ \\t]+)' + // ...
- '([0-9][0-9]?)' + // [4] hour
- ':([0-9][0-9])' + // [5] minute
- ':([0-9][0-9])' + // [6] second
- '(?:\\.([0-9]*))?' + // [7] fraction
- '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour
- '(?::([0-9][0-9]))?))?)?$'); // [11] tz_minute
-
-function resolveYamlTimestamp(data) {
- var match, year, month, day, hour, minute, second, fraction = 0,
- delta = null, tz_hour, tz_minute, date;
-
- match = YAML_TIMESTAMP_REGEXP.exec(data);
-
- if (null === match) {
- return false;
- }
-
- return true;
-}
-
-function constructYamlTimestamp(data) {
- var match, year, month, day, hour, minute, second, fraction = 0,
- delta = null, tz_hour, tz_minute, date;
-
- match = YAML_TIMESTAMP_REGEXP.exec(data);
-
- if (null === match) {
- throw new Error('Date resolve error');
- }
-
- // match: [1] year [2] month [3] day
-
- year = +(match[1]);
- month = +(match[2]) - 1; // JS month starts with 0
- day = +(match[3]);
-
- if (!match[4]) { // no hour
- return new Date(Date.UTC(year, month, day));
- }
-
- // match: [4] hour [5] minute [6] second [7] fraction
-
- hour = +(match[4]);
- minute = +(match[5]);
- second = +(match[6]);
-
- if (match[7]) {
- fraction = match[7].slice(0, 3);
- while (fraction.length < 3) { // milli-seconds
- fraction += '0';
- }
- fraction = +fraction;
- }
-
- // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute
-
- if (match[9]) {
- tz_hour = +(match[10]);
- tz_minute = +(match[11] || 0);
- delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds
- if ('-' === match[9]) {
- delta = -delta;
- }
- }
-
- date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
-
- if (delta) {
- date.setTime(date.getTime() - delta);
- }
-
- return date;
-}
-
-function representYamlTimestamp(object /*, style*/) {
- return object.toISOString();
-}
-
-module.exports = new Type('tag:yaml.org,2002:timestamp', {
- kind: 'scalar',
- resolve: resolveYamlTimestamp,
- construct: constructYamlTimestamp,
- instanceOf: Date,
- represent: representYamlTimestamp
-});
-
-},{"../type":14}],31:[function(_dereq_,module,exports){
-
-},{}]},{},[1])
-(1)
-});
diff --git a/merlin/static/merlin/js/lib/underscore-min.js b/merlin/static/merlin/js/lib/underscore-min.js
deleted file mode 100644
index f01025b..0000000
--- a/merlin/static/merlin/js/lib/underscore-min.js
+++ /dev/null
@@ -1,6 +0,0 @@
-// Underscore.js 1.8.3
-// http://underscorejs.org
-// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
-// Underscore may be freely distributed under the MIT license.
-(function(){function n(n){function t(t,r,e,u,i,o){for(;i>=0&&o>i;i+=n){var a=u?u[i]:i;e=r(e,t[a],a,t)}return e}return function(r,e,u,i){e=b(e,i,4);var o=!k(r)&&m.keys(r),a=(o||r).length,c=n>0?0:a-1;return arguments.length<3&&(u=r[o?o[c]:c],c+=n),t(r,e,u,o,c,a)}}function t(n){return function(t,r,e){r=x(r,e);for(var u=O(t),i=n>0?0:u-1;i>=0&&u>i;i+=n)if(r(t[i],i,t))return i;return-1}}function r(n,t,r){return function(e,u,i){var o=0,a=O(e);if("number"==typeof i)n>0?o=i>=0?i:Math.max(i+a,o):a=i>=0?Math.min(i+1,a):i+a+1;else if(r&&i&&a)return i=r(e,u),e[i]===u?i:-1;if(u!==u)return i=t(l.call(e,o,a),m.isNaN),i>=0?i+o:-1;for(i=n>0?o:a-1;i>=0&&a>i;i+=n)if(e[i]===u)return i;return-1}}function e(n,t){var r=I.length,e=n.constructor,u=m.isFunction(e)&&e.prototype||a,i="constructor";for(m.has(n,i)&&!m.contains(t,i)&&t.push(i);r--;)i=I[r],i in n&&n[i]!==u[i]&&!m.contains(t,i)&&t.push(i)}var u=this,i=u._,o=Array.prototype,a=Object.prototype,c=Function.prototype,f=o.push,l=o.slice,s=a.toString,p=a.hasOwnProperty,h=Array.isArray,v=Object.keys,g=c.bind,y=Object.create,d=function(){},m=function(n){return n instanceof m?n:this instanceof m?void(this._wrapped=n):new m(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=m),exports._=m):u._=m,m.VERSION="1.8.3";var b=function(n,t,r){if(t===void 0)return n;switch(null==r?3:r){case 1:return function(r){return n.call(t,r)};case 2:return function(r,e){return n.call(t,r,e)};case 3:return function(r,e,u){return n.call(t,r,e,u)};case 4:return function(r,e,u,i){return n.call(t,r,e,u,i)}}return function(){return n.apply(t,arguments)}},x=function(n,t,r){return null==n?m.identity:m.isFunction(n)?b(n,t,r):m.isObject(n)?m.matcher(n):m.property(n)};m.iteratee=function(n,t){return x(n,t,1/0)};var _=function(n,t){return function(r){var e=arguments.length;if(2>e||null==r)return r;for(var u=1;e>u;u++)for(var i=arguments[u],o=n(i),a=o.length,c=0;a>c;c++){var f=o[c];t&&r[f]!==void 0||(r[f]=i[f])}return r}},j=function(n){if(!m.isObject(n))return{};if(y)return y(n);d.prototype=n;var t=new d;return d.prototype=null,t},w=function(n){return function(t){return null==t?void 0:t[n]}},A=Math.pow(2,53)-1,O=w("length"),k=function(n){var t=O(n);return"number"==typeof t&&t>=0&&A>=t};m.each=m.forEach=function(n,t,r){t=b(t,r);var e,u;if(k(n))for(e=0,u=n.length;u>e;e++)t(n[e],e,n);else{var i=m.keys(n);for(e=0,u=i.length;u>e;e++)t(n[i[e]],i[e],n)}return n},m.map=m.collect=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=Array(u),o=0;u>o;o++){var a=e?e[o]:o;i[o]=t(n[a],a,n)}return i},m.reduce=m.foldl=m.inject=n(1),m.reduceRight=m.foldr=n(-1),m.find=m.detect=function(n,t,r){var e;return e=k(n)?m.findIndex(n,t,r):m.findKey(n,t,r),e!==void 0&&e!==-1?n[e]:void 0},m.filter=m.select=function(n,t,r){var e=[];return t=x(t,r),m.each(n,function(n,r,u){t(n,r,u)&&e.push(n)}),e},m.reject=function(n,t,r){return m.filter(n,m.negate(x(t)),r)},m.every=m.all=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(!t(n[o],o,n))return!1}return!0},m.some=m.any=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(t(n[o],o,n))return!0}return!1},m.contains=m.includes=m.include=function(n,t,r,e){return k(n)||(n=m.values(n)),("number"!=typeof r||e)&&(r=0),m.indexOf(n,t,r)>=0},m.invoke=function(n,t){var r=l.call(arguments,2),e=m.isFunction(t);return m.map(n,function(n){var u=e?t:n[t];return null==u?u:u.apply(n,r)})},m.pluck=function(n,t){return m.map(n,m.property(t))},m.where=function(n,t){return m.filter(n,m.matcher(t))},m.findWhere=function(n,t){return m.find(n,m.matcher(t))},m.max=function(n,t,r){var e,u,i=-1/0,o=-1/0;if(null==t&&null!=n){n=k(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],e>i&&(i=e)}else t=x(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(u>o||u===-1/0&&i===-1/0)&&(i=n,o=u)});return i},m.min=function(n,t,r){var e,u,i=1/0,o=1/0;if(null==t&&null!=n){n=k(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],i>e&&(i=e)}else t=x(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(o>u||1/0===u&&1/0===i)&&(i=n,o=u)});return i},m.shuffle=function(n){for(var t,r=k(n)?n:m.values(n),e=r.length,u=Array(e),i=0;e>i;i++)t=m.random(0,i),t!==i&&(u[i]=u[t]),u[t]=r[i];return u},m.sample=function(n,t,r){return null==t||r?(k(n)||(n=m.values(n)),n[m.random(n.length-1)]):m.shuffle(n).slice(0,Math.max(0,t))},m.sortBy=function(n,t,r){return t=x(t,r),m.pluck(m.map(n,function(n,r,e){return{value:n,index:r,criteria:t(n,r,e)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index-t.index}),"value")};var F=function(n){return function(t,r,e){var u={};return r=x(r,e),m.each(t,function(e,i){var o=r(e,i,t);n(u,e,o)}),u}};m.groupBy=F(function(n,t,r){m.has(n,r)?n[r].push(t):n[r]=[t]}),m.indexBy=F(function(n,t,r){n[r]=t}),m.countBy=F(function(n,t,r){m.has(n,r)?n[r]++:n[r]=1}),m.toArray=function(n){return n?m.isArray(n)?l.call(n):k(n)?m.map(n,m.identity):m.values(n):[]},m.size=function(n){return null==n?0:k(n)?n.length:m.keys(n).length},m.partition=function(n,t,r){t=x(t,r);var e=[],u=[];return m.each(n,function(n,r,i){(t(n,r,i)?e:u).push(n)}),[e,u]},m.first=m.head=m.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:m.initial(n,n.length-t)},m.initial=function(n,t,r){return l.call(n,0,Math.max(0,n.length-(null==t||r?1:t)))},m.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:m.rest(n,Math.max(0,n.length-t))},m.rest=m.tail=m.drop=function(n,t,r){return l.call(n,null==t||r?1:t)},m.compact=function(n){return m.filter(n,m.identity)};var S=function(n,t,r,e){for(var u=[],i=0,o=e||0,a=O(n);a>o;o++){var c=n[o];if(k(c)&&(m.isArray(c)||m.isArguments(c))){t||(c=S(c,t,r));var f=0,l=c.length;for(u.length+=l;l>f;)u[i++]=c[f++]}else r||(u[i++]=c)}return u};m.flatten=function(n,t){return S(n,t,!1)},m.without=function(n){return m.difference(n,l.call(arguments,1))},m.uniq=m.unique=function(n,t,r,e){m.isBoolean(t)||(e=r,r=t,t=!1),null!=r&&(r=x(r,e));for(var u=[],i=[],o=0,a=O(n);a>o;o++){var c=n[o],f=r?r(c,o,n):c;t?(o&&i===f||u.push(c),i=f):r?m.contains(i,f)||(i.push(f),u.push(c)):m.contains(u,c)||u.push(c)}return u},m.union=function(){return m.uniq(S(arguments,!0,!0))},m.intersection=function(n){for(var t=[],r=arguments.length,e=0,u=O(n);u>e;e++){var i=n[e];if(!m.contains(t,i)){for(var o=1;r>o&&m.contains(arguments[o],i);o++);o===r&&t.push(i)}}return t},m.difference=function(n){var t=S(arguments,!0,!0,1);return m.filter(n,function(n){return!m.contains(t,n)})},m.zip=function(){return m.unzip(arguments)},m.unzip=function(n){for(var t=n&&m.max(n,O).length||0,r=Array(t),e=0;t>e;e++)r[e]=m.pluck(n,e);return r},m.object=function(n,t){for(var r={},e=0,u=O(n);u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},m.findIndex=t(1),m.findLastIndex=t(-1),m.sortedIndex=function(n,t,r,e){r=x(r,e,1);for(var u=r(t),i=0,o=O(n);o>i;){var a=Math.floor((i+o)/2);r(n[a])i;i++,n+=r)u[i]=n;return u};var E=function(n,t,r,e,u){if(!(e instanceof t))return n.apply(r,u);var i=j(n.prototype),o=n.apply(i,u);return m.isObject(o)?o:i};m.bind=function(n,t){if(g&&n.bind===g)return g.apply(n,l.call(arguments,1));if(!m.isFunction(n))throw new TypeError("Bind must be called on a function");var r=l.call(arguments,2),e=function(){return E(n,e,t,this,r.concat(l.call(arguments)))};return e},m.partial=function(n){var t=l.call(arguments,1),r=function(){for(var e=0,u=t.length,i=Array(u),o=0;u>o;o++)i[o]=t[o]===m?arguments[e++]:t[o];for(;e=e)throw new Error("bindAll must be passed function names");for(t=1;e>t;t++)r=arguments[t],n[r]=m.bind(n[r],n);return n},m.memoize=function(n,t){var r=function(e){var u=r.cache,i=""+(t?t.apply(this,arguments):e);return m.has(u,i)||(u[i]=n.apply(this,arguments)),u[i]};return r.cache={},r},m.delay=function(n,t){var r=l.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},m.defer=m.partial(m.delay,m,1),m.throttle=function(n,t,r){var e,u,i,o=null,a=0;r||(r={});var c=function(){a=r.leading===!1?0:m.now(),o=null,i=n.apply(e,u),o||(e=u=null)};return function(){var f=m.now();a||r.leading!==!1||(a=f);var l=t-(f-a);return e=this,u=arguments,0>=l||l>t?(o&&(clearTimeout(o),o=null),a=f,i=n.apply(e,u),o||(e=u=null)):o||r.trailing===!1||(o=setTimeout(c,l)),i}},m.debounce=function(n,t,r){var e,u,i,o,a,c=function(){var f=m.now()-o;t>f&&f>=0?e=setTimeout(c,t-f):(e=null,r||(a=n.apply(i,u),e||(i=u=null)))};return function(){i=this,u=arguments,o=m.now();var f=r&&!e;return e||(e=setTimeout(c,t)),f&&(a=n.apply(i,u),i=u=null),a}},m.wrap=function(n,t){return m.partial(t,n)},m.negate=function(n){return function(){return!n.apply(this,arguments)}},m.compose=function(){var n=arguments,t=n.length-1;return function(){for(var r=t,e=n[t].apply(this,arguments);r--;)e=n[r].call(this,e);return e}},m.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},m.before=function(n,t){var r;return function(){return--n>0&&(r=t.apply(this,arguments)),1>=n&&(t=null),r}},m.once=m.partial(m.before,2);var M=!{toString:null}.propertyIsEnumerable("toString"),I=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];m.keys=function(n){if(!m.isObject(n))return[];if(v)return v(n);var t=[];for(var r in n)m.has(n,r)&&t.push(r);return M&&e(n,t),t},m.allKeys=function(n){if(!m.isObject(n))return[];var t=[];for(var r in n)t.push(r);return M&&e(n,t),t},m.values=function(n){for(var t=m.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},m.mapObject=function(n,t,r){t=x(t,r);for(var e,u=m.keys(n),i=u.length,o={},a=0;i>a;a++)e=u[a],o[e]=t(n[e],e,n);return o},m.pairs=function(n){for(var t=m.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},m.invert=function(n){for(var t={},r=m.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},m.functions=m.methods=function(n){var t=[];for(var r in n)m.isFunction(n[r])&&t.push(r);return t.sort()},m.extend=_(m.allKeys),m.extendOwn=m.assign=_(m.keys),m.findKey=function(n,t,r){t=x(t,r);for(var e,u=m.keys(n),i=0,o=u.length;o>i;i++)if(e=u[i],t(n[e],e,n))return e},m.pick=function(n,t,r){var e,u,i={},o=n;if(null==o)return i;m.isFunction(t)?(u=m.allKeys(o),e=b(t,r)):(u=S(arguments,!1,!1,1),e=function(n,t,r){return t in r},o=Object(o));for(var a=0,c=u.length;c>a;a++){var f=u[a],l=o[f];e(l,f,o)&&(i[f]=l)}return i},m.omit=function(n,t,r){if(m.isFunction(t))t=m.negate(t);else{var e=m.map(S(arguments,!1,!1,1),String);t=function(n,t){return!m.contains(e,t)}}return m.pick(n,t,r)},m.defaults=_(m.allKeys,!0),m.create=function(n,t){var r=j(n);return t&&m.extendOwn(r,t),r},m.clone=function(n){return m.isObject(n)?m.isArray(n)?n.slice():m.extend({},n):n},m.tap=function(n,t){return t(n),n},m.isMatch=function(n,t){var r=m.keys(t),e=r.length;if(null==n)return!e;for(var u=Object(n),i=0;e>i;i++){var o=r[i];if(t[o]!==u[o]||!(o in u))return!1}return!0};var N=function(n,t,r,e){if(n===t)return 0!==n||1/n===1/t;if(null==n||null==t)return n===t;n instanceof m&&(n=n._wrapped),t instanceof m&&(t=t._wrapped);var u=s.call(n);if(u!==s.call(t))return!1;switch(u){case"[object RegExp]":case"[object String]":return""+n==""+t;case"[object Number]":return+n!==+n?+t!==+t:0===+n?1/+n===1/t:+n===+t;case"[object Date]":case"[object Boolean]":return+n===+t}var i="[object Array]"===u;if(!i){if("object"!=typeof n||"object"!=typeof t)return!1;var o=n.constructor,a=t.constructor;if(o!==a&&!(m.isFunction(o)&&o instanceof o&&m.isFunction(a)&&a instanceof a)&&"constructor"in n&&"constructor"in t)return!1}r=r||[],e=e||[];for(var c=r.length;c--;)if(r[c]===n)return e[c]===t;if(r.push(n),e.push(t),i){if(c=n.length,c!==t.length)return!1;for(;c--;)if(!N(n[c],t[c],r,e))return!1}else{var f,l=m.keys(n);if(c=l.length,m.keys(t).length!==c)return!1;for(;c--;)if(f=l[c],!m.has(t,f)||!N(n[f],t[f],r,e))return!1}return r.pop(),e.pop(),!0};m.isEqual=function(n,t){return N(n,t)},m.isEmpty=function(n){return null==n?!0:k(n)&&(m.isArray(n)||m.isString(n)||m.isArguments(n))?0===n.length:0===m.keys(n).length},m.isElement=function(n){return!(!n||1!==n.nodeType)},m.isArray=h||function(n){return"[object Array]"===s.call(n)},m.isObject=function(n){var t=typeof n;return"function"===t||"object"===t&&!!n},m.each(["Arguments","Function","String","Number","Date","RegExp","Error"],function(n){m["is"+n]=function(t){return s.call(t)==="[object "+n+"]"}}),m.isArguments(arguments)||(m.isArguments=function(n){return m.has(n,"callee")}),"function"!=typeof/./&&"object"!=typeof Int8Array&&(m.isFunction=function(n){return"function"==typeof n||!1}),m.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},m.isNaN=function(n){return m.isNumber(n)&&n!==+n},m.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"===s.call(n)},m.isNull=function(n){return null===n},m.isUndefined=function(n){return n===void 0},m.has=function(n,t){return null!=n&&p.call(n,t)},m.noConflict=function(){return u._=i,this},m.identity=function(n){return n},m.constant=function(n){return function(){return n}},m.noop=function(){},m.property=w,m.propertyOf=function(n){return null==n?function(){}:function(t){return n[t]}},m.matcher=m.matches=function(n){return n=m.extendOwn({},n),function(t){return m.isMatch(t,n)}},m.times=function(n,t,r){var e=Array(Math.max(0,n));t=b(t,r,1);for(var u=0;n>u;u++)e[u]=t(u);return e},m.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))},m.now=Date.now||function(){return(new Date).getTime()};var B={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},T=m.invert(B),R=function(n){var t=function(t){return n[t]},r="(?:"+m.keys(n).join("|")+")",e=RegExp(r),u=RegExp(r,"g");return function(n){return n=null==n?"":""+n,e.test(n)?n.replace(u,t):n}};m.escape=R(B),m.unescape=R(T),m.result=function(n,t,r){var e=null==n?void 0:n[t];return e===void 0&&(e=r),m.isFunction(e)?e.call(n):e};var q=0;m.uniqueId=function(n){var t=++q+"";return n?n+t:t},m.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var K=/(.)^/,z={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\u2028|\u2029/g,L=function(n){return"\\"+z[n]};m.template=function(n,t,r){!t&&r&&(t=r),t=m.defaults({},t,m.templateSettings);var e=RegExp([(t.escape||K).source,(t.interpolate||K).source,(t.evaluate||K).source].join("|")+"|$","g"),u=0,i="__p+='";n.replace(e,function(t,r,e,o,a){return i+=n.slice(u,a).replace(D,L),u=a+t.length,r?i+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'":e?i+="'+\n((__t=("+e+"))==null?'':__t)+\n'":o&&(i+="';\n"+o+"\n__p+='"),t}),i+="';\n",t.variable||(i="with(obj||{}){\n"+i+"}\n"),i="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+i+"return __p;\n";try{var o=new Function(t.variable||"obj","_",i)}catch(a){throw a.source=i,a}var c=function(n){return o.call(this,n,m)},f=t.variable||"obj";return c.source="function("+f+"){\n"+i+"}",c},m.chain=function(n){var t=m(n);return t._chain=!0,t};var P=function(n,t){return n._chain?m(t).chain():t};m.mixin=function(n){m.each(m.functions(n),function(t){var r=m[t]=n[t];m.prototype[t]=function(){var n=[this._wrapped];return f.apply(n,arguments),P(this,r.apply(m,n))}})},m.mixin(m),m.each(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=o[n];m.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!==n&&"splice"!==n||0!==r.length||delete r[0],P(this,r)}}),m.each(["concat","join","slice"],function(n){var t=o[n];m.prototype[n]=function(){return P(this,t.apply(this._wrapped,arguments))}}),m.prototype.value=function(){return this._wrapped},m.prototype.valueOf=m.prototype.toJSON=m.prototype.value,m.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return m})}).call(this);
-//# sourceMappingURL=underscore-min.map
\ No newline at end of file
diff --git a/merlin/static/merlin/js/lib/underscore.js b/merlin/static/merlin/js/lib/underscore.js
deleted file mode 100644
index b29332f..0000000
--- a/merlin/static/merlin/js/lib/underscore.js
+++ /dev/null
@@ -1,1548 +0,0 @@
-// Underscore.js 1.8.3
-// http://underscorejs.org
-// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
-// Underscore may be freely distributed under the MIT license.
-
-(function() {
-
- // Baseline setup
- // --------------
-
- // Establish the root object, `window` in the browser, or `exports` on the server.
- var root = this;
-
- // Save the previous value of the `_` variable.
- var previousUnderscore = root._;
-
- // Save bytes in the minified (but not gzipped) version:
- var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;
-
- // Create quick reference variables for speed access to core prototypes.
- var
- push = ArrayProto.push,
- slice = ArrayProto.slice,
- toString = ObjProto.toString,
- hasOwnProperty = ObjProto.hasOwnProperty;
-
- // All **ECMAScript 5** native function implementations that we hope to use
- // are declared here.
- var
- nativeIsArray = Array.isArray,
- nativeKeys = Object.keys,
- nativeBind = FuncProto.bind,
- nativeCreate = Object.create;
-
- // Naked function reference for surrogate-prototype-swapping.
- var Ctor = function(){};
-
- // Create a safe reference to the Underscore object for use below.
- var _ = function(obj) {
- if (obj instanceof _) return obj;
- if (!(this instanceof _)) return new _(obj);
- this._wrapped = obj;
- };
-
- // Export the Underscore object for **Node.js**, with
- // backwards-compatibility for the old `require()` API. If we're in
- // the browser, add `_` as a global object.
- if (typeof exports !== 'undefined') {
- if (typeof module !== 'undefined' && module.exports) {
- exports = module.exports = _;
- }
- exports._ = _;
- } else {
- root._ = _;
- }
-
- // Current version.
- _.VERSION = '1.8.3';
-
- // Internal function that returns an efficient (for current engines) version
- // of the passed-in callback, to be repeatedly applied in other Underscore
- // functions.
- var optimizeCb = function(func, context, argCount) {
- if (context === void 0) return func;
- switch (argCount == null ? 3 : argCount) {
- case 1: return function(value) {
- return func.call(context, value);
- };
- case 2: return function(value, other) {
- return func.call(context, value, other);
- };
- case 3: return function(value, index, collection) {
- return func.call(context, value, index, collection);
- };
- case 4: return function(accumulator, value, index, collection) {
- return func.call(context, accumulator, value, index, collection);
- };
- }
- return function() {
- return func.apply(context, arguments);
- };
- };
-
- // A mostly-internal function to generate callbacks that can be applied
- // to each element in a collection, returning the desired result — either
- // identity, an arbitrary callback, a property matcher, or a property accessor.
- var cb = function(value, context, argCount) {
- if (value == null) return _.identity;
- if (_.isFunction(value)) return optimizeCb(value, context, argCount);
- if (_.isObject(value)) return _.matcher(value);
- return _.property(value);
- };
- _.iteratee = function(value, context) {
- return cb(value, context, Infinity);
- };
-
- // An internal function for creating assigner functions.
- var createAssigner = function(keysFunc, undefinedOnly) {
- return function(obj) {
- var length = arguments.length;
- if (length < 2 || obj == null) return obj;
- for (var index = 1; index < length; index++) {
- var source = arguments[index],
- keys = keysFunc(source),
- l = keys.length;
- for (var i = 0; i < l; i++) {
- var key = keys[i];
- if (!undefinedOnly || obj[key] === void 0) obj[key] = source[key];
- }
- }
- return obj;
- };
- };
-
- // An internal function for creating a new object that inherits from another.
- var baseCreate = function(prototype) {
- if (!_.isObject(prototype)) return {};
- if (nativeCreate) return nativeCreate(prototype);
- Ctor.prototype = prototype;
- var result = new Ctor;
- Ctor.prototype = null;
- return result;
- };
-
- var property = function(key) {
- return function(obj) {
- return obj == null ? void 0 : obj[key];
- };
- };
-
- // Helper for collection methods to determine whether a collection
- // should be iterated as an array or as an object
- // Related: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength
- // Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094
- var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1;
- var getLength = property('length');
- var isArrayLike = function(collection) {
- var length = getLength(collection);
- return typeof length == 'number' && length >= 0 && length <= MAX_ARRAY_INDEX;
- };
-
- // Collection Functions
- // --------------------
-
- // The cornerstone, an `each` implementation, aka `forEach`.
- // Handles raw objects in addition to array-likes. Treats all
- // sparse array-likes as if they were dense.
- _.each = _.forEach = function(obj, iteratee, context) {
- iteratee = optimizeCb(iteratee, context);
- var i, length;
- if (isArrayLike(obj)) {
- for (i = 0, length = obj.length; i < length; i++) {
- iteratee(obj[i], i, obj);
- }
- } else {
- var keys = _.keys(obj);
- for (i = 0, length = keys.length; i < length; i++) {
- iteratee(obj[keys[i]], keys[i], obj);
- }
- }
- return obj;
- };
-
- // Return the results of applying the iteratee to each element.
- _.map = _.collect = function(obj, iteratee, context) {
- iteratee = cb(iteratee, context);
- var keys = !isArrayLike(obj) && _.keys(obj),
- length = (keys || obj).length,
- results = Array(length);
- for (var index = 0; index < length; index++) {
- var currentKey = keys ? keys[index] : index;
- results[index] = iteratee(obj[currentKey], currentKey, obj);
- }
- return results;
- };
-
- // Create a reducing function iterating left or right.
- function createReduce(dir) {
- // Optimized iterator function as using arguments.length
- // in the main function will deoptimize the, see #1991.
- function iterator(obj, iteratee, memo, keys, index, length) {
- for (; index >= 0 && index < length; index += dir) {
- var currentKey = keys ? keys[index] : index;
- memo = iteratee(memo, obj[currentKey], currentKey, obj);
- }
- return memo;
- }
-
- return function(obj, iteratee, memo, context) {
- iteratee = optimizeCb(iteratee, context, 4);
- var keys = !isArrayLike(obj) && _.keys(obj),
- length = (keys || obj).length,
- index = dir > 0 ? 0 : length - 1;
- // Determine the initial value if none is provided.
- if (arguments.length < 3) {
- memo = obj[keys ? keys[index] : index];
- index += dir;
- }
- return iterator(obj, iteratee, memo, keys, index, length);
- };
- }
-
- // **Reduce** builds up a single result from a list of values, aka `inject`,
- // or `foldl`.
- _.reduce = _.foldl = _.inject = createReduce(1);
-
- // The right-associative version of reduce, also known as `foldr`.
- _.reduceRight = _.foldr = createReduce(-1);
-
- // Return the first value which passes a truth test. Aliased as `detect`.
- _.find = _.detect = function(obj, predicate, context) {
- var key;
- if (isArrayLike(obj)) {
- key = _.findIndex(obj, predicate, context);
- } else {
- key = _.findKey(obj, predicate, context);
- }
- if (key !== void 0 && key !== -1) return obj[key];
- };
-
- // Return all the elements that pass a truth test.
- // Aliased as `select`.
- _.filter = _.select = function(obj, predicate, context) {
- var results = [];
- predicate = cb(predicate, context);
- _.each(obj, function(value, index, list) {
- if (predicate(value, index, list)) results.push(value);
- });
- return results;
- };
-
- // Return all the elements for which a truth test fails.
- _.reject = function(obj, predicate, context) {
- return _.filter(obj, _.negate(cb(predicate)), context);
- };
-
- // Determine whether all of the elements match a truth test.
- // Aliased as `all`.
- _.every = _.all = function(obj, predicate, context) {
- predicate = cb(predicate, context);
- var keys = !isArrayLike(obj) && _.keys(obj),
- length = (keys || obj).length;
- for (var index = 0; index < length; index++) {
- var currentKey = keys ? keys[index] : index;
- if (!predicate(obj[currentKey], currentKey, obj)) return false;
- }
- return true;
- };
-
- // Determine if at least one element in the object matches a truth test.
- // Aliased as `any`.
- _.some = _.any = function(obj, predicate, context) {
- predicate = cb(predicate, context);
- var keys = !isArrayLike(obj) && _.keys(obj),
- length = (keys || obj).length;
- for (var index = 0; index < length; index++) {
- var currentKey = keys ? keys[index] : index;
- if (predicate(obj[currentKey], currentKey, obj)) return true;
- }
- return false;
- };
-
- // Determine if the array or object contains a given item (using `===`).
- // Aliased as `includes` and `include`.
- _.contains = _.includes = _.include = function(obj, item, fromIndex, guard) {
- if (!isArrayLike(obj)) obj = _.values(obj);
- if (typeof fromIndex != 'number' || guard) fromIndex = 0;
- return _.indexOf(obj, item, fromIndex) >= 0;
- };
-
- // Invoke a method (with arguments) on every item in a collection.
- _.invoke = function(obj, method) {
- var args = slice.call(arguments, 2);
- var isFunc = _.isFunction(method);
- return _.map(obj, function(value) {
- var func = isFunc ? method : value[method];
- return func == null ? func : func.apply(value, args);
- });
- };
-
- // Convenience version of a common use case of `map`: fetching a property.
- _.pluck = function(obj, key) {
- return _.map(obj, _.property(key));
- };
-
- // Convenience version of a common use case of `filter`: selecting only objects
- // containing specific `key:value` pairs.
- _.where = function(obj, attrs) {
- return _.filter(obj, _.matcher(attrs));
- };
-
- // Convenience version of a common use case of `find`: getting the first object
- // containing specific `key:value` pairs.
- _.findWhere = function(obj, attrs) {
- return _.find(obj, _.matcher(attrs));
- };
-
- // Return the maximum element (or element-based computation).
- _.max = function(obj, iteratee, context) {
- var result = -Infinity, lastComputed = -Infinity,
- value, computed;
- if (iteratee == null && obj != null) {
- obj = isArrayLike(obj) ? obj : _.values(obj);
- for (var i = 0, length = obj.length; i < length; i++) {
- value = obj[i];
- if (value > result) {
- result = value;
- }
- }
- } else {
- iteratee = cb(iteratee, context);
- _.each(obj, function(value, index, list) {
- computed = iteratee(value, index, list);
- if (computed > lastComputed || computed === -Infinity && result === -Infinity) {
- result = value;
- lastComputed = computed;
- }
- });
- }
- return result;
- };
-
- // Return the minimum element (or element-based computation).
- _.min = function(obj, iteratee, context) {
- var result = Infinity, lastComputed = Infinity,
- value, computed;
- if (iteratee == null && obj != null) {
- obj = isArrayLike(obj) ? obj : _.values(obj);
- for (var i = 0, length = obj.length; i < length; i++) {
- value = obj[i];
- if (value < result) {
- result = value;
- }
- }
- } else {
- iteratee = cb(iteratee, context);
- _.each(obj, function(value, index, list) {
- computed = iteratee(value, index, list);
- if (computed < lastComputed || computed === Infinity && result === Infinity) {
- result = value;
- lastComputed = computed;
- }
- });
- }
- return result;
- };
-
- // Shuffle a collection, using the modern version of the
- // [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle).
- _.shuffle = function(obj) {
- var set = isArrayLike(obj) ? obj : _.values(obj);
- var length = set.length;
- var shuffled = Array(length);
- for (var index = 0, rand; index < length; index++) {
- rand = _.random(0, index);
- if (rand !== index) shuffled[index] = shuffled[rand];
- shuffled[rand] = set[index];
- }
- return shuffled;
- };
-
- // Sample **n** random values from a collection.
- // If **n** is not specified, returns a single random element.
- // The internal `guard` argument allows it to work with `map`.
- _.sample = function(obj, n, guard) {
- if (n == null || guard) {
- if (!isArrayLike(obj)) obj = _.values(obj);
- return obj[_.random(obj.length - 1)];
- }
- return _.shuffle(obj).slice(0, Math.max(0, n));
- };
-
- // Sort the object's values by a criterion produced by an iteratee.
- _.sortBy = function(obj, iteratee, context) {
- iteratee = cb(iteratee, context);
- return _.pluck(_.map(obj, function(value, index, list) {
- return {
- value: value,
- index: index,
- criteria: iteratee(value, index, list)
- };
- }).sort(function(left, right) {
- var a = left.criteria;
- var b = right.criteria;
- if (a !== b) {
- if (a > b || a === void 0) return 1;
- if (a < b || b === void 0) return -1;
- }
- return left.index - right.index;
- }), 'value');
- };
-
- // An internal function used for aggregate "group by" operations.
- var group = function(behavior) {
- return function(obj, iteratee, context) {
- var result = {};
- iteratee = cb(iteratee, context);
- _.each(obj, function(value, index) {
- var key = iteratee(value, index, obj);
- behavior(result, value, key);
- });
- return result;
- };
- };
-
- // Groups the object's values by a criterion. Pass either a string attribute
- // to group by, or a function that returns the criterion.
- _.groupBy = group(function(result, value, key) {
- if (_.has(result, key)) result[key].push(value); else result[key] = [value];
- });
-
- // Indexes the object's values by a criterion, similar to `groupBy`, but for
- // when you know that your index values will be unique.
- _.indexBy = group(function(result, value, key) {
- result[key] = value;
- });
-
- // Counts instances of an object that group by a certain criterion. Pass
- // either a string attribute to count by, or a function that returns the
- // criterion.
- _.countBy = group(function(result, value, key) {
- if (_.has(result, key)) result[key]++; else result[key] = 1;
- });
-
- // Safely create a real, live array from anything iterable.
- _.toArray = function(obj) {
- if (!obj) return [];
- if (_.isArray(obj)) return slice.call(obj);
- if (isArrayLike(obj)) return _.map(obj, _.identity);
- return _.values(obj);
- };
-
- // Return the number of elements in an object.
- _.size = function(obj) {
- if (obj == null) return 0;
- return isArrayLike(obj) ? obj.length : _.keys(obj).length;
- };
-
- // Split a collection into two arrays: one whose elements all satisfy the given
- // predicate, and one whose elements all do not satisfy the predicate.
- _.partition = function(obj, predicate, context) {
- predicate = cb(predicate, context);
- var pass = [], fail = [];
- _.each(obj, function(value, key, obj) {
- (predicate(value, key, obj) ? pass : fail).push(value);
- });
- return [pass, fail];
- };
-
- // Array Functions
- // ---------------
-
- // Get the first element of an array. Passing **n** will return the first N
- // values in the array. Aliased as `head` and `take`. The **guard** check
- // allows it to work with `_.map`.
- _.first = _.head = _.take = function(array, n, guard) {
- if (array == null) return void 0;
- if (n == null || guard) return array[0];
- return _.initial(array, array.length - n);
- };
-
- // Returns everything but the last entry of the array. Especially useful on
- // the arguments object. Passing **n** will return all the values in
- // the array, excluding the last N.
- _.initial = function(array, n, guard) {
- return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n)));
- };
-
- // Get the last element of an array. Passing **n** will return the last N
- // values in the array.
- _.last = function(array, n, guard) {
- if (array == null) return void 0;
- if (n == null || guard) return array[array.length - 1];
- return _.rest(array, Math.max(0, array.length - n));
- };
-
- // Returns everything but the first entry of the array. Aliased as `tail` and `drop`.
- // Especially useful on the arguments object. Passing an **n** will return
- // the rest N values in the array.
- _.rest = _.tail = _.drop = function(array, n, guard) {
- return slice.call(array, n == null || guard ? 1 : n);
- };
-
- // Trim out all falsy values from an array.
- _.compact = function(array) {
- return _.filter(array, _.identity);
- };
-
- // Internal implementation of a recursive `flatten` function.
- var flatten = function(input, shallow, strict, startIndex) {
- var output = [], idx = 0;
- for (var i = startIndex || 0, length = getLength(input); i < length; i++) {
- var value = input[i];
- if (isArrayLike(value) && (_.isArray(value) || _.isArguments(value))) {
- //flatten current level of array or arguments object
- if (!shallow) value = flatten(value, shallow, strict);
- var j = 0, len = value.length;
- output.length += len;
- while (j < len) {
- output[idx++] = value[j++];
- }
- } else if (!strict) {
- output[idx++] = value;
- }
- }
- return output;
- };
-
- // Flatten out an array, either recursively (by default), or just one level.
- _.flatten = function(array, shallow) {
- return flatten(array, shallow, false);
- };
-
- // Return a version of the array that does not contain the specified value(s).
- _.without = function(array) {
- return _.difference(array, slice.call(arguments, 1));
- };
-
- // Produce a duplicate-free version of the array. If the array has already
- // been sorted, you have the option of using a faster algorithm.
- // Aliased as `unique`.
- _.uniq = _.unique = function(array, isSorted, iteratee, context) {
- if (!_.isBoolean(isSorted)) {
- context = iteratee;
- iteratee = isSorted;
- isSorted = false;
- }
- if (iteratee != null) iteratee = cb(iteratee, context);
- var result = [];
- var seen = [];
- for (var i = 0, length = getLength(array); i < length; i++) {
- var value = array[i],
- computed = iteratee ? iteratee(value, i, array) : value;
- if (isSorted) {
- if (!i || seen !== computed) result.push(value);
- seen = computed;
- } else if (iteratee) {
- if (!_.contains(seen, computed)) {
- seen.push(computed);
- result.push(value);
- }
- } else if (!_.contains(result, value)) {
- result.push(value);
- }
- }
- return result;
- };
-
- // Produce an array that contains the union: each distinct element from all of
- // the passed-in arrays.
- _.union = function() {
- return _.uniq(flatten(arguments, true, true));
- };
-
- // Produce an array that contains every item shared between all the
- // passed-in arrays.
- _.intersection = function(array) {
- var result = [];
- var argsLength = arguments.length;
- for (var i = 0, length = getLength(array); i < length; i++) {
- var item = array[i];
- if (_.contains(result, item)) continue;
- for (var j = 1; j < argsLength; j++) {
- if (!_.contains(arguments[j], item)) break;
- }
- if (j === argsLength) result.push(item);
- }
- return result;
- };
-
- // Take the difference between one array and a number of other arrays.
- // Only the elements present in just the first array will remain.
- _.difference = function(array) {
- var rest = flatten(arguments, true, true, 1);
- return _.filter(array, function(value){
- return !_.contains(rest, value);
- });
- };
-
- // Zip together multiple lists into a single array -- elements that share
- // an index go together.
- _.zip = function() {
- return _.unzip(arguments);
- };
-
- // Complement of _.zip. Unzip accepts an array of arrays and groups
- // each array's elements on shared indices
- _.unzip = function(array) {
- var length = array && _.max(array, getLength).length || 0;
- var result = Array(length);
-
- for (var index = 0; index < length; index++) {
- result[index] = _.pluck(array, index);
- }
- return result;
- };
-
- // Converts lists into objects. Pass either a single array of `[key, value]`
- // pairs, or two parallel arrays of the same length -- one of keys, and one of
- // the corresponding values.
- _.object = function(list, values) {
- var result = {};
- for (var i = 0, length = getLength(list); i < length; i++) {
- if (values) {
- result[list[i]] = values[i];
- } else {
- result[list[i][0]] = list[i][1];
- }
- }
- return result;
- };
-
- // Generator function to create the findIndex and findLastIndex functions
- function createPredicateIndexFinder(dir) {
- return function(array, predicate, context) {
- predicate = cb(predicate, context);
- var length = getLength(array);
- var index = dir > 0 ? 0 : length - 1;
- for (; index >= 0 && index < length; index += dir) {
- if (predicate(array[index], index, array)) return index;
- }
- return -1;
- };
- }
-
- // Returns the first index on an array-like that passes a predicate test
- _.findIndex = createPredicateIndexFinder(1);
- _.findLastIndex = createPredicateIndexFinder(-1);
-
- // Use a comparator function to figure out the smallest index at which
- // an object should be inserted so as to maintain order. Uses binary search.
- _.sortedIndex = function(array, obj, iteratee, context) {
- iteratee = cb(iteratee, context, 1);
- var value = iteratee(obj);
- var low = 0, high = getLength(array);
- while (low < high) {
- var mid = Math.floor((low + high) / 2);
- if (iteratee(array[mid]) < value) low = mid + 1; else high = mid;
- }
- return low;
- };
-
- // Generator function to create the indexOf and lastIndexOf functions
- function createIndexFinder(dir, predicateFind, sortedIndex) {
- return function(array, item, idx) {
- var i = 0, length = getLength(array);
- if (typeof idx == 'number') {
- if (dir > 0) {
- i = idx >= 0 ? idx : Math.max(idx + length, i);
- } else {
- length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1;
- }
- } else if (sortedIndex && idx && length) {
- idx = sortedIndex(array, item);
- return array[idx] === item ? idx : -1;
- }
- if (item !== item) {
- idx = predicateFind(slice.call(array, i, length), _.isNaN);
- return idx >= 0 ? idx + i : -1;
- }
- for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) {
- if (array[idx] === item) return idx;
- }
- return -1;
- };
- }
-
- // Return the position of the first occurrence of an item in an array,
- // or -1 if the item is not included in the array.
- // If the array is large and already in sort order, pass `true`
- // for **isSorted** to use binary search.
- _.indexOf = createIndexFinder(1, _.findIndex, _.sortedIndex);
- _.lastIndexOf = createIndexFinder(-1, _.findLastIndex);
-
- // Generate an integer Array containing an arithmetic progression. A port of
- // the native Python `range()` function. See
- // [the Python documentation](http://docs.python.org/library/functions.html#range).
- _.range = function(start, stop, step) {
- if (stop == null) {
- stop = start || 0;
- start = 0;
- }
- step = step || 1;
-
- var length = Math.max(Math.ceil((stop - start) / step), 0);
- var range = Array(length);
-
- for (var idx = 0; idx < length; idx++, start += step) {
- range[idx] = start;
- }
-
- return range;
- };
-
- // Function (ahem) Functions
- // ------------------
-
- // Determines whether to execute a function as a constructor
- // or a normal function with the provided arguments
- var executeBound = function(sourceFunc, boundFunc, context, callingContext, args) {
- if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args);
- var self = baseCreate(sourceFunc.prototype);
- var result = sourceFunc.apply(self, args);
- if (_.isObject(result)) return result;
- return self;
- };
-
- // Create a function bound to a given object (assigning `this`, and arguments,
- // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if
- // available.
- _.bind = function(func, context) {
- if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
- if (!_.isFunction(func)) throw new TypeError('Bind must be called on a function');
- var args = slice.call(arguments, 2);
- var bound = function() {
- return executeBound(func, bound, context, this, args.concat(slice.call(arguments)));
- };
- return bound;
- };
-
- // Partially apply a function by creating a version that has had some of its
- // arguments pre-filled, without changing its dynamic `this` context. _ acts
- // as a placeholder, allowing any combination of arguments to be pre-filled.
- _.partial = function(func) {
- var boundArgs = slice.call(arguments, 1);
- var bound = function() {
- var position = 0, length = boundArgs.length;
- var args = Array(length);
- for (var i = 0; i < length; i++) {
- args[i] = boundArgs[i] === _ ? arguments[position++] : boundArgs[i];
- }
- while (position < arguments.length) args.push(arguments[position++]);
- return executeBound(func, bound, this, this, args);
- };
- return bound;
- };
-
- // Bind a number of an object's methods to that object. Remaining arguments
- // are the method names to be bound. Useful for ensuring that all callbacks
- // defined on an object belong to it.
- _.bindAll = function(obj) {
- var i, length = arguments.length, key;
- if (length <= 1) throw new Error('bindAll must be passed function names');
- for (i = 1; i < length; i++) {
- key = arguments[i];
- obj[key] = _.bind(obj[key], obj);
- }
- return obj;
- };
-
- // Memoize an expensive function by storing its results.
- _.memoize = function(func, hasher) {
- var memoize = function(key) {
- var cache = memoize.cache;
- var address = '' + (hasher ? hasher.apply(this, arguments) : key);
- if (!_.has(cache, address)) cache[address] = func.apply(this, arguments);
- return cache[address];
- };
- memoize.cache = {};
- return memoize;
- };
-
- // Delays a function for the given number of milliseconds, and then calls
- // it with the arguments supplied.
- _.delay = function(func, wait) {
- var args = slice.call(arguments, 2);
- return setTimeout(function(){
- return func.apply(null, args);
- }, wait);
- };
-
- // Defers a function, scheduling it to run after the current call stack has
- // cleared.
- _.defer = _.partial(_.delay, _, 1);
-
- // Returns a function, that, when invoked, will only be triggered at most once
- // during a given window of time. Normally, the throttled function will run
- // as much as it can, without ever going more than once per `wait` duration;
- // but if you'd like to disable the execution on the leading edge, pass
- // `{leading: false}`. To disable execution on the trailing edge, ditto.
- _.throttle = function(func, wait, options) {
- var context, args, result;
- var timeout = null;
- var previous = 0;
- if (!options) options = {};
- var later = function() {
- previous = options.leading === false ? 0 : _.now();
- timeout = null;
- result = func.apply(context, args);
- if (!timeout) context = args = null;
- };
- return function() {
- var now = _.now();
- if (!previous && options.leading === false) previous = now;
- var remaining = wait - (now - previous);
- context = this;
- args = arguments;
- if (remaining <= 0 || remaining > wait) {
- if (timeout) {
- clearTimeout(timeout);
- timeout = null;
- }
- previous = now;
- result = func.apply(context, args);
- if (!timeout) context = args = null;
- } else if (!timeout && options.trailing !== false) {
- timeout = setTimeout(later, remaining);
- }
- return result;
- };
- };
-
- // Returns a function, that, as long as it continues to be invoked, will not
- // be triggered. The function will be called after it stops being called for
- // N milliseconds. If `immediate` is passed, trigger the function on the
- // leading edge, instead of the trailing.
- _.debounce = function(func, wait, immediate) {
- var timeout, args, context, timestamp, result;
-
- var later = function() {
- var last = _.now() - timestamp;
-
- if (last < wait && last >= 0) {
- timeout = setTimeout(later, wait - last);
- } else {
- timeout = null;
- if (!immediate) {
- result = func.apply(context, args);
- if (!timeout) context = args = null;
- }
- }
- };
-
- return function() {
- context = this;
- args = arguments;
- timestamp = _.now();
- var callNow = immediate && !timeout;
- if (!timeout) timeout = setTimeout(later, wait);
- if (callNow) {
- result = func.apply(context, args);
- context = args = null;
- }
-
- return result;
- };
- };
-
- // Returns the first function passed as an argument to the second,
- // allowing you to adjust arguments, run code before and after, and
- // conditionally execute the original function.
- _.wrap = function(func, wrapper) {
- return _.partial(wrapper, func);
- };
-
- // Returns a negated version of the passed-in predicate.
- _.negate = function(predicate) {
- return function() {
- return !predicate.apply(this, arguments);
- };
- };
-
- // Returns a function that is the composition of a list of functions, each
- // consuming the return value of the function that follows.
- _.compose = function() {
- var args = arguments;
- var start = args.length - 1;
- return function() {
- var i = start;
- var result = args[start].apply(this, arguments);
- while (i--) result = args[i].call(this, result);
- return result;
- };
- };
-
- // Returns a function that will only be executed on and after the Nth call.
- _.after = function(times, func) {
- return function() {
- if (--times < 1) {
- return func.apply(this, arguments);
- }
- };
- };
-
- // Returns a function that will only be executed up to (but not including) the Nth call.
- _.before = function(times, func) {
- var memo;
- return function() {
- if (--times > 0) {
- memo = func.apply(this, arguments);
- }
- if (times <= 1) func = null;
- return memo;
- };
- };
-
- // Returns a function that will be executed at most one time, no matter how
- // often you call it. Useful for lazy initialization.
- _.once = _.partial(_.before, 2);
-
- // Object Functions
- // ----------------
-
- // Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed.
- var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString');
- var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString',
- 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString'];
-
- function collectNonEnumProps(obj, keys) {
- var nonEnumIdx = nonEnumerableProps.length;
- var constructor = obj.constructor;
- var proto = (_.isFunction(constructor) && constructor.prototype) || ObjProto;
-
- // Constructor is a special case.
- var prop = 'constructor';
- if (_.has(obj, prop) && !_.contains(keys, prop)) keys.push(prop);
-
- while (nonEnumIdx--) {
- prop = nonEnumerableProps[nonEnumIdx];
- if (prop in obj && obj[prop] !== proto[prop] && !_.contains(keys, prop)) {
- keys.push(prop);
- }
- }
- }
-
- // Retrieve the names of an object's own properties.
- // Delegates to **ECMAScript 5**'s native `Object.keys`
- _.keys = function(obj) {
- if (!_.isObject(obj)) return [];
- if (nativeKeys) return nativeKeys(obj);
- var keys = [];
- for (var key in obj) if (_.has(obj, key)) keys.push(key);
- // Ahem, IE < 9.
- if (hasEnumBug) collectNonEnumProps(obj, keys);
- return keys;
- };
-
- // Retrieve all the property names of an object.
- _.allKeys = function(obj) {
- if (!_.isObject(obj)) return [];
- var keys = [];
- for (var key in obj) keys.push(key);
- // Ahem, IE < 9.
- if (hasEnumBug) collectNonEnumProps(obj, keys);
- return keys;
- };
-
- // Retrieve the values of an object's properties.
- _.values = function(obj) {
- var keys = _.keys(obj);
- var length = keys.length;
- var values = Array(length);
- for (var i = 0; i < length; i++) {
- values[i] = obj[keys[i]];
- }
- return values;
- };
-
- // Returns the results of applying the iteratee to each element of the object
- // In contrast to _.map it returns an object
- _.mapObject = function(obj, iteratee, context) {
- iteratee = cb(iteratee, context);
- var keys = _.keys(obj),
- length = keys.length,
- results = {},
- currentKey;
- for (var index = 0; index < length; index++) {
- currentKey = keys[index];
- results[currentKey] = iteratee(obj[currentKey], currentKey, obj);
- }
- return results;
- };
-
- // Convert an object into a list of `[key, value]` pairs.
- _.pairs = function(obj) {
- var keys = _.keys(obj);
- var length = keys.length;
- var pairs = Array(length);
- for (var i = 0; i < length; i++) {
- pairs[i] = [keys[i], obj[keys[i]]];
- }
- return pairs;
- };
-
- // Invert the keys and values of an object. The values must be serializable.
- _.invert = function(obj) {
- var result = {};
- var keys = _.keys(obj);
- for (var i = 0, length = keys.length; i < length; i++) {
- result[obj[keys[i]]] = keys[i];
- }
- return result;
- };
-
- // Return a sorted list of the function names available on the object.
- // Aliased as `methods`
- _.functions = _.methods = function(obj) {
- var names = [];
- for (var key in obj) {
- if (_.isFunction(obj[key])) names.push(key);
- }
- return names.sort();
- };
-
- // Extend a given object with all the properties in passed-in object(s).
- _.extend = createAssigner(_.allKeys);
-
- // Assigns a given object with all the own properties in the passed-in object(s)
- // (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
- _.extendOwn = _.assign = createAssigner(_.keys);
-
- // Returns the first key on an object that passes a predicate test
- _.findKey = function(obj, predicate, context) {
- predicate = cb(predicate, context);
- var keys = _.keys(obj), key;
- for (var i = 0, length = keys.length; i < length; i++) {
- key = keys[i];
- if (predicate(obj[key], key, obj)) return key;
- }
- };
-
- // Return a copy of the object only containing the whitelisted properties.
- _.pick = function(object, oiteratee, context) {
- var result = {}, obj = object, iteratee, keys;
- if (obj == null) return result;
- if (_.isFunction(oiteratee)) {
- keys = _.allKeys(obj);
- iteratee = optimizeCb(oiteratee, context);
- } else {
- keys = flatten(arguments, false, false, 1);
- iteratee = function(value, key, obj) { return key in obj; };
- obj = Object(obj);
- }
- for (var i = 0, length = keys.length; i < length; i++) {
- var key = keys[i];
- var value = obj[key];
- if (iteratee(value, key, obj)) result[key] = value;
- }
- return result;
- };
-
- // Return a copy of the object without the blacklisted properties.
- _.omit = function(obj, iteratee, context) {
- if (_.isFunction(iteratee)) {
- iteratee = _.negate(iteratee);
- } else {
- var keys = _.map(flatten(arguments, false, false, 1), String);
- iteratee = function(value, key) {
- return !_.contains(keys, key);
- };
- }
- return _.pick(obj, iteratee, context);
- };
-
- // Fill in a given object with default properties.
- _.defaults = createAssigner(_.allKeys, true);
-
- // Creates an object that inherits from the given prototype object.
- // If additional properties are provided then they will be added to the
- // created object.
- _.create = function(prototype, props) {
- var result = baseCreate(prototype);
- if (props) _.extendOwn(result, props);
- return result;
- };
-
- // Create a (shallow-cloned) duplicate of an object.
- _.clone = function(obj) {
- if (!_.isObject(obj)) return obj;
- return _.isArray(obj) ? obj.slice() : _.extend({}, obj);
- };
-
- // Invokes interceptor with the obj, and then returns obj.
- // The primary purpose of this method is to "tap into" a method chain, in
- // order to perform operations on intermediate results within the chain.
- _.tap = function(obj, interceptor) {
- interceptor(obj);
- return obj;
- };
-
- // Returns whether an object has a given set of `key:value` pairs.
- _.isMatch = function(object, attrs) {
- var keys = _.keys(attrs), length = keys.length;
- if (object == null) return !length;
- var obj = Object(object);
- for (var i = 0; i < length; i++) {
- var key = keys[i];
- if (attrs[key] !== obj[key] || !(key in obj)) return false;
- }
- return true;
- };
-
-
- // Internal recursive comparison function for `isEqual`.
- var eq = function(a, b, aStack, bStack) {
- // Identical objects are equal. `0 === -0`, but they aren't identical.
- // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
- if (a === b) return a !== 0 || 1 / a === 1 / b;
- // A strict comparison is necessary because `null == undefined`.
- if (a == null || b == null) return a === b;
- // Unwrap any wrapped objects.
- if (a instanceof _) a = a._wrapped;
- if (b instanceof _) b = b._wrapped;
- // Compare `[[Class]]` names.
- var className = toString.call(a);
- if (className !== toString.call(b)) return false;
- switch (className) {
- // Strings, numbers, regular expressions, dates, and booleans are compared by value.
- case '[object RegExp]':
- // RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i')
- case '[object String]':
- // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
- // equivalent to `new String("5")`.
- return '' + a === '' + b;
- case '[object Number]':
- // `NaN`s are equivalent, but non-reflexive.
- // Object(NaN) is equivalent to NaN
- if (+a !== +a) return +b !== +b;
- // An `egal` comparison is performed for other numeric values.
- return +a === 0 ? 1 / +a === 1 / b : +a === +b;
- case '[object Date]':
- case '[object Boolean]':
- // Coerce dates and booleans to numeric primitive values. Dates are compared by their
- // millisecond representations. Note that invalid dates with millisecond representations
- // of `NaN` are not equivalent.
- return +a === +b;
- }
-
- var areArrays = className === '[object Array]';
- if (!areArrays) {
- if (typeof a != 'object' || typeof b != 'object') return false;
-
- // Objects with different constructors are not equivalent, but `Object`s or `Array`s
- // from different frames are.
- var aCtor = a.constructor, bCtor = b.constructor;
- if (aCtor !== bCtor && !(_.isFunction(aCtor) && aCtor instanceof aCtor &&
- _.isFunction(bCtor) && bCtor instanceof bCtor)
- && ('constructor' in a && 'constructor' in b)) {
- return false;
- }
- }
- // Assume equality for cyclic structures. The algorithm for detecting cyclic
- // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
-
- // Initializing stack of traversed objects.
- // It's done here since we only need them for objects and arrays comparison.
- aStack = aStack || [];
- bStack = bStack || [];
- var length = aStack.length;
- while (length--) {
- // Linear search. Performance is inversely proportional to the number of
- // unique nested structures.
- if (aStack[length] === a) return bStack[length] === b;
- }
-
- // Add the first object to the stack of traversed objects.
- aStack.push(a);
- bStack.push(b);
-
- // Recursively compare objects and arrays.
- if (areArrays) {
- // Compare array lengths to determine if a deep comparison is necessary.
- length = a.length;
- if (length !== b.length) return false;
- // Deep compare the contents, ignoring non-numeric properties.
- while (length--) {
- if (!eq(a[length], b[length], aStack, bStack)) return false;
- }
- } else {
- // Deep compare objects.
- var keys = _.keys(a), key;
- length = keys.length;
- // Ensure that both objects contain the same number of properties before comparing deep equality.
- if (_.keys(b).length !== length) return false;
- while (length--) {
- // Deep compare each member
- key = keys[length];
- if (!(_.has(b, key) && eq(a[key], b[key], aStack, bStack))) return false;
- }
- }
- // Remove the first object from the stack of traversed objects.
- aStack.pop();
- bStack.pop();
- return true;
- };
-
- // Perform a deep comparison to check if two objects are equal.
- _.isEqual = function(a, b) {
- return eq(a, b);
- };
-
- // Is a given array, string, or object empty?
- // An "empty" object has no enumerable own-properties.
- _.isEmpty = function(obj) {
- if (obj == null) return true;
- if (isArrayLike(obj) && (_.isArray(obj) || _.isString(obj) || _.isArguments(obj))) return obj.length === 0;
- return _.keys(obj).length === 0;
- };
-
- // Is a given value a DOM element?
- _.isElement = function(obj) {
- return !!(obj && obj.nodeType === 1);
- };
-
- // Is a given value an array?
- // Delegates to ECMA5's native Array.isArray
- _.isArray = nativeIsArray || function(obj) {
- return toString.call(obj) === '[object Array]';
- };
-
- // Is a given variable an object?
- _.isObject = function(obj) {
- var type = typeof obj;
- return type === 'function' || type === 'object' && !!obj;
- };
-
- // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp, isError.
- _.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error'], function(name) {
- _['is' + name] = function(obj) {
- return toString.call(obj) === '[object ' + name + ']';
- };
- });
-
- // Define a fallback version of the method in browsers (ahem, IE < 9), where
- // there isn't any inspectable "Arguments" type.
- if (!_.isArguments(arguments)) {
- _.isArguments = function(obj) {
- return _.has(obj, 'callee');
- };
- }
-
- // Optimize `isFunction` if appropriate. Work around some typeof bugs in old v8,
- // IE 11 (#1621), and in Safari 8 (#1929).
- if (typeof /./ != 'function' && typeof Int8Array != 'object') {
- _.isFunction = function(obj) {
- return typeof obj == 'function' || false;
- };
- }
-
- // Is a given object a finite number?
- _.isFinite = function(obj) {
- return isFinite(obj) && !isNaN(parseFloat(obj));
- };
-
- // Is the given value `NaN`? (NaN is the only number which does not equal itself).
- _.isNaN = function(obj) {
- return _.isNumber(obj) && obj !== +obj;
- };
-
- // Is a given value a boolean?
- _.isBoolean = function(obj) {
- return obj === true || obj === false || toString.call(obj) === '[object Boolean]';
- };
-
- // Is a given value equal to null?
- _.isNull = function(obj) {
- return obj === null;
- };
-
- // Is a given variable undefined?
- _.isUndefined = function(obj) {
- return obj === void 0;
- };
-
- // Shortcut function for checking if an object has a given property directly
- // on itself (in other words, not on a prototype).
- _.has = function(obj, key) {
- return obj != null && hasOwnProperty.call(obj, key);
- };
-
- // Utility Functions
- // -----------------
-
- // Run Underscore.js in *noConflict* mode, returning the `_` variable to its
- // previous owner. Returns a reference to the Underscore object.
- _.noConflict = function() {
- root._ = previousUnderscore;
- return this;
- };
-
- // Keep the identity function around for default iteratees.
- _.identity = function(value) {
- return value;
- };
-
- // Predicate-generating functions. Often useful outside of Underscore.
- _.constant = function(value) {
- return function() {
- return value;
- };
- };
-
- _.noop = function(){};
-
- _.property = property;
-
- // Generates a function for a given object that returns a given property.
- _.propertyOf = function(obj) {
- return obj == null ? function(){} : function(key) {
- return obj[key];
- };
- };
-
- // Returns a predicate for checking whether an object has a given set of
- // `key:value` pairs.
- _.matcher = _.matches = function(attrs) {
- attrs = _.extendOwn({}, attrs);
- return function(obj) {
- return _.isMatch(obj, attrs);
- };
- };
-
- // Run a function **n** times.
- _.times = function(n, iteratee, context) {
- var accum = Array(Math.max(0, n));
- iteratee = optimizeCb(iteratee, context, 1);
- for (var i = 0; i < n; i++) accum[i] = iteratee(i);
- return accum;
- };
-
- // Return a random integer between min and max (inclusive).
- _.random = function(min, max) {
- if (max == null) {
- max = min;
- min = 0;
- }
- return min + Math.floor(Math.random() * (max - min + 1));
- };
-
- // A (possibly faster) way to get the current timestamp as an integer.
- _.now = Date.now || function() {
- return new Date().getTime();
- };
-
- // List of HTML entities for escaping.
- var escapeMap = {
- '&': '&',
- '<': '<',
- '>': '>',
- '"': '"',
- "'": ''',
- '`': '`'
- };
- var unescapeMap = _.invert(escapeMap);
-
- // Functions for escaping and unescaping strings to/from HTML interpolation.
- var createEscaper = function(map) {
- var escaper = function(match) {
- return map[match];
- };
- // Regexes for identifying a key that needs to be escaped
- var source = '(?:' + _.keys(map).join('|') + ')';
- var testRegexp = RegExp(source);
- var replaceRegexp = RegExp(source, 'g');
- return function(string) {
- string = string == null ? '' : '' + string;
- return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;
- };
- };
- _.escape = createEscaper(escapeMap);
- _.unescape = createEscaper(unescapeMap);
-
- // If the value of the named `property` is a function then invoke it with the
- // `object` as context; otherwise, return it.
- _.result = function(object, property, fallback) {
- var value = object == null ? void 0 : object[property];
- if (value === void 0) {
- value = fallback;
- }
- return _.isFunction(value) ? value.call(object) : value;
- };
-
- // Generate a unique integer id (unique within the entire client session).
- // Useful for temporary DOM ids.
- var idCounter = 0;
- _.uniqueId = function(prefix) {
- var id = ++idCounter + '';
- return prefix ? prefix + id : id;
- };
-
- // By default, Underscore uses ERB-style template delimiters, change the
- // following template settings to use alternative delimiters.
- _.templateSettings = {
- evaluate : /<%([\s\S]+?)%>/g,
- interpolate : /<%=([\s\S]+?)%>/g,
- escape : /<%-([\s\S]+?)%>/g
- };
-
- // When customizing `templateSettings`, if you don't want to define an
- // interpolation, evaluation or escaping regex, we need one that is
- // guaranteed not to match.
- var noMatch = /(.)^/;
-
- // Certain characters need to be escaped so that they can be put into a
- // string literal.
- var escapes = {
- "'": "'",
- '\\': '\\',
- '\r': 'r',
- '\n': 'n',
- '\u2028': 'u2028',
- '\u2029': 'u2029'
- };
-
- var escaper = /\\|'|\r|\n|\u2028|\u2029/g;
-
- var escapeChar = function(match) {
- return '\\' + escapes[match];
- };
-
- // JavaScript micro-templating, similar to John Resig's implementation.
- // Underscore templating handles arbitrary delimiters, preserves whitespace,
- // and correctly escapes quotes within interpolated code.
- // NB: `oldSettings` only exists for backwards compatibility.
- _.template = function(text, settings, oldSettings) {
- if (!settings && oldSettings) settings = oldSettings;
- settings = _.defaults({}, settings, _.templateSettings);
-
- // Combine delimiters into one regular expression via alternation.
- var matcher = RegExp([
- (settings.escape || noMatch).source,
- (settings.interpolate || noMatch).source,
- (settings.evaluate || noMatch).source
- ].join('|') + '|$', 'g');
-
- // Compile the template source, escaping string literals appropriately.
- var index = 0;
- var source = "__p+='";
- text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {
- source += text.slice(index, offset).replace(escaper, escapeChar);
- index = offset + match.length;
-
- if (escape) {
- source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'";
- } else if (interpolate) {
- source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'";
- } else if (evaluate) {
- source += "';\n" + evaluate + "\n__p+='";
- }
-
- // Adobe VMs need the match returned to produce the correct offest.
- return match;
- });
- source += "';\n";
-
- // If a variable is not specified, place data values in local scope.
- if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n';
-
- source = "var __t,__p='',__j=Array.prototype.join," +
- "print=function(){__p+=__j.call(arguments,'');};\n" +
- source + 'return __p;\n';
-
- try {
- var render = new Function(settings.variable || 'obj', '_', source);
- } catch (e) {
- e.source = source;
- throw e;
- }
-
- var template = function(data) {
- return render.call(this, data, _);
- };
-
- // Provide the compiled source as a convenience for precompilation.
- var argument = settings.variable || 'obj';
- template.source = 'function(' + argument + '){\n' + source + '}';
-
- return template;
- };
-
- // Add a "chain" function. Start chaining a wrapped Underscore object.
- _.chain = function(obj) {
- var instance = _(obj);
- instance._chain = true;
- return instance;
- };
-
- // OOP
- // ---------------
- // If Underscore is called as a function, it returns a wrapped object that
- // can be used OO-style. This wrapper holds altered versions of all the
- // underscore functions. Wrapped objects may be chained.
-
- // Helper function to continue chaining intermediate results.
- var result = function(instance, obj) {
- return instance._chain ? _(obj).chain() : obj;
- };
-
- // Add your own custom functions to the Underscore object.
- _.mixin = function(obj) {
- _.each(_.functions(obj), function(name) {
- var func = _[name] = obj[name];
- _.prototype[name] = function() {
- var args = [this._wrapped];
- push.apply(args, arguments);
- return result(this, func.apply(_, args));
- };
- });
- };
-
- // Add all of the Underscore functions to the wrapper object.
- _.mixin(_);
-
- // Add all mutator Array functions to the wrapper.
- _.each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
- var method = ArrayProto[name];
- _.prototype[name] = function() {
- var obj = this._wrapped;
- method.apply(obj, arguments);
- if ((name === 'shift' || name === 'splice') && obj.length === 0) delete obj[0];
- return result(this, obj);
- };
- });
-
- // Add all accessor Array functions to the wrapper.
- _.each(['concat', 'join', 'slice'], function(name) {
- var method = ArrayProto[name];
- _.prototype[name] = function() {
- return result(this, method.apply(this._wrapped, arguments));
- };
- });
-
- // Extracts the result from a wrapped and chained object.
- _.prototype.value = function() {
- return this._wrapped;
- };
-
- // Provide unwrapping proxy for some methods used in engine operations
- // such as arithmetic and JSON stringification.
- _.prototype.valueOf = _.prototype.toJSON = _.prototype.value;
-
- _.prototype.toString = function() {
- return '' + this._wrapped;
- };
-
- // AMD registration happens at the end for compatibility with AMD loaders
- // that may not enforce next-turn semantics on modules. Even though general
- // practice for AMD registration is to be anonymous, underscore registers
- // as a named module because, like jQuery, it is a base library that is
- // popular enough to be bundled in a third party lib, but not be part of
- // an AMD load request. Those cases could generate an error when an
- // anonymous define() is called outside of a loader request.
- if (typeof define === 'function' && define.amd) {
- define('underscore', [], function() {
- return _;
- });
- }
-}.call(this));
diff --git a/merlin/static/merlin/js/libs b/merlin/static/merlin/js/libs
new file mode 120000
index 0000000..ad5885d
--- /dev/null
+++ b/merlin/static/merlin/js/libs
@@ -0,0 +1 @@
+../../../../bower_components/
\ No newline at end of file