<commit_before>/* eslint-disable */

// a butchered version of https://www.warcraftlogs.com:443/v1/zones
// only inclused the raids from Legion (showing older logs wouldn't make sense)

// TODO: Refactor this (it's kind of strange and feels misplaced)

const ZONES = [
  {
    "id": 22,
    "name": "Crucible of Storms",
    "frozen": false,
    "encounters": [
      {
        "id": 2269,
        "name": "The Restless Cabal",
        "npcID": 146497
      },
      {
        "id": 2273,
        "name": "Uu'nat, Harbinger of the Void",
        "npcID": 145371
      }
    ],
    "brackets": {
      "min": 370,
      "max": 427,
      "bucket": 3,
      "type": "Item Level"
    }
  },
  {
    "id": 21,
    "name": "Battle of Dazar'alor",
    "encounters": [
      {
        "id": 2265,
        "name": "Champion of the Light",
        "npcID": 144680
      },
      {
        "id": 2266,
        "name": "Jadefire Masters",
        "npcID": 144690
      },
      {
        "id": 2263,
        "name": "Grong",
        "npcID": 144637
      },
      {
        "id": 2271,
        "name": "Opulence",
        "npcID": 145261
      },
      {
        "id": 2268,
        "name": "Conclave of the Chosen",
        "npcID": 144747
      },
      {
        "id": 2272,
        "name": "King Rastakhan",
        "npcID": 145616
      },
      {
        "id": 2276,
        "name": "Mekkatorque",
        "npcID": 144796
      },
      {
        "id": 2280,
        "name": "Stormwall Blockade",
        "npcID": 146256
      },
      {
        "id": 2281,
        "name": "Lady Jaina Proudmoore",
        "npcID": 146416
      }
    ],
    "brackets": {
      "min": 370,
      "max": 427,
      "bucket": 3,
      "type": "Item Level"
    },
    "partitions": [
      {
        "name": "8.1",
        "compact": "8.1"
      },
      {
        "name": "8.1.5",
        "compact": "8.1.5",
        "default": true
      }
    ]
  },
  {
    "id": 19,
    "name": "Uldir",
    "frozen": true,
    "encounters": [
      {
        "id": 2144,
        "name": "Taloc",
        "npcID": 137119
      },
      {
        "id": 2141,
        "name": "MOTHER",
        "npcID": 135452
      },
      {
        "id": 2128,
        "name": "Fetid Devourer",
        "npcID": 133298
      },
      {
        "id": 2136,
        "name": "Zek'voz",
        "npcID": 134445
      },
      {
        "id": 2134,
        "name": "Vectis",
        "npcID": 134442
      },
      {
        "id": 2145,
        "name": "Zul",
        "npcID": 138967
      },
      {
        "id": 2135,
        "name": "Mythrax",
        "npcID": 134546
      },
      {
        "id": 2122,
        "name": "G'huun",
        "npcID": 132998
      }
    ],
    "brackets": {
      "min": 340,
      "max": 397,
      "bucket": 3,
      "type": "Item Level"
    },
    "partitions": [
      {
        "name": "8.0",
        "compact": "8.0",
        "default": true
      },
      {
        "name": "8.1",
        "compact": "8.1"
      }
    ]
  },
];

export default ZONES;
<commit_msg>added eternal palace raid to zones<commit_after>/* eslint-disable */

// a butchered version of https://www.warcraftlogs.com:443/v1/zones
// only inclused the raids from Legion (showing older logs wouldn't make sense)

// TODO: Refactor this (it's kind of strange and feels misplaced)

const ZONES = [
  {
    "id": 23,
    "name": "The Eternal Palace",
    "frozen": true,
    "encounters": [
      {
        "id": 2298,
        "name": "Abyssal Commander Sivarra",
        "npcID": 145371
      },
      {
        "id": 2305,
        "name": "Radiance of Azshara",
        "npcID": 145371
      },
      {
        "id": 2289,
        "name": "Blackwater Behemoth",
        "npcID": 145371
      },
      {
        "id": 2304,
        "name": "Lady Ashvane",
        "npcID": 145371
      },
      {
        "id": 2303,
        "name": "Orgozoa",
        "npcID": 145371
      },
      {
        "id": 2311,
        "name": "The Queen's Court",
        "npcID": 145371
      },
      {
        "id": 2293,
        "name": "Za'qul, Harbinger of Ny'alotha",
        "npcID": 145371
      },
      {
        "id": 2299,
        "name": "Queen Azshara",
        "npcID": 145371
      }
    ],
    "brackets": {
      "min": 400,
      "max": 457,
      "bucket": 3,
      "type": "Item Level"
    }
  },
  {
    "id": 22,
    "name": "Crucible of Storms",
    "frozen": false,
    "encounters": [
      {
        "id": 2269,
        "name": "The Restless Cabal",
        "npcID": 146497
      },
      {
        "id": 2273,
        "name": "Uu'nat, Harbinger of the Void",
        "npcID": 145371
      }
    ],
    "brackets": {
      "min": 370,
      "max": 427,
      "bucket": 3,
      "type": "Item Level"
    }
  },
  {
    "id": 21,
    "name": "Battle of Dazar'alor",
    "encounters": [
      {
        "id": 2265,
        "name": "Champion of the Light",
        "npcID": 144680
      },
      {
        "id": 2266,
        "name": "Jadefire Masters",
        "npcID": 144690
      },
      {
        "id": 2263,
        "name": "Grong",
        "npcID": 144637
      },
      {
        "id": 2271,
        "name": "Opulence",
        "npcID": 145261
      },
      {
        "id": 2268,
        "name": "Conclave of the Chosen",
        "npcID": 144747
      },
      {
        "id": 2272,
        "name": "King Rastakhan",
        "npcID": 145616
      },
      {
        "id": 2276,
        "name": "Mekkatorque",
        "npcID": 144796
      },
      {
        "id": 2280,
        "name": "Stormwall Blockade",
        "npcID": 146256
      },
      {
        "id": 2281,
        "name": "Lady Jaina Proudmoore",
        "npcID": 146416
      }
    ],
    "brackets": {
      "min": 370,
      "max": 427,
      "bucket": 3,
      "type": "Item Level"
    },
    "partitions": [
      {
        "name": "8.1",
        "compact": "8.1"
      },
      {
        "name": "8.1.5",
        "compact": "8.1.5",
        "default": true
      }
    ]
  },
  {
    "id": 19,
    "name": "Uldir",
    "frozen": true,
    "encounters": [
      {
        "id": 2144,
        "name": "Taloc",
        "npcID": 137119
      },
      {
        "id": 2141,
        "name": "MOTHER",
        "npcID": 135452
      },
      {
        "id": 2128,
        "name": "Fetid Devourer",
        "npcID": 133298
      },
      {
        "id": 2136,
        "name": "Zek'voz",
        "npcID": 134445
      },
      {
        "id": 2134,
        "name": "Vectis",
        "npcID": 134442
      },
      {
        "id": 2145,
        "name": "Zul",
        "npcID": 138967
      },
      {
        "id": 2135,
        "name": "Mythrax",
        "npcID": 134546
      },
      {
        "id": 2122,
        "name": "G'huun",
        "npcID": 132998
      }
    ],
    "brackets": {
      "min": 340,
      "max": 397,
      "bucket": 3,
      "type": "Item Level"
    },
    "partitions": [
      {
        "name": "8.0",
        "compact": "8.0",
        "default": true
      },
      {
        "name": "8.1",
        "compact": "8.1"
      }
    ]
  },
];

export default ZONES;
<|endoftext|>


<commit_before>/**
 * @module Lyria
 */
define('lyria/gameobject', ['mixin', 'isemptyobject', 'each', 'eventmap', 'lyria/component', 'lyria/log'], function(mixin, isEmptyObject, each, EventMap, Component, Log) {
  'use strict';

  //Lyria.GameObject
  return (function() {

    // Constructor
    var GameObject = function() {
      mixin(GameObject.prototype, new EventMap());

      var self = this;

      this.components = {};
      this.className = 'gameobject';

      this.template = {};
      this.template.source = '

';

      this.on('update', function(dt) {
        if (isEmptyObject(self.components)) {
          return;
        }

        each(self.components, function(key, value) {
          value.trigger('update', dt);
        });
      });
    };

    /**
     * Refreshes the game object
     *
     * @param {Object} val
     */
    GameObject.prototype.refresh = function(val) {
      if (val == null && this.template) {
        val = this.template.data;
      }

      if (this.template && this.template.source) {
        this.content = this.template.source(val);
      }

      this.trigger('refresh');
    };

    GameObject.prototype.add = function(component) {
      if (component instanceof Component) {
        this.components[component.name] = component;
      }
    };

    GameObject.prototype.execute = function(functionBody) {
      functionBody.apply(this, this);
    };

    GameObject.prototype.log = function(text) {
      Log.i('GameObject: ' + text);
    };

    return GameObject;

  })();

});<commit_msg>Using lodash where jquery is not a dependency<commit_after>/**
 * @module Lyria
 */
define('lyria/gameobject', ['mixer', 'eventmap', 'lyria/component', 'lyria/log'], function(mixer, EventMap, Component, Log) {
  'use strict';

  //Lyria.GameObject
  return (function() {

    // Constructor
    var GameObject = function() {
      mixer(GameObject.prototype, new EventMap());

      var self = this;

      this.components = {};
      this.className = 'gameobject';

      this.template = {};
      this.template.source = '

';

      this.on('update', function(dt) {
        if (_.isEmpty(self.components)) {
          return;
        }

        _.each(self.components, function(key, value) {
          value.trigger('update', dt);
        });
      });
    };

    /**
     * Refreshes the game object
     *
     * @param {Object} val
     */
    GameObject.prototype.refresh = function(val) {
      if (val == null && this.template) {
        val = this.template.data;
      }

      if (this.template && this.template.source) {
        this.content = this.template.source(val);
      }

      this.trigger('refresh');
    };

    GameObject.prototype.add = function(component) {
      if (component instanceof Component) {
        this.components[component.name] = component;
      }
    };

    GameObject.prototype.execute = function(functionBody) {
      functionBody.apply(this, this);
    };

    GameObject.prototype.log = function(text) {
      Log.i('GameObject: ' + text);
    };

    return GameObject;

  })();

});<|endoftext|>


<commit_before>var request = require('request');

var HACKA_URL = "https://news.ycombinator.com/";
var MAX_LIST_STORIES = 500; //The official HN API only stores up to 500 top/new stories

var hackaAPIURL = "https://hacker-news.firebaseio.com/v0/";
var amtOfFeedStories = 10;
var jsonObject = null;

var getAmountOfFeedStories = function(){
    return amtOfFeedStories;
};

var getURL = function(id){
    return HACKA_URL + "item?id=" + id;
};

var setAPIURL = function(url){
    hackaAPIURL = url;
};

var requestFeedStoryIDs = function(storyType, callback){
    request(hackaAPIURL + storyType + "stories.json?print=pretty", function(error, response, body) {
        if (error){
            console.log("ERROR: Couldn't load " + storyType + " stories.");
            return;
        }
        ids = JSON.parse(body);
        callback(ids);
    });
};

var requestStory = function(id, callback){
    request(hackaAPIURL + "item/" + id + ".json?print=pretty", function (error, response, body) {
        if (error){
            console.log("ERROR: Couldn't load story.");
            return;
        }
        callback(body);
    });
};

var requestStoryParsed = function(id, callback){
    requestStory(id, function(hnJsonStr){
        var parsedStory = JSON.parse(hnJsonStr);
        injectStoryExtras(parsedStory, callback);
        // callback(parsedStory);
    });
};

var injectStoryExtras = function(parsedStory, callback) {
    parsedStory.commentsUrl = getURL(parsedStory.id); //injecting comments url address into the node
    if (parsedStory.type == "comment"){
        requestRootParent(parsedStory, function(rootParent){
            parsedStory.rootParent = rootParent;
            callback(parsedStory);
        });
    }else if (parsedStory.type == "poll"){
        requestPollOptions(parsedStory, function(pollOptArr){
            parsedStory.partNodes = pollOptArr;
            callback(parsedStory);
        });
    }else{
        callback(parsedStory);
    }
};

var requestRootParent = function(childNode, callback){
    if (childNode == null){
        console.log("ERROR: Child node is null.");
        return;
    }
    //Get root parent of post (which, for a comment, should be the article they commented on)
    var rootParent = childNode;
    while (rootParent.parent != null){
        rootParent = rootParent.parent;
        // console.log(rootParent);
    }
    requestStoryParsed(rootParent, function(parsed){
        callback(parsed);
    });
};

var requestPollOptions = function(pollNode, callback){
    if (pollNode == null){
        console.log("ERROR: Poll node is null.");
        return;
    }
    var pollOptNodes = new Array();
    for (var i = 0; i < pollNode.parts.length; i++){
        //Get each pollopt
        requestStoryParsed(pollNode.parts[i], function(parsedPollOpt){
            pollOptNodes.push(parsedPollOpt);
            if (pollOptNodes.length >= pollNode.parts.length){
                callback(pollOptNodes);
            }
        });
    }
};

var requestGroup = function(idList, callback){
    var loadedList = [];
    var loadedCount = 0;
    var expectedCount = idList.length;
    for (var i = 0; i < idList.length; i++){
        loadedList.push(null);
        (function(index){
            requestStoryParsed(idList[index], function(hnJson){
                loadedList[index] = hnJson;
                loadedCount++;
                if (loadedCount >= expectedCount){
                    callback(loadedList);
                }
            });
        })(i);
    }
};

var fetchTopID = function(index, callback) {
    if (index < 0 || index >= MAX_LIST_STORIES){
        throw -1;
    }
    requestFeedStoryIDs("top", function(ids){
        if (ids == null){
            console.log("ERROR: Top stories did not load.");
            return;
        }
        callback(ids[index]);
    });
};

var fetchTopURL = function(index, callback) {
    fetchTopID(index, function(id){
        callback(getURL(id));
    });
};

module.exports = {
    getAmountOfFeedStories,
    getURL,
    setAPIURL,
    requestFeedStoryIDs,
    requestStory,
    requestStoryParsed,
    requestGroup,
    fetchTopID,
    fetchTopURL
};
<commit_msg>Add pruning feed posts function. Add max constant for ask/show/job stories. Remove unused feed stories var.<commit_after>var request = require('request');

var HACKA_URL = "https://news.ycombinator.com/";
const MAX_LIST_STORIES = 500; //The official HN API only provides 500 top/new stories
const MAX_POSTINGS_STORIES = 200; //The official HN API only provides 200 ask/show/job stories

var hackaAPIURL = "https://hacker-news.firebaseio.com/v0/";
var jsonObject = null;

var getURL = function(id){
    return HACKA_URL + "item?id=" + id;
};

var setAPIURL = function(url){
    hackaAPIURL = url;
};

var pruneResults = function(ids, limit){
    var prunedIDs = ids.slice(0, limit);
    return prunedIDs;
}

var requestFeedStoryIDs = function(storyType, limit, callback){
    request(hackaAPIURL + storyType + "stories.json?print=pretty", function(error, response, body) {
        if (error){
            console.log("ERROR: Couldn't load " + storyType + " stories.");
            return;
        }
        ids = JSON.parse(body);
        var maxLimit = (storyType == "top" || storyType == "new") ? MAX_LIST_STORIES : MAX_POSTINGS_STORIES;
        if (limit < maxLimit) {
            ids = pruneResults(ids, limit);
        }
        callback(ids);
    });
};

var requestStory = function(id, callback){
    request(hackaAPIURL + "item/" + id + ".json?print=pretty", function (error, response, body) {
        if (error){
            console.log("ERROR: Couldn't load story.");
            return;
        }
        callback(body);
    });
};

var requestStoryParsed = function(id, callback){
    requestStory(id, function(hnJsonStr){
        var parsedStory = JSON.parse(hnJsonStr);
        injectStoryExtras(parsedStory, callback);
        // callback(parsedStory);
    });
};

var injectStoryExtras = function(parsedStory, callback) {
    parsedStory.commentsUrl = getURL(parsedStory.id); //injecting comments url address into the node
    if (parsedStory.type == "comment"){
        requestRootParent(parsedStory, function(rootParent){
            parsedStory.rootParent = rootParent;
            callback(parsedStory);
        });
    }else if (parsedStory.type == "poll"){
        requestPollOptions(parsedStory, function(pollOptArr){
            parsedStory.partNodes = pollOptArr;
            callback(parsedStory);
        });
    }else{
        callback(parsedStory);
    }
};

var requestRootParent = function(childNode, callback){
    if (childNode == null){
        console.log("ERROR: Child node is null.");
        return;
    }
    //Get root parent of post (which, for a comment, should be the article they commented on)
    var rootParent = childNode;
    while (rootParent.parent != null){
        rootParent = rootParent.parent;
        // console.log(rootParent);
    }
    requestStoryParsed(rootParent, function(parsed){
        callback(parsed);
    });
};

var requestPollOptions = function(pollNode, callback){
    if (pollNode == null){
        console.log("ERROR: Poll node is null.");
        return;
    }
    var pollOptNodes = new Array();
    for (var i = 0; i < pollNode.parts.length; i++){
        //Get each pollopt
        requestStoryParsed(pollNode.parts[i], function(parsedPollOpt){
            pollOptNodes.push(parsedPollOpt);
            if (pollOptNodes.length >= pollNode.parts.length){
                callback(pollOptNodes);
            }
        });
    }
};

var requestGroup = function(idList, callback){
    var loadedList = [];
    var loadedCount = 0;
    var expectedCount = idList.length;
    for (var i = 0; i < idList.length; i++){
        loadedList.push(null);
        (function(index){
            requestStoryParsed(idList[index], function(hnJson){
                loadedList[index] = hnJson;
                loadedCount++;
                if (loadedCount >= expectedCount){
                    callback(loadedList);
                }
            });
        })(i);
    }
};

var fetchTopID = function(index, callback) {
    if (index < 0 || index >= MAX_LIST_STORIES){
        throw -1;
    }
    requestFeedStoryIDs("top", 1, function(ids){
        if (ids == null){
            console.log("ERROR: Top stories did not load.");
            return;
        }
        callback(ids[index]);
    });
};

var fetchTopURL = function(index, callback) {
    fetchTopID(index, function(id){
        callback(getURL(id));
    });
};

module.exports = {
    getURL,
    setAPIURL,
    requestFeedStoryIDs,
    requestStory,
    requestStoryParsed,
    requestGroup,
    fetchTopID,
    fetchTopURL
};
<|endoftext|>


<commit_before>(function(ext) {
    var status = "no";
    var error = 0;
    ext._shutdown = function() {};
    ext._getStatus = function() {
        return {status: 2, msg: 'Ready'};
    };

    ext.error = function() {
        return error;
    };

    ext.status = function() {
        return status;
    };

    ext.support = function() {
        if(typeof(Storage) !== "undefined") {
            error = 1;
            status = "Yes, files can be saved";
            return "Yes, files can be saved";
        } else {
            error = 0;
            status = "Sorry, files cannot be saved";
            return "Sorry, files cannot be saved";
        }
    };

    ext.create = function(value, key) {
        if (error != 0) {
            status = "File Saved";
            localStorage.setItem(key, value);
        } else {
            status = "Sorry file saving failed";
        };
    };

    ext.return = function(key) {
        if (error != 0) {
            if (localStorage.getItem(key) != "null") {
                status = "Item returned";
                return localStorage.getItem(key);
            } else {
                status = "Item does not exist";
                return "null";
            };
        } else {
            status = "Sorry file return failed";
        };
    };

    ext.set = function(value, key) {
        if (error != 0) {
            if (localStorage.getItem(key) != "null") {
                status = "Item set";
                localStorage.getItem(key) = value;
            } else {
                status = "Item does not exist";
            };
        } else {
            status = "Sorry file set failed";
        };
    };
    ext.exist = function(key) {
        if (error != 0) {
            if (localStorage.getItem(key) != "null") {
                return true;
            } else {
                return false;
            };
        } else {
            status = "Sorry file exist check failed";
            return false;
        };
    };

    var descriptor = {
        blocks: [

        ]
    };
    ScratchExtensions.register('Mod - Logic', descriptor, ext);
})({});
<commit_msg>Update html5local.js<commit_after>(function(ext) {
    var status = "no";
    var error = 0;
    ext._shutdown = function() {};
    ext._getStatus = function() {
        return {status: 2, msg: 'Ready'};
    };

    ext.error = function() {
        return error;
    };

    ext.status = function() {
        return status;
    };

    ext.support = function() {
        if(typeof(Storage) !== "undefined") {
            error = 1;
            status = "Yes, files can be saved";
            return true;
        } else {
            error = 0;
            status = "Sorry, files cannot be saved";
            return false;
        };
    };

    ext.create = function(value, key) {
        if (error != 0) {
            status = "File Saved";
            localStorage.setItem(key, value);
        } else {
            status = "Sorry file saving failed";
        };
    };

    ext.return = function(key) {
        if (error != 0) {
            if (localStorage.getItem(key) != "null") {
                status = "Item returned";
                return localStorage.getItem(key);
            } else {
                status = "Item does not exist";
                return "null";
            };
        } else {
            status = "Sorry file return failed";
        };
    };

    ext.set = function(key,value) {
        if (error != 0) {
            if (localStorage.getItem(key) != "null") {
                status = "Item set";
                localStorage.getItem(key) = value;
            } else {
                status = "Item does not exist";
            };
        } else {
            status = "Sorry file set failed";
        };
    };
    ext.exist = function(key) {
        if (error != 0) {
            if (localStorage.getItem(key) != "null") {
                return true;
            } else {
                return false;
            };
        } else {
            status = "Sorry file exist check failed";
            return false;
        };
    };

    ext.del = function(key) {
        if (error != 0) {
            if (localStorage.getItem(key) != "null") {
                localStorage.removeItem(key);
                status = "Item removed";
            } else {
                status = "Item does not exist";
            };
        } else {
            status = "Sorry deletion failed";
        };
    };

    var descriptor = {
        blocks: [
            ["r", "error","error"],
            ["r", "status","status"],
            ["b", "suport saving?","suport"],
            [" ", "create var with value %s and key %s","create","value","key"],
            ["r", "var with key = %s","return","key"],
            [" ", "set var with key %s to %s","set","key","value"],
            ["b", "var with key %s exists?","exist","key"],
            [" ", "delete var with key %s","del","key"],
        ]
    };
    ScratchExtensions.register('Mod - Logic', descriptor, ext);
})({});
<|endoftext|>


<commit_before>/** HTML DOM parser.
 *  @class
 */
var htmlParser = (function() {
	/** @exports exports as htmlParser# */

	var exports = {},
		util = {},
		splitAttrsTokenizer = /([a-z0-9_\:\-]*)\s*?=\s*?(['"]?)(.*?)\2\s+/gim,
		domParserTokenizer = /(?:<(\/?)([a-zA-Z][a-zA-Z0-9\:]*)(?:\s([^>]*?))?((?:\s*\/)?)>|(<\!\-\-)([\s\S]*?)(\-\->)|(<\!\[CDATA\[)([\s\S]*?)(\]\]>))/gm;

	util.extend = function(a, b) {
		for (var x in b) {
			if (b.hasOwnProperty(x)) {
				a[x] = b[x];
			}
		}
		return a;
	};

	util.inherit = function(a, b) {
		var p = a.prototype;
		function F(){}
		F.prototype = b.prototype;
		a.prototype = new F();
		util.extend(a.prototype, p);
		a.prototype.constructor = a;
	};

	util.selfClosingTags = {img:1,br:1,hr:1,meta:1,link:1,base:1,input:1};

	util.getElementsByTagName = function(el, tag) {
		var els=[], c=0, i, n;
		if (!tag) {
			tag = '*';
		}
		tag = tag.toLowerCase();
		if (el.childNodes) {
			for (i=0; i<el.childNodes.length; i++) {
				n = el.childNodes[i];
				if (n.nodeType===1 && (tag==='*' || n.nodeName===tag)) {
					els[c++] = n;
				}
				Array.prototype.splice.apply(els, [els.length, 0].concat(util.getElementsByTagName(n, tag)));
				c = els.length;
			}
		}
		return els;
	};

	util.splitAttrs = function(str) {
		var obj={}, token;
		if (str) {
			splitAttrsTokenizer.lastIndex = 0;
			str = ' '+(str || '')+' ';
			while ( (token=splitAttrsTokenizer.exec(str)) ) {
				obj[token[1]] = token[3];
			}
		}
		return obj;
	};

	util.ta = document.createElement('textarea');
	util.encodeEntities = function(str) {
		util.ta.value = str || '';
		return util.ta.innerHTML;
	};
	util.decodeEntities = function(str) {
		util.ta.innerHTML = str || '';
		return util.ta.value;
	};

	util.htmlToText = function(html) {
		html = html.replace(/<\/?[a-z].*?>/gim, '');
		return util.decodeEntities(html);
	};

	function HTMLElement() {
		this.childNodes = [];
	}
	util.extend(HTMLElement.prototype, {
		nodeType : 1,
		textContent : '',
		getElementsByTagName : function(tag) {
			return util.getElementsByTagName(this, tag);
		},
		getAttribute : function(a) {
			if (this.attributes.hasOwnProperty(a)) {
				return this.attributes[a];
			}
		},
		setAttribute : function(name, value) {
			var lcName = (name+'').toLowerCase();
			this.attributes[name] = value + '';
			if (lcName==='id' || lcName==='name') {
				this[lcName] = value;
			}
			if (lcName==='class') {
				this.className = value;
			}
		},
		getElementById : function(id) {
			var all = this.getElementsByTagName('*'),
				i;
			for (i=all.length; i--; ) {
				if (all[i].id===id) {
					return all[i];
				}
			}
		}
	});
	exports.HTMLElement = HTMLElement;

	function Node(){}
	util.extend(Node.prototype, {
		toString : function(){ return this.textContent; }
	});

	function TextNode(){}
	util.inherit(TextNode, Node);
	util.extend(TextNode.prototype, {
		nodeType : 3,
		nodeName : '#text'
	});
	exports.TextNode = TextNode;

	function CommentNode(){}
	util.inherit(CommentNode, Node);
	util.extend(CommentNode.prototype, {
		nodeType : 8,
		nodeName : '#comment'
	});
	exports.CommentNode = CommentNode;

	function CDATASectionNode(){}
	util.inherit(CDATASectionNode, Node);
	util.extend(CDATASectionNode.prototype, {
		nodeType : 4,
		nodeName : '#cdata-section'
	});
	exports.CDATASectionNode = CDATASectionNode;

	util.blockConstructors = {
		'<!--' : CommentNode,
		'<![CDATA[' : CDATASectionNode
	};

	/** Parse a string of HTML into an HTML DOM.
	 *  @param {String} str		A string containing HTML
	 *  @returns {Document}		A Node, the type corresponding to the type of the root HTML node.
	 */
	exports.parse = function(str) {
		var tags, doc, parent, prev, token, text, i,
			bStart, bText, bEnd, BlockConstructor, commitTextNode, tag;
		tags = [];
		domParserTokenizer.lastIndex = 0;

		parent = doc = util.extend(new HTMLElement(), {
			nodeType : 9,
			nodeName : '#document'
		});

		commitTextNode = function() {
			// note: this is moved out of the loop but still uses its scope!!
			if (parent && tags.length>0) {
				prev = tags[tags.length-1];
				i = (prev.documentPosition.closeTag || prev.documentPosition.openTag).end;
				if (prev.parentNode===parent && i && i<tag.documentPosition.openTag.start) {
					text = str.substring(i, tag.documentPosition.openTag.start);
					if (text) {
						text = util.decodeEntities(text);
						parent.childNodes.push(util.extend(new TextNode(), {
							textContent : text,
							nodeValue : text,
							parentNode : parent
						}));
					}
				}
			}
		};

		while ( (token=domParserTokenizer.exec(str)) ) {
			bStart = token[5] || token[8];
			bText = token[6] || token[9];
			bEnd = token[7] || token[10];
			if (bStart==='<!--' || bStart==='<![CDATA[') {
				i = domParserTokenizer.lastIndex - token[0].length;
				BlockConstructor = util.blockConstructors[bStart];
				if (BlockConstructor) {
					tag = util.extend(new BlockConstructor(), {
						textContent : bText,
						nodeValue : bText,
						parentNode : parent,
						documentPosition : {
							openTag : {
								start : i,
								end : i+bStart.length
							},
							closeTag : {
								start : domParserTokenizer.lastIndex - bEnd.length,
								end : domParserTokenizer.lastIndex
							}
						}
					});
					commitTextNode();
					tags.push(tag);
					tag.parentNode.childNodes.push(tag);
				}
			}
			else if (token[1]!=='/') {
				tag = util.extend(new HTMLElement(), {
					nodeName : (token[2]+'').toLowerCase(),
					attributes : util.splitAttrs(token[3]),
					parentNode : parent,
					documentPosition : {
						openTag : {
							start : domParserTokenizer.lastIndex - token[0].length,
							end : domParserTokenizer.lastIndex
						}
					}
				});
				tag.className = tag.attributes['class'];
				tag.id = tag.attributes.id;
				tag.name = tag.attributes.name;
				commitTextNode();
				tags.push(tag);
				tag.parentNode.childNodes.push(tag);
				if ((token[4] && token[4].indexOf('/')>-1) || util.selfClosingTags.hasOwnProperty(tag.nodeName)) {
					tag.documentPosition.closeTag = tag.documentPosition.openTag;
					tag.isSelfClosingTag = true;
					tag.innerHTML = '';
					tag.outerHTML = str.substring(tag.documentPosition.openTag.start, tag.documentPosition.closeTag.end);
				}
				else {
					parent = tag;
				}
			}
			else {
				// Close parent node if end-tag matches
				if ((token[2]+'').toLowerCase()===parent.nodeName) {
					tag = parent;
					parent = tag.parentNode;
					delete tag.isSelfClosingTag;
					tag.documentPosition.closeTag = {
						start : domParserTokenizer.lastIndex - token[0].length,
						end : domParserTokenizer.lastIndex
					};
					tag.innerHTML = str.substring(tag.documentPosition.openTag.end, tag.documentPosition.closeTag.start);
					tag.outerHTML = str.substring(tag.documentPosition.openTag.start, tag.documentPosition.closeTag.end);
					tag.textContent = util.htmlToText(tag.innerHTML);
				}
				// account for abuse of self-closing tags when an end-tag is also provided:
				else if ((token[2]+'').toLowerCase()===tags[tags.length-1].nodeName && tags[tags.length-1].isSelfClosingTag===true) {
					tag = tags[tags.length-1];
					console.warn('HTML Error: discarding dangling <\/'+token[2]+'> tag. Already closed via: '+tag.outerHTML);
					delete tag.isSelfClosing;
					tag.documentPosition.closeTag = {
						start : domParserTokenizer.lastIndex - token[0].length,
						end : domParserTokenizer.lastIndex
					};
				}
				else {
					console.warn('tag mismatch: "'+token[2]+'" vs "'+tag.nodeName+'"', tag);
				}
			}
		}

		doc.documentElement = doc.getElementsByTagName('html')[0];
		doc.body = doc.getElementsByTagName('body')[0];

		return doc;
	};

	return exports;
}());
<commit_msg>Update htmlParser.js<commit_after>/** HTML DOM parser.
 *  @class
 */
var htmlParser = (function() {
	/** @exports exports as htmlParser# */

	var exports = {},
		util = {},
		splitAttrsTokenizer = /([a-z0-9_\:\-]*)\s*?=\s*?(['"]?)(.*?)\2\s+/gim,
		domParserTokenizer = /(?:<(\/?)([a-zA-Z][a-zA-Z0-9\:]*)(?:\s([^>]*?))?((?:\s*\/)?)>|(<\!\-\-)([\s\S]*?)(\-\->)|(<\!\[CDATA\[)([\s\S]*?)(\]\]>))/gm;

	util.extend = function(a, b) {
		for (var x in b) {
			if (b.hasOwnProperty(x)) {
				a[x] = b[x];
			}
		}
		return a;
	};

	util.inherit = function(a, b) {
		var p = a.prototype;
		function F(){}
		F.prototype = b.prototype;
		a.prototype = new F();
		util.extend(a.prototype, p);
		a.prototype.constructor = a;
	};

	util.selfClosingTags = {img:1,br:1,hr:1,meta:1,link:1,base:1,input:1};

	util.getElementsByTagName = function(el, tag) {
		var els=[], c=0, i, n;
		if (!tag) {
			tag = '*';
		}
		tag = tag.toLowerCase();
		if (el.childNodes) {
			for (i=0; i<el.childNodes.length; i++) {
				n = el.childNodes[i];
				if (n.nodeType===1 && (tag==='*' || n.nodeName===tag)) {
					els[c++] = n;
				}
				Array.prototype.splice.apply(els, [els.length, 0].concat(util.getElementsByTagName(n, tag)));
				c = els.length;
			}
		}
		return els;
	};

	util.splitAttrs = function(str) {
		var obj={}, token;
		if (str) {
			splitAttrsTokenizer.lastIndex = 0;
			str = ' '+(str || '')+' ';
			while ( (token=splitAttrsTokenizer.exec(str)) ) {
				obj[token[1]] = token[3];
			}
		}
		return obj;
	};

	util.ta = document.createElement('textarea');
	util.encodeEntities = function(str) {
		util.ta.value = str || '';
		return util.ta.innerHTML;
	};
	util.decodeEntities = function(str) {
		util.ta.innerHTML = str || '';
		return util.ta.value;
	};

	util.htmlToText = function(html) {
		html = html.replace(/<\/?[a-z].*?>/gim, '');
		return util.decodeEntities(html);
	};

	function HTMLElement() {
		this.childNodes = [];
	}
	util.extend(HTMLElement.prototype, {
		nodeType : 1,
		textContent : '',
		getElementsByTagName : function(tag) {
			return util.getElementsByTagName(this, tag);
		},
		getAttribute : function(a) {
			if (this.attributes.hasOwnProperty(a)) {
				return this.attributes[a];
			}
		},
		setAttribute : function(name, value) {
			var lcName = (name+'').toLowerCase();
			this.attributes[name] = value + '';
			if (lcName==='id' || lcName==='name') {
				this[lcName] = value;
			}
			if (lcName==='class') {
				this.className = value;
			}
		},
		getElementById : function(id) {
			var all = this.getElementsByTagName('*'),
				i;
			for (i=all.length; i--; ) {
				if (all[i].id===id) {
					return all[i];
				}
			}
		},
		appendChild : function(child) {
			if (child.parentNode) {
				child.parentNode.removeChild(child);
			}
			this.childNodes.push(child);
		},
		insertBefore : function(child, sibling) {
			if (child.parentNode) {
				child.parentNode.removeChild(child);
			}
			for (var i=0; i<this.childNodes.length; i++) {
				if (this.childNodes[i]===sibling) {
					break;
				}
			}
			this.childNodes.splice(i, 0, child);
		},
		removeChild : function(child) {
			for (var i=this.childNodes.length; i--; ) {
				if (this.childNodes[i]===child) {
					this.childNodes.splice(i, 1);
					break;
				}
			}
		}
	});
	exports.HTMLElement = HTMLElement;

	function Node(){}
	util.extend(Node.prototype, {
		toString : function(){ return this.textContent; }
	});

	function Document(){
		HTMLElement.call(this);
	}
	util.inherit(Document, HTMLElement);
	util.extend(Document.prototype, {
		nodeType : 9,
		nodeName : '#document'
	});
	exports.Document = Document;

	function TextNode(){}
	util.inherit(TextNode, Node);
	util.extend(TextNode.prototype, {
		nodeType : 3,
		nodeName : '#text'
	});
	exports.TextNode = TextNode;

	function CommentNode(){}
	util.inherit(CommentNode, Node);
	util.extend(CommentNode.prototype, {
		nodeType : 8,
		nodeName : '#comment'
	});
	exports.CommentNode = CommentNode;

	function CDATASectionNode(){}
	util.inherit(CDATASectionNode, Node);
	util.extend(CDATASectionNode.prototype, {
		nodeType : 4,
		nodeName : '#cdata-section'
	});
	exports.CDATASectionNode = CDATASectionNode;

	util.blockConstructors = {
		'<!--' : CommentNode,
		'<![CDATA[' : CDATASectionNode
	};

	/** Parse a string of HTML into an HTML DOM.
	 *  @param {String} str		A string containing HTML
	 *  @returns {Document}		A Node, the type corresponding to the type of the root HTML node.
	 */
	exports.parse = function(str) {
		var tags, doc, parent, prev, token, text, i,
			bStart, bText, bEnd, BlockConstructor, commitTextNode, tag;
		tags = [];
		domParserTokenizer.lastIndex = 0;

		parent = doc = new Document();

		commitTextNode = function() {
			// note: this is moved out of the loop but still uses its scope!!
			if (parent && tags.length>0) {
				prev = tags[tags.length-1];
				i = (prev.documentPosition.closeTag || prev.documentPosition.openTag).end;
				if (prev.parentNode===parent && i && i<tag.documentPosition.openTag.start) {
					text = str.substring(i, tag.documentPosition.openTag.start);
					if (text) {
						text = util.decodeEntities(text);
						parent.childNodes.push(util.extend(new TextNode(), {
							textContent : text,
							nodeValue : text,
							parentNode : parent
						}));
					}
				}
			}
		};

		while ( (token=domParserTokenizer.exec(str)) ) {
			bStart = token[5] || token[8];
			bText = token[6] || token[9];
			bEnd = token[7] || token[10];
			if (bStart==='<!--' || bStart==='<![CDATA[') {
				i = domParserTokenizer.lastIndex - token[0].length;
				BlockConstructor = util.blockConstructors[bStart];
				if (BlockConstructor) {
					tag = util.extend(new BlockConstructor(), {
						textContent : bText,
						nodeValue : bText,
						parentNode : parent,
						documentPosition : {
							openTag : {
								start : i,
								end : i+bStart.length
							},
							closeTag : {
								start : domParserTokenizer.lastIndex - bEnd.length,
								end : domParserTokenizer.lastIndex
							}
						}
					});
					commitTextNode();
					tags.push(tag);
					tag.parentNode.childNodes.push(tag);
				}
			}
			else if (token[1]!=='/') {
				tag = util.extend(new HTMLElement(), {
					nodeName : (token[2]+'').toLowerCase(),
					attributes : util.splitAttrs(token[3]),
					parentNode : parent,
					documentPosition : {
						openTag : {
							start : domParserTokenizer.lastIndex - token[0].length,
							end : domParserTokenizer.lastIndex
						}
					}
				});
				tag.className = tag.attributes['class'];
				tag.id = tag.attributes.id;
				tag.name = tag.attributes.name;
				commitTextNode();
				tags.push(tag);
				tag.parentNode.childNodes.push(tag);
				if ((token[4] && token[4].indexOf('/')>-1) || util.selfClosingTags.hasOwnProperty(tag.nodeName)) {
					tag.documentPosition.closeTag = tag.documentPosition.openTag;
					tag.isSelfClosingTag = true;
					tag.innerHTML = '';
					tag.outerHTML = str.substring(tag.documentPosition.openTag.start, tag.documentPosition.closeTag.end);
				}
				else {
					parent = tag;
				}
			}
			else {
				// Close parent node if end-tag matches
				if ((token[2]+'').toLowerCase()===parent.nodeName) {
					tag = parent;
					parent = tag.parentNode;
					delete tag.isSelfClosingTag;
					tag.documentPosition.closeTag = {
						start : domParserTokenizer.lastIndex - token[0].length,
						end : domParserTokenizer.lastIndex
					};
					tag.innerHTML = str.substring(tag.documentPosition.openTag.end, tag.documentPosition.closeTag.start);
					tag.outerHTML = str.substring(tag.documentPosition.openTag.start, tag.documentPosition.closeTag.end);
					tag.textContent = util.htmlToText(tag.innerHTML);
				}
				// account for abuse of self-closing tags when an end-tag is also provided:
				else if ((token[2]+'').toLowerCase()===tags[tags.length-1].nodeName && tags[tags.length-1].isSelfClosingTag===true) {
					tag = tags[tags.length-1];
					console.warn('HTML Error: discarding dangling <\/'+token[2]+'> tag. Already closed via: '+tag.outerHTML);
					delete tag.isSelfClosing;
					tag.documentPosition.closeTag = {
						start : domParserTokenizer.lastIndex - token[0].length,
						end : domParserTokenizer.lastIndex
					};
				}
				else {
					console.warn('tag mismatch: "'+token[2]+'" vs "'+tag.nodeName+'"', tag);
				}
			}
		}

		doc.documentElement = doc.getElementsByTagName('html')[0];
		doc.body = doc.getElementsByTagName('body')[0];

		return doc;
	};

	return exports;
}());
<|endoftext|>


<commit_before>/*
 * DateJS Culture String File
 * Country Code: hr-HR
 * Name: Croatian (Croatia)
 * Format: "key" : "value"
 * Key is the en-US term, Value is the Key in the current language.
 */
Date.CultureStrings = Date.CultureStrings || {};
Date.CultureStrings["hr-HR"] = {
        "name": "hr-HR",
        "englishName": "Croatian (Croatia)",
        "nativeName": "hrvatski (Hrvatska)",
        "Sunday": "nedjelja",
        "Monday": "ponedjeljak",
        "Tuesday": "utorak",
        "Wednesday": "srijeda",
        "Thursday": "četvrtak",
        "Friday": "petak",
        "Saturday": "subota",
        "Sun": "ned",
        "Mon": "pon",
        "Tue": "uto",
        "Wed": "sri",
        "Thu": "čet",
        "Fri": "pet",
        "Sat": "sub",
        "Su": "ne",
        "Mo": "po",
        "Tu": "ut",
        "We": "sr",
        "Th": "če",
        "Fr": "pe",
        "Sa": "su",
        "S_Sun_Initial": "n",
        "M_Mon_Initial": "p",
        "T_Tue_Initial": "u",
        "W_Wed_Initial": "s",
        "T_Thu_Initial": "č",
        "F_Fri_Initial": "p",
        "S_Sat_Initial": "s",
        "January": "siječanj",
        "February": "veljača",
        "March": "ožujak",
        "April": "travanj",
        "May": "svibanj",
        "June": "lipanj",
        "July": "srpanj",
        "August": "kolovoz",
        "September": "rujan",
        "October": "listopad",
        "November": "studeni",
        "December": "prosinac",
        "Jan_Abbr": "sij",
        "Feb_Abbr": "vlj",
        "Mar_Abbr": "ožu",
        "Apr_Abbr": "tra",
        "May_Abbr": "svi",
        "Jun_Abbr": "lip",
        "Jul_Abbr": "srp",
        "Aug_Abbr": "kol",
        "Sep_Abbr": "ruj",
        "Oct_Abbr": "lis",
        "Nov_Abbr": "stu",
        "Dec_Abbr": "pro",
        "AM": "",
        "PM": "",
        "firstDayOfWeek": 1,
        "twoDigitYearMax": 2029,
        "mdy": "dmy",
        "M/d/yyyy": "d.M.yyyy",
        "dddd, MMMM dd, yyyy": "d. MMMM yyyy",
        "h:mm tt": "H:mm",
        "h:mm:ss tt": "H:mm:ss",
        "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss",
        "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss",
        "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ",
        "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss",
        "MMMM dd": "d. MMMM",
        "MMMM, yyyy": "MMMM, yyyy",
        "/jan(uary)?/": "sij(ečanj)?",
        "/feb(ruary)?/": "veljača",
        "/mar(ch)?/": "ožu(jak)?",
        "/apr(il)?/": "tra(vanj)?",
        "/may/": "svi(banj)?",
        "/jun(e)?/": "lip(anj)?",
        "/jul(y)?/": "srp(anj)?",
        "/aug(ust)?/": "kol(ovoz)?",
        "/sep(t(ember)?)?/": "ruj(an)?",
        "/oct(ober)?/": "lis(topad)?",
        "/nov(ember)?/": "stu(deni)?",
        "/dec(ember)?/": "pro(sinac)?",
        "/^su(n(day)?)?/": "^ne(d(jelja)?)?",
        "/^mo(n(day)?)?/": "^po(n(edjeljak)?)?",
        "/^tu(e(s(day)?)?)?/": "^ut(o(rak)?)?",
        "/^we(d(nesday)?)?/": "^sr(i(jeda)?)?",
        "/^th(u(r(s(day)?)?)?)?/": "^če(t(vrtak)?)?",
        "/^fr(i(day)?)?/": "^pe(t(ak)?)?",
        "/^sa(t(urday)?)?/": "^su(b(ota)?)?",
        "/^next/": "^next",
        "/^last|past|prev(ious)?/": "^last|past|prev(ious)?",
        "/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)",
        "/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)",
        "/^yes(terday)?/": "^yes(terday)?",
        "/^t(od(ay)?)?/": "^t(od(ay)?)?",
        "/^tom(orrow)?/": "^tom(orrow)?",
        "/^n(ow)?/": "^n(ow)?",
        "/^ms|milli(second)?s?/": "^ms|milli(second)?s?",
        "/^sec(ond)?s?/": "^sec(ond)?s?",
        "/^mn|min(ute)?s?/": "^mn|min(ute)?s?",
        "/^h(our)?s?/": "^h(our)?s?",
        "/^w(eek)?s?/": "^w(eek)?s?",
        "/^m(onth)?s?/": "^m(onth)?s?",
        "/^d(ay)?s?/": "^d(ay)?s?",
        "/^y(ear)?s?/": "^y(ear)?s?",
        "/^(a|p)/": "^(a|p)",
        "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)",
        "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)",
        "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)",
        "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)",
        "LINT": "LINT",
        "TOT": "TOT",
        "CHAST": "CHAST",
        "NZST": "NZST",
        "NFT": "NFT",
        "SBT": "SBT",
        "AEST": "AEST",
        "ACST": "ACST",
        "JST": "JST",
        "CWST": "CWST",
        "CT": "CT",
        "ICT": "ICT",
        "MMT": "MMT",
        "BIOT": "BST",
        "NPT": "NPT",
        "IST": "IST",
        "PKT": "PKT",
        "AFT": "AFT",
        "MSK": "MSK",
        "IRST": "IRST",
        "FET": "FET",
        "EET": "EET",
        "CET": "CET",
        "UTC": "UTC",
        "GMT": "GMT",
        "CVT": "CVT",
        "GST": "GST",
        "BRT": "BRT",
        "NST": "NST",
        "AST": "AST",
        "EST": "EST",
        "CST": "CST",
        "MST": "MST",
        "PST": "PST",
        "AKST": "AKST",
        "MIT": "MIT",
        "HST": "HST",
        "SST": "SST",
        "BIT": "BIT",
        "CHADT": "CHADT",
        "NZDT": "NZDT",
        "AEDT": "AEDT",
        "ACDT": "ACDT",
        "AZST": "AZST",
        "IRDT": "IRDT",
        "EEST": "EEST",
        "CEST": "CEST",
        "BST": "BST",
        "PMDT": "PMDT",
        "ADT": "ADT",
        "NDT": "NDT",
        "EDT": "EDT",
        "CDT": "CDT",
        "MDT": "MDT",
        "PDT": "PDT",
        "AKDT": "AKDT",
        "HADT": "HADT"
};
Date.CultureStrings.lang = "hr-HR";
<commit_msg>fixed croatian<commit_after>/*
 * DateJS Culture String File
 * Country Code: hr-HR
 * Name: Croatian (Croatia)
 * Format: "key" : "value"
 * Key is the en-US term, Value is the Key in the current language.
 */
Date.CultureStrings = Date.CultureStrings || {};
Date.CultureStrings["hr-HR"] = {
        "name": "hr-HR",
        "englishName": "Croatian (Croatia)",
        "nativeName": "hrvatski (Hrvatska)",
        "Sunday": "nedjelja",
        "Monday": "ponedjeljak",
        "Tuesday": "utorak",
        "Wednesday": "srijeda",
        "Thursday": "četvrtak",
        "Friday": "petak",
        "Saturday": "subota",
        "Sun": "ned",
        "Mon": "pon",
        "Tue": "uto",
        "Wed": "sri",
        "Thu": "čet",
        "Fri": "pet",
        "Sat": "sub",
        "Su": "ne",
        "Mo": "po",
        "Tu": "ut",
        "We": "sr",
        "Th": "če",
        "Fr": "pe",
        "Sa": "su",
        "S_Sun_Initial": "n",
        "M_Mon_Initial": "p",
        "T_Tue_Initial": "u",
        "W_Wed_Initial": "s",
        "T_Thu_Initial": "č",
        "F_Fri_Initial": "p",
        "S_Sat_Initial": "s",
        "January": "siječanj",
        "February": "veljača",
        "March": "ožujak",
        "April": "travanj",
        "May": "svibanj",
        "June": "lipanj",
        "July": "srpanj",
        "August": "kolovoz",
        "September": "rujan",
        "October": "listopad",
        "November": "studeni",
        "December": "prosinac",
        "Jan_Abbr": "sij",
        "Feb_Abbr": "vlj",
        "Mar_Abbr": "ožu",
        "Apr_Abbr": "tra",
        "May_Abbr": "svi",
        "Jun_Abbr": "lip",
        "Jul_Abbr": "srp",
        "Aug_Abbr": "kol",
        "Sep_Abbr": "ruj",
        "Oct_Abbr": "lis",
        "Nov_Abbr": "stu",
        "Dec_Abbr": "pro",
        "AM": "",
        "PM": "",
        "firstDayOfWeek": 1,
        "twoDigitYearMax": 2029,
        "mdy": "dmy",
        "M/d/yyyy": "d.M.yyyy",
        "dddd, MMMM dd, yyyy": "d. MMMM yyyy",
        "h:mm tt": "H:mm",
        "h:mm:ss tt": "H:mm:ss",
        "dddd, MMMM dd, yyyy h:mm:ss tt": "d. MMMM yyyy H:mm:ss",
        "yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss",
        "yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ",
        "ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss",
        "MMMM dd": "d. MMMM",
        "MMMM, yyyy": "MMMM, yyyy",
        "/jan(uary)?/": "sij(ečanj)?",
        "/feb(ruary)?/": "veljača",
        "/mar(ch)?/": "ožu(jak)?",
        "/apr(il)?/": "tra(vanj)?",
        "/may/": "svi(banj)?",
        "/jun(e)?/": "lip(anj)?",
        "/jul(y)?/": "srp(anj)?",
        "/aug(ust)?/": "kol(ovoz)?",
        "/sep(t(ember)?)?/": "ruj(an)?",
        "/oct(ober)?/": "lis(topad)?",
        "/nov(ember)?/": "stu(deni)?",
        "/dec(ember)?/": "pro(sinac)?",
        "/^su(n(day)?)?/": "^ne(d(jelja)?)?",
        "/^mo(n(day)?)?/": "^po(n(edjeljak)?)?",
        "/^tu(e(s(day)?)?)?/": "^ut(o(rak)?)?",
        "/^we(d(nesday)?)?/": "^sr(i(jeda)?)?",
        "/^th(u(r(s(day)?)?)?)?/": "^če(t(vrtak)?)?",
        "/^fr(i(day)?)?/": "^pe(t(ak)?)?",
        "/^sa(t(urday)?)?/": "^su(b(ota)?)?",
        "/^next/": "^slijedeć(i|e|eg)",
        "/^last|past|prev(ious)?/": "^zadnji|posljednji|prethodni",
        "/^(\\+|aft(er)?|from|hence)/": "^(\\+|pos(lije)?|od|odsad(a)?)",
        "/^(\\-|bef(ore)?|ago)/": "^(\\-|pr(ije)?pred)",
        "/^yes(terday)?/": "^jučer",
        "/^t(od(ay)?)?/": "^danas",
        "/^tom(orrow)?/": "^sutra",
        "/^n(ow)?/": "^sad(a)?",
        "/^ms|milli(second)?s?/": "^ms|milli(second)?s?",
        "/^sec(ond)?s?/": "^sek(und(a|e|i)?)?",
        "/^mn|min(ute)?s?/": "^mn|min(ut(a|e|i)?)?",
        "/^h(our)?s?/": "^s(at(a|i)?)?",
        "/^w(eek)?s?/": "^tj(edan(a|i)?)?",
        "/^m(onth)?s?/": "^mj(esec(a|i)?)?",
        "/^d(ay)?s?/": "^dan(a|i)?",
        "/^y(ear)?s?/": "^god(in(a|e|i|u))?",
        "/^(a|p)/": "^(a|p)",
        "/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)",
        "/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)",
        "/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)",
        "/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)",
        "LINT": "LINT",
        "TOT": "TOT",
        "CHAST": "CHAST",
        "NZST": "NZST",
        "NFT": "NFT",
        "SBT": "SBT",
        "AEST": "AEST",
        "ACST": "ACST",
        "JST": "JST",
        "CWST": "CWST",
        "CT": "CT",
        "ICT": "ICT",
        "MMT": "MMT",
        "BIOT": "BST",
        "NPT": "NPT",
        "IST": "IST",
        "PKT": "PKT",
        "AFT": "AFT",
        "MSK": "MSK",
        "IRST": "IRST",
        "FET": "FET",
        "EET": "EET",
        "CET": "CET",
        "UTC": "UTC",
        "GMT": "GMT",
        "CVT": "CVT",
        "GST": "GST",
        "BRT": "BRT",
        "NST": "NST",
        "AST": "AST",
        "EST": "EST",
        "CST": "CST",
        "MST": "MST",
        "PST": "PST",
        "AKST": "AKST",
        "MIT": "MIT",
        "HST": "HST",
        "SST": "SST",
        "BIT": "BIT",
        "CHADT": "CHADT",
        "NZDT": "NZDT",
        "AEDT": "AEDT",
        "ACDT": "ACDT",
        "AZST": "AZST",
        "IRDT": "IRDT",
        "EEST": "EEST",
        "CEST": "CEST",
        "BST": "BST",
        "PMDT": "PMDT",
        "ADT": "ADT",
        "NDT": "NDT",
        "EDT": "EDT",
        "CDT": "CDT",
        "MDT": "MDT",
        "PDT": "PDT",
        "AKDT": "AKDT",
        "HADT": "HADT"
};
Date.CultureStrings.lang = "hr-HR";
<|endoftext|>


<commit_before>import each from './';

const noop = () => {};
const expectFunction = expect.any(Function);

const get = (object, lensPath) => lensPath.reduce((acc, key) => acc[key], object);

describe('jest-each', () => {
  [
    ['test'],
    ['test', 'only'],
    ['it'],
    ['fit'],
    ['it', 'only'],
    ['describe'],
    ['fdescribe'],
    ['describe', 'only']
  ].forEach(keyPath => {
    describe(`.${keyPath.join('.')}`, () => {
      const getGlobalTestMocks = () => {
        const globals = {
          test: jest.fn(),
          it: jest.fn(),
          fit: jest.fn(),
          describe: jest.fn(),
          fdescribe: jest.fn()
        };
        globals.test.only = jest.fn();
        globals.it.only = jest.fn();
        globals.describe.only = jest.fn();
        return globals;
      };

      test('calls global with given title', () => {
        const globalTestMocks = getGlobalTestMocks();
        const testObject = each([[]], globalTestMocks);
        get(testObject, keyPath)('expected string', noop);

        const globalMock = get(globalTestMocks, keyPath);
        expect(globalMock).toHaveBeenCalledTimes(1);
        expect(globalMock).toHaveBeenCalledWith('expected string', expectFunction);
      });

      test('calls global with given title when multiple tests cases exist', () => {
        const globalTestMocks = getGlobalTestMocks();
        const testObject = each([[], []], globalTestMocks);
        get(testObject, keyPath)('expected string', noop);

        const globalMock = get(globalTestMocks, keyPath);
        expect(globalMock).toHaveBeenCalledTimes(2);
        expect(globalMock).toHaveBeenCalledWith('expected string', expectFunction);
        expect(globalMock).toHaveBeenCalledWith('expected string', expectFunction);
      });

      test('calls global with title containing param values when using sprintf format', () => {
        const globalTestMocks = getGlobalTestMocks();
        const testObject = each([['hello', 1], ['world', 2]], globalTestMocks);
        get(testObject, keyPath)('expected string: %s %s', noop);

        const globalMock = get(globalTestMocks, keyPath);
        expect(globalMock).toHaveBeenCalledTimes(2);
        expect(globalMock).toHaveBeenCalledWith('expected string: hello 1', expectFunction);
        expect(globalMock).toHaveBeenCalledWith('expected string: world 2', expectFunction);
      });

      test('calls global with cb function', () => {
        const globalTestMocks = getGlobalTestMocks();
        const testObject = each([[]], globalTestMocks)
        get(testObject, keyPath)('expected string', noop);

        const globalMock = get(globalTestMocks, keyPath);
        expect(globalMock).toHaveBeenCalledTimes(1);
        expect(typeof globalMock.mock.calls[0][1] === 'function').toBe(true);
      });

      test('calls global with cb function containing all parameters of each test case', () => {
        const globalTestMocks = getGlobalTestMocks();
        const testCallBack = jest.fn();
        const testObject = each([['hello', 'world'], ['joe', 'bloggs']], globalTestMocks)
        get(testObject, keyPath)('expected string', testCallBack);

        const globalMock = get(globalTestMocks, keyPath);

        globalMock.mock.calls[0][1]();
        expect(testCallBack).toHaveBeenCalledTimes(1);
        expect(testCallBack).toHaveBeenCalledWith('hello', 'world');

        globalMock.mock.calls[1][1]();
        expect(testCallBack).toHaveBeenCalledTimes(2);
        expect(testCallBack).toHaveBeenCalledWith('joe', 'bloggs');
      });

      test('calls global with async done when cb function has more args than params of given test row', () => {
        const globalTestMocks = getGlobalTestMocks();
        const testObject = each([['hello']], globalTestMocks)

        get(testObject, keyPath)('expected string', (hello, done) => {
          expect(hello).toBe('hello');
          expect(done).toBe('DONE');
        });
        get(globalTestMocks, keyPath).mock.calls[0][1]('DONE');
      });
    });
  });

  [
    ['xtest'],
    ['test', 'skip']
  ].forEach(keyPath => {
    describe(`.${keyPath.join('.')}`, () => {
      const getGlobalTestMocks = () => {
        const globals = {
          test: {
            skip: jest.fn()
          },
          it: {},
          describe: {},
          xtest: jest.fn()
        };
        return globals;
      };

      test('calls global with given title', () => {
        const globalTestMocks = getGlobalTestMocks();
        const testObject = each([[]], globalTestMocks);
        get(testObject, keyPath)('expected string', noop);

        const globalMock = get(globalTestMocks, keyPath);
        expect(globalMock).toHaveBeenCalledTimes(1);
        expect(globalMock).toHaveBeenCalledWith('expected string', expectFunction);
      });

      test('calls global with given title when multiple tests cases exist', () => {
        const globalTestMocks = getGlobalTestMocks();
        const testObject = each([[], []], globalTestMocks);
        get(testObject, keyPath)('expected string', noop);

        const globalMock = get(globalTestMocks, keyPath);
        expect(globalMock).toHaveBeenCalledTimes(2);
        expect(globalMock).toHaveBeenCalledWith('expected string', expectFunction);
      });

      test('calls global with title containing param values when using sprintf format', () => {
        const globalTestMocks = getGlobalTestMocks();
        const testObject = each([['hello', 1], ['world', 2]], globalTestMocks)
        get(testObject, keyPath)('expected string: %s %s', () => {});

        const globalMock = get(globalTestMocks, keyPath);
        expect(globalMock).toHaveBeenCalledTimes(2);
        expect(globalMock).toHaveBeenCalledWith('expected string: hello 1', expectFunction);
        expect(globalMock).toHaveBeenCalledWith('expected string: world 2', expectFunction);
      });

      test('calls global with cb function', () => {
        const globalTestMocks = getGlobalTestMocks();
        const testCallBack = jest.fn();
        const testObject = each([[]], globalTestMocks)
        get(testObject, keyPath)('expected string', testCallBack);

        const globalMock = get(globalTestMocks, keyPath);
        expect(globalMock).toHaveBeenCalledTimes(1);
        expect(typeof globalMock.mock.calls[0][1] === 'function').toBe(true);
      });
    });
  });

  describe('.it.skip', () => {
    test('calls global it skip with given title', () => {
      const globalItSkipMock = { it: { skip: jest.fn() }, test: {}, describe: {} };
      each([[]], globalItSkipMock).it.skip('expected string', () => {});

      expect(globalItSkipMock.it.skip.mock.calls.length).toBe(1);
      expect(globalItSkipMock.it.skip.mock.calls[0][0]).toBe('expected string');
    });

    test('calls global it skip with given title when multiple tests cases exist', () => {
      const globalItSkipMock = { it: { skip: jest.fn() }, test: {}, describe: {} };
      each([[], []], globalItSkipMock).it.skip('expected string', () => {});

      expect(globalItSkipMock.it.skip.mock.calls.length).toBe(2);
      expect(globalItSkipMock.it.skip.mock.calls[0][0]).toBe('expected string');
    });

    test('calls global it skip with title containing param values when using sprintf format', () => {
      const globalItSkipMock = { it: { skip: jest.fn() }, test: {}, describe: {} };
      each([['hello', 1], ['world', 2]], globalItSkipMock).it.skip('expected string: %s %s', () => {});

      expect(globalItSkipMock.it.skip.mock.calls.length).toBe(2);
      expect(globalItSkipMock.it.skip.mock.calls[0][0]).toBe('expected string: hello 1');
      expect(globalItSkipMock.it.skip.mock.calls[1][0]).toBe('expected string: world 2');
    });

    test('calls global it skip with cb function', () => {
      const globalItSkipMock = { it: { skip: jest.fn() }, test: {}, describe: {} };
      const testCallBack = jest.fn();
      each([[]], globalItSkipMock).it.skip('expected string', testCallBack);

      expect(globalItSkipMock.it.skip.mock.calls.length).toBe(1);
      expect(typeof globalItSkipMock.it.skip.mock.calls[0][1] === 'function').toBe(true);
    });
  });

  describe('.xit', () => {
    test('calls global xit with given title', () => {
      const globalXItMock = { test: {}, it: {}, xit: jest.fn(), describe: {} };
      each([[]], globalXItMock).xit('expected string', () => {});

      expect(globalXItMock.xit.mock.calls.length).toBe(1);
      expect(globalXItMock.xit.mock.calls[0][0]).toBe('expected string');
    });

    test('calls global xit with given title when multiple tests cases exist', () => {
      const globalXItMock = { test: {}, it: {}, xit: jest.fn(), describe: {} };
      each([[], []], globalXItMock).xit('expected string', () => {});

      expect(globalXItMock.xit.mock.calls.length).toBe(2);
      expect(globalXItMock.xit.mock.calls[0][0]).toBe('expected string');
    });

    test('calls global xit with title containing param values when using sprintf format', () => {
      const globalXItMock = { test: {}, it: {}, xit: jest.fn(), describe: {} };
      each([['hello', 1], ['world', 2]], globalXItMock).xit('expected string: %s %s', () => {});

      expect(globalXItMock.xit.mock.calls.length).toBe(2);
      expect(globalXItMock.xit.mock.calls[0][0]).toBe('expected string: hello 1');
      expect(globalXItMock.xit.mock.calls[1][0]).toBe('expected string: world 2');
    });

    test('calls global xit with cb function', () => {
      const globalXItMock = { test: {}, it: {}, xit: jest.fn(), describe: {} };
      const testCallBack = jest.fn();
      each([[]], globalXItMock).xit('expected string', testCallBack);

      expect(globalXItMock.xit.mock.calls.length).toBe(1);
      expect(typeof globalXItMock.xit.mock.calls[0][1] === 'function').toBe(true);
    });
  });

  describe('.xdescribe', () => {
    test('calls global xdescribe with given title', () => {
      const globalMock = { xdescribe: jest.fn(), describe: {}, fit: {}, it: {}, test: {} };
      each([[]], globalMock).xdescribe('expected string', () => {});

      expect(globalMock.xdescribe.mock.calls.length).toBe(1);
      expect(globalMock.xdescribe.mock.calls[0][0]).toBe('expected string');
    });

    test('calls global xdescribe with given title when multiple tests cases exist', () => {
      const globalMock = { xdescribe: jest.fn(), describe: {}, fit: {}, it: {}, test: {} };
      each([[], []], globalMock).xdescribe('expected string', () => {});

      expect(globalMock.xdescribe.mock.calls.length).toBe(2);
      expect(globalMock.xdescribe.mock.calls[0][0]).toBe('expected string');
    });

    test('calls global xdescribe with title containing param values when using sprintf format', () => {
      const globalMock = { xdescribe: jest.fn(), describe: {}, fit: {}, it: {}, test: {} };
      each([['hello', 1], ['world', 2]], globalMock).xdescribe('expected string: %s %s', () => {});

      expect(globalMock.xdescribe.mock.calls.length).toBe(2);
      expect(globalMock.xdescribe.mock.calls[0][0]).toBe('expected string: hello 1');
      expect(globalMock.xdescribe.mock.calls[1][0]).toBe('expected string: world 2');
    });

    test('calls global xdescribe with cb function', () => {
      const globalMock = { xdescribe: jest.fn(), describe: {}, fit: {}, it: {}, test: {} };
      const testCallBack = jest.fn();
      each([[]], globalMock).xdescribe('expected string', testCallBack);

      expect(globalMock.xdescribe.mock.calls.length).toBe(1);
      expect(typeof globalMock.xdescribe.mock.calls[0][1] === 'function').toBe(true);
    });

    test('calls global xdescribe with cb function containing all parameters of first row when multiple test cases exist', () => {
      const globalMock = { xdescribe: jest.fn(), describe: {}, fit: {}, it: {}, test: {} };
      const testCallBack = jest.fn();
      each([['hello', 'world'], ['joe', 'bloggs']], globalMock).xdescribe('expected string', testCallBack);

      globalMock.xdescribe.mock.calls[0][1]();
      expect(testCallBack.mock.calls.length).toBe(1);
      expect(testCallBack.mock.calls[0][0]).toBe('hello');
      expect(testCallBack.mock.calls[0][1]).toBe('world');

      globalMock.xdescribe.mock.calls[1][1]();
      expect(testCallBack.mock.calls.length).toBe(2);
      expect(testCallBack.mock.calls[1][0]).toBe('joe');
      expect(testCallBack.mock.calls[1][1]).toBe('bloggs');
    });

    test('calls global xdescribe with async done when cb function has more args than params of given test row', () => {
      const globalMock = { xdescribe: jest.fn(), describe: {}, fit: {}, it: {}, test: {} };
      each([['hello']], globalMock).xdescribe('expected string', (hello, done) => {
        expect(hello).toBe('hello');
        expect(done).toBe('DONE');
      });

      globalMock.xdescribe.mock.calls[0][1]('DONE');
    });
  });

  describe('.describe.skip', () => {
    test('calls global describe.skip with given title', () => {
      const globalMock = { fdescribe: {}, describe: { skip: jest.fn() }, fit: {}, it: {}, test: {} };
      each([[]], globalMock).describe.skip('expected string', () => {});

      expect(globalMock.describe.skip.mock.calls.length).toBe(1);
      expect(globalMock.describe.skip.mock.calls[0][0]).toBe('expected string');
    });

    test('calls global describe.skip with given title when multiple tests cases exist', () => {
      const globalMock = { fdescribe: {}, describe: { skip: jest.fn() }, fit: {}, it: {}, test: {} };
      each([[], []], globalMock).describe.skip('expected string', () => {});

      expect(globalMock.describe.skip.mock.calls.length).toBe(2);
      expect(globalMock.describe.skip.mock.calls[0][0]).toBe('expected string');
    });

    test('calls global describe.skip with title containing param values when using sprintf format', () => {
      const globalMock = { fdescribe: {}, describe: { skip: jest.fn() }, fit: {}, it: {}, test: {} };
      each([['hello', 1], ['world', 2]], globalMock).describe.skip('expected string: %s %s', () => {});

      expect(globalMock.describe.skip.mock.calls.length).toBe(2);
      expect(globalMock.describe.skip.mock.calls[0][0]).toBe('expected string: hello 1');
      expect(globalMock.describe.skip.mock.calls[1][0]).toBe('expected string: world 2');
    });

    test('calls global describe.skip with cb function', () => {
      const globalMock = { fdescribe: {}, describe: { skip: jest.fn() }, fit: {}, it: {}, test: {} };
      const testCallBack = jest.fn();
      each([[]], globalMock).describe.skip('expected string', testCallBack);

      expect(globalMock.describe.skip.mock.calls.length).toBe(1);
      expect(typeof globalMock.describe.skip.mock.calls[0][1] === 'function').toBe(true);
    });

    test('calls global describe.skip with cb function containing all parameters of first row when multiple test cases exist', () => {
      const globalMock = { fdescribe: {}, describe: { skip: jest.fn() }, fit: {}, it: {}, test: {} };
      const testCallBack = jest.fn();
      each([['hello', 'world'], ['joe', 'bloggs']], globalMock).describe.skip('expected string', testCallBack);

      globalMock.describe.skip.mock.calls[0][1]();
      expect(testCallBack.mock.calls.length).toBe(1);
      expect(testCallBack.mock.calls[0][0]).toBe('hello');
      expect(testCallBack.mock.calls[0][1]).toBe('world');

      globalMock.describe.skip.mock.calls[1][1]();
      expect(testCallBack.mock.calls.length).toBe(2);
      expect(testCallBack.mock.calls[1][0]).toBe('joe');
      expect(testCallBack.mock.calls[1][1]).toBe('bloggs');
    });

    test('calls global describe.skip with async done when cb function has more args than params of given test row', () => {
      const globalMock = { fdescribe: {}, describe: { skip: jest.fn() }, fit: {}, it: {}, test: {} };
      each([['hello']], globalMock).describe.skip('expected string', (hello, done) => {
        expect(hello).toBe('hello');
        expect(done).toBe('DONE');
      });

      globalMock.describe.skip.mock.calls[0][1]('DONE');
    });
  });

});
<commit_msg>Convert xit to parameterised test<commit_after>import each from './';

const noop = () => {};
const expectFunction = expect.any(Function);

const get = (object, lensPath) => lensPath.reduce((acc, key) => acc[key], object);

describe('jest-each', () => {
  [
    ['test'],
    ['test', 'only'],
    ['it'],
    ['fit'],
    ['it', 'only'],
    ['describe'],
    ['fdescribe'],
    ['describe', 'only']
  ].forEach(keyPath => {
    describe(`.${keyPath.join('.')}`, () => {
      const getGlobalTestMocks = () => {
        const globals = {
          test: jest.fn(),
          it: jest.fn(),
          fit: jest.fn(),
          describe: jest.fn(),
          fdescribe: jest.fn()
        };
        globals.test.only = jest.fn();
        globals.it.only = jest.fn();
        globals.describe.only = jest.fn();
        return globals;
      };

      test('calls global with given title', () => {
        const globalTestMocks = getGlobalTestMocks();
        const testObject = each([[]], globalTestMocks);
        get(testObject, keyPath)('expected string', noop);

        const globalMock = get(globalTestMocks, keyPath);
        expect(globalMock).toHaveBeenCalledTimes(1);
        expect(globalMock).toHaveBeenCalledWith('expected string', expectFunction);
      });

      test('calls global with given title when multiple tests cases exist', () => {
        const globalTestMocks = getGlobalTestMocks();
        const testObject = each([[], []], globalTestMocks);
        get(testObject, keyPath)('expected string', noop);

        const globalMock = get(globalTestMocks, keyPath);
        expect(globalMock).toHaveBeenCalledTimes(2);
        expect(globalMock).toHaveBeenCalledWith('expected string', expectFunction);
        expect(globalMock).toHaveBeenCalledWith('expected string', expectFunction);
      });

      test('calls global with title containing param values when using sprintf format', () => {
        const globalTestMocks = getGlobalTestMocks();
        const testObject = each([['hello', 1], ['world', 2]], globalTestMocks);
        get(testObject, keyPath)('expected string: %s %s', noop);

        const globalMock = get(globalTestMocks, keyPath);
        expect(globalMock).toHaveBeenCalledTimes(2);
        expect(globalMock).toHaveBeenCalledWith('expected string: hello 1', expectFunction);
        expect(globalMock).toHaveBeenCalledWith('expected string: world 2', expectFunction);
      });

      test('calls global with cb function', () => {
        const globalTestMocks = getGlobalTestMocks();
        const testObject = each([[]], globalTestMocks)
        get(testObject, keyPath)('expected string', noop);

        const globalMock = get(globalTestMocks, keyPath);
        expect(globalMock).toHaveBeenCalledTimes(1);
        expect(typeof globalMock.mock.calls[0][1] === 'function').toBe(true);
      });

      test('calls global with cb function containing all parameters of each test case', () => {
        const globalTestMocks = getGlobalTestMocks();
        const testCallBack = jest.fn();
        const testObject = each([['hello', 'world'], ['joe', 'bloggs']], globalTestMocks)
        get(testObject, keyPath)('expected string', testCallBack);

        const globalMock = get(globalTestMocks, keyPath);

        globalMock.mock.calls[0][1]();
        expect(testCallBack).toHaveBeenCalledTimes(1);
        expect(testCallBack).toHaveBeenCalledWith('hello', 'world');

        globalMock.mock.calls[1][1]();
        expect(testCallBack).toHaveBeenCalledTimes(2);
        expect(testCallBack).toHaveBeenCalledWith('joe', 'bloggs');
      });

      test('calls global with async done when cb function has more args than params of given test row', () => {
        const globalTestMocks = getGlobalTestMocks();
        const testObject = each([['hello']], globalTestMocks)

        get(testObject, keyPath)('expected string', (hello, done) => {
          expect(hello).toBe('hello');
          expect(done).toBe('DONE');
        });
        get(globalTestMocks, keyPath).mock.calls[0][1]('DONE');
      });
    });
  });

  [
    ['xtest'],
    ['test', 'skip'],
    ['xit']
  ].forEach(keyPath => {
    describe(`.${keyPath.join('.')}`, () => {
      const getGlobalTestMocks = () => {
        const globals = {
          test: {
            skip: jest.fn()
          },
          xtest: jest.fn(),
          it: {},
          xit: jest.fn(),
          describe: {},
        };
        return globals;
      };

      test('calls global with given title', () => {
        const globalTestMocks = getGlobalTestMocks();
        const testObject = each([[]], globalTestMocks);
        get(testObject, keyPath)('expected string', noop);

        const globalMock = get(globalTestMocks, keyPath);
        expect(globalMock).toHaveBeenCalledTimes(1);
        expect(globalMock).toHaveBeenCalledWith('expected string', expectFunction);
      });

      test('calls global with given title when multiple tests cases exist', () => {
        const globalTestMocks = getGlobalTestMocks();
        const testObject = each([[], []], globalTestMocks);
        get(testObject, keyPath)('expected string', noop);

        const globalMock = get(globalTestMocks, keyPath);
        expect(globalMock).toHaveBeenCalledTimes(2);
        expect(globalMock).toHaveBeenCalledWith('expected string', expectFunction);
      });

      test('calls global with title containing param values when using sprintf format', () => {
        const globalTestMocks = getGlobalTestMocks();
        const testObject = each([['hello', 1], ['world', 2]], globalTestMocks)
        get(testObject, keyPath)('expected string: %s %s', () => {});

        const globalMock = get(globalTestMocks, keyPath);
        expect(globalMock).toHaveBeenCalledTimes(2);
        expect(globalMock).toHaveBeenCalledWith('expected string: hello 1', expectFunction);
        expect(globalMock).toHaveBeenCalledWith('expected string: world 2', expectFunction);
      });

      test('calls global with cb function', () => {
        const globalTestMocks = getGlobalTestMocks();
        const testCallBack = jest.fn();
        const testObject = each([[]], globalTestMocks)
        get(testObject, keyPath)('expected string', testCallBack);

        const globalMock = get(globalTestMocks, keyPath);
        expect(globalMock).toHaveBeenCalledTimes(1);
        expect(typeof globalMock.mock.calls[0][1] === 'function').toBe(true);
      });
    });
  });

  describe('.it.skip', () => {
    test('calls global it skip with given title', () => {
      const globalItSkipMock = { it: { skip: jest.fn() }, test: {}, describe: {} };
      each([[]], globalItSkipMock).it.skip('expected string', () => {});

      expect(globalItSkipMock.it.skip.mock.calls.length).toBe(1);
      expect(globalItSkipMock.it.skip.mock.calls[0][0]).toBe('expected string');
    });

    test('calls global it skip with given title when multiple tests cases exist', () => {
      const globalItSkipMock = { it: { skip: jest.fn() }, test: {}, describe: {} };
      each([[], []], globalItSkipMock).it.skip('expected string', () => {});

      expect(globalItSkipMock.it.skip.mock.calls.length).toBe(2);
      expect(globalItSkipMock.it.skip.mock.calls[0][0]).toBe('expected string');
    });

    test('calls global it skip with title containing param values when using sprintf format', () => {
      const globalItSkipMock = { it: { skip: jest.fn() }, test: {}, describe: {} };
      each([['hello', 1], ['world', 2]], globalItSkipMock).it.skip('expected string: %s %s', () => {});

      expect(globalItSkipMock.it.skip.mock.calls.length).toBe(2);
      expect(globalItSkipMock.it.skip.mock.calls[0][0]).toBe('expected string: hello 1');
      expect(globalItSkipMock.it.skip.mock.calls[1][0]).toBe('expected string: world 2');
    });

    test('calls global it skip with cb function', () => {
      const globalItSkipMock = { it: { skip: jest.fn() }, test: {}, describe: {} };
      const testCallBack = jest.fn();
      each([[]], globalItSkipMock).it.skip('expected string', testCallBack);

      expect(globalItSkipMock.it.skip.mock.calls.length).toBe(1);
      expect(typeof globalItSkipMock.it.skip.mock.calls[0][1] === 'function').toBe(true);
    });
  });

  describe('.xdescribe', () => {
    test('calls global xdescribe with given title', () => {
      const globalMock = { xdescribe: jest.fn(), describe: {}, fit: {}, it: {}, test: {} };
      each([[]], globalMock).xdescribe('expected string', () => {});

      expect(globalMock.xdescribe.mock.calls.length).toBe(1);
      expect(globalMock.xdescribe.mock.calls[0][0]).toBe('expected string');
    });

    test('calls global xdescribe with given title when multiple tests cases exist', () => {
      const globalMock = { xdescribe: jest.fn(), describe: {}, fit: {}, it: {}, test: {} };
      each([[], []], globalMock).xdescribe('expected string', () => {});

      expect(globalMock.xdescribe.mock.calls.length).toBe(2);
      expect(globalMock.xdescribe.mock.calls[0][0]).toBe('expected string');
    });

    test('calls global xdescribe with title containing param values when using sprintf format', () => {
      const globalMock = { xdescribe: jest.fn(), describe: {}, fit: {}, it: {}, test: {} };
      each([['hello', 1], ['world', 2]], globalMock).xdescribe('expected string: %s %s', () => {});

      expect(globalMock.xdescribe.mock.calls.length).toBe(2);
      expect(globalMock.xdescribe.mock.calls[0][0]).toBe('expected string: hello 1');
      expect(globalMock.xdescribe.mock.calls[1][0]).toBe('expected string: world 2');
    });

    test('calls global xdescribe with cb function', () => {
      const globalMock = { xdescribe: jest.fn(), describe: {}, fit: {}, it: {}, test: {} };
      const testCallBack = jest.fn();
      each([[]], globalMock).xdescribe('expected string', testCallBack);

      expect(globalMock.xdescribe.mock.calls.length).toBe(1);
      expect(typeof globalMock.xdescribe.mock.calls[0][1] === 'function').toBe(true);
    });

    test('calls global xdescribe with cb function containing all parameters of first row when multiple test cases exist', () => {
      const globalMock = { xdescribe: jest.fn(), describe: {}, fit: {}, it: {}, test: {} };
      const testCallBack = jest.fn();
      each([['hello', 'world'], ['joe', 'bloggs']], globalMock).xdescribe('expected string', testCallBack);

      globalMock.xdescribe.mock.calls[0][1]();
      expect(testCallBack.mock.calls.length).toBe(1);
      expect(testCallBack.mock.calls[0][0]).toBe('hello');
      expect(testCallBack.mock.calls[0][1]).toBe('world');

      globalMock.xdescribe.mock.calls[1][1]();
      expect(testCallBack.mock.calls.length).toBe(2);
      expect(testCallBack.mock.calls[1][0]).toBe('joe');
      expect(testCallBack.mock.calls[1][1]).toBe('bloggs');
    });

    test('calls global xdescribe with async done when cb function has more args than params of given test row', () => {
      const globalMock = { xdescribe: jest.fn(), describe: {}, fit: {}, it: {}, test: {} };
      each([['hello']], globalMock).xdescribe('expected string', (hello, done) => {
        expect(hello).toBe('hello');
        expect(done).toBe('DONE');
      });

      globalMock.xdescribe.mock.calls[0][1]('DONE');
    });
  });

  describe('.describe.skip', () => {
    test('calls global describe.skip with given title', () => {
      const globalMock = { fdescribe: {}, describe: { skip: jest.fn() }, fit: {}, it: {}, test: {} };
      each([[]], globalMock).describe.skip('expected string', () => {});

      expect(globalMock.describe.skip.mock.calls.length).toBe(1);
      expect(globalMock.describe.skip.mock.calls[0][0]).toBe('expected string');
    });

    test('calls global describe.skip with given title when multiple tests cases exist', () => {
      const globalMock = { fdescribe: {}, describe: { skip: jest.fn() }, fit: {}, it: {}, test: {} };
      each([[], []], globalMock).describe.skip('expected string', () => {});

      expect(globalMock.describe.skip.mock.calls.length).toBe(2);
      expect(globalMock.describe.skip.mock.calls[0][0]).toBe('expected string');
    });

    test('calls global describe.skip with title containing param values when using sprintf format', () => {
      const globalMock = { fdescribe: {}, describe: { skip: jest.fn() }, fit: {}, it: {}, test: {} };
      each([['hello', 1], ['world', 2]], globalMock).describe.skip('expected string: %s %s', () => {});

      expect(globalMock.describe.skip.mock.calls.length).toBe(2);
      expect(globalMock.describe.skip.mock.calls[0][0]).toBe('expected string: hello 1');
      expect(globalMock.describe.skip.mock.calls[1][0]).toBe('expected string: world 2');
    });

    test('calls global describe.skip with cb function', () => {
      const globalMock = { fdescribe: {}, describe: { skip: jest.fn() }, fit: {}, it: {}, test: {} };
      const testCallBack = jest.fn();
      each([[]], globalMock).describe.skip('expected string', testCallBack);

      expect(globalMock.describe.skip.mock.calls.length).toBe(1);
      expect(typeof globalMock.describe.skip.mock.calls[0][1] === 'function').toBe(true);
    });

    test('calls global describe.skip with cb function containing all parameters of first row when multiple test cases exist', () => {
      const globalMock = { fdescribe: {}, describe: { skip: jest.fn() }, fit: {}, it: {}, test: {} };
      const testCallBack = jest.fn();
      each([['hello', 'world'], ['joe', 'bloggs']], globalMock).describe.skip('expected string', testCallBack);

      globalMock.describe.skip.mock.calls[0][1]();
      expect(testCallBack.mock.calls.length).toBe(1);
      expect(testCallBack.mock.calls[0][0]).toBe('hello');
      expect(testCallBack.mock.calls[0][1]).toBe('world');

      globalMock.describe.skip.mock.calls[1][1]();
      expect(testCallBack.mock.calls.length).toBe(2);
      expect(testCallBack.mock.calls[1][0]).toBe('joe');
      expect(testCallBack.mock.calls[1][1]).toBe('bloggs');
    });

    test('calls global describe.skip with async done when cb function has more args than params of given test row', () => {
      const globalMock = { fdescribe: {}, describe: { skip: jest.fn() }, fit: {}, it: {}, test: {} };
      each([['hello']], globalMock).describe.skip('expected string', (hello, done) => {
        expect(hello).toBe('hello');
        expect(done).toBe('DONE');
      });

      globalMock.describe.skip.mock.calls[0][1]('DONE');
    });
  });

});
<|endoftext|>


<commit_before>import * as journalize from './';

it('should export all the functions', () => {
  const expectedProperties = [
    'apnumber',
    'apstate',
    'intcomma',
    'intword',
    'ordinal',
    'postal'
  ];
  const properties = Object.keys(journalize);

  expect(properties).toEqual(expect.arrayContaining(expectedProperties));
});
<commit_msg>The index test was silly and not helping<commit_after><|endoftext|>


<commit_before>/*
 * typeahead.js
 * https://github.com/twitter/typeahead
 * Copyright 2013 Twitter, Inc. and other contributors; Licensed MIT
 */

var InputView = (function() {

  // constructor
  // -----------

  function InputView(o) {
    var that = this;

    utils.bindAll(this);

    this.specialKeyCodeMap = {
      9: 'tab',
      27: 'esc',
      37: 'left',
      39: 'right',
      13: 'enter',
      38: 'up',
      40: 'down'
    };

    this.query = '';

    this.$hint = $(o.hint);
    this.$input = $(o.input)
    .on('blur.tt', this._handleBlur)
    .on('focus.tt', this._handleFocus)
    .on('keydown.tt', this._handleSpecialKeyEvent);

    // ie7 and ie8 don't support the input event
    // ie9 doesn't fire the input event when characters are removed
    // not sure if ie10 is compatible
    if (!utils.isMsie()) {
      this.$input.on('input.tt', this._compareQueryToInputValue);
    }

    else {
      this.$input
      .on('keydown.tt keypress.tt cut.tt paste.tt', function($e) {
        // if a special key triggered this, ignore it
        if (that.specialKeyCodeMap[$e.which || $e.keyCode]) { return; }

        // give the browser a chance to update the value of the input
        // before checking to see if the query changed
        setTimeout(that._compareQueryToInputValue, 0);
      });
    }

    // helps with calculating the width of the input's value
    this.$overflowHelper = buildOverflowHelper(this.$input);
  }

  utils.mixin(InputView.prototype, EventTarget, {
    // private methods
    // ---------------

    _handleFocus: function() {
      this.trigger('focused');
    },

    _handleBlur: function() {
      this.trigger('blured');
    },

    _handleSpecialKeyEvent: function($e) {
      // which is normalized and consistent (but not for IE)
      var keyName = this.specialKeyCodeMap[$e.which || $e.keyCode];

      keyName && this.trigger(keyName + 'Keyed', $e);
    },

    _compareQueryToInputValue: function() {
      var inputValue = this.getInputValue(),
          isSameQuery = compareQueries(this.query, inputValue),
          isSameQueryExceptWhitespace = isSameQuery ?
            this.query.length !== inputValue.length : false;

      if (isSameQueryExceptWhitespace) {
        this.trigger('whitespaceChanged', { value: this.query });
      }

      else if (!isSameQuery) {
        this.trigger('queryChanged', { value: this.query = inputValue });
      }
    },

    // public methods
    // --------------

    destroy: function() {
      this.$hint.off('.tt');
      this.$input.off('.tt');

      this.$hint = this.$input = this.$overflowHelper = null;
    },

    focus: function() {
      this.$input.focus();
    },

    blur: function() {
      this.$input.blur();
    },

    getQuery: function() {
      return this.query;
    },

    getInputValue: function() {
      return this.$input.val();
    },

    setInputValue: function(value, silent) {
      this.$input.val(value);

      // strict equal to support function(value) signature
      if (silent !== true) {
        this._compareQueryToInputValue();
      }
    },

    getHintValue: function() {
      return this.$hint.val();
    },

    setHintValue: function(value) {
      this.$hint.val(value);
    },

    getLanguageDirection: function() {
      return (this.$input.css('direction') || 'ltr').toLowerCase();
    },

    isOverflow: function() {
      this.$overflowHelper.text(this.getInputValue());

      return this.$overflowHelper.width() > this.$input.width();
    },

    isCursorAtEnd: function() {
      var valueLength = this.$input.val().length,
          selectionStart = this.$input[0].selectionStart,
          range;

      if (utils.isNumber(selectionStart)) {
       return selectionStart === valueLength;
      }

      else if (document.selection) {
        // this won't work unless the input has focus, the good news
        // is this code should only get called when the input has focus
        range = document.selection.createRange();
        range.moveStart('character', -valueLength);

        return valueLength === range.text.length;
      }

      return true;
    }
  });

  return InputView;

  function buildOverflowHelper($input) {
    return $('')
    .css({
      // position helper off-screen
      position: 'absolute',
      left: '-9999px',
      visibility: 'hidden',
      // avoid line breaks
      whiteSpace: 'nowrap',
      // use same font css as input to calculate accurate width
      fontFamily: $input.css('font-family'),
      fontSize: $input.css('font-size'),
      fontStyle: $input.css('font-style'),
      fontVariant: $input.css('font-variant'),
      fontWeight: $input.css('font-weight'),
      wordSpacing: $input.css('word-spacing'),
      letterSpacing: $input.css('letter-spacing'),
      textIndent: $input.css('text-indent'),
      textRendering: $input.css('text-rendering'),
      textTransform: $input.css('text-transform')
    })
    .insertAfter($input);
  }

  function compareQueries(a, b) {
    // strips leading whitespace and condenses all whitespace
    a = (a || '').replace(/^\s*/g, '').replace(/\s{2,}/g, ' ').toLowerCase();
    b = (b || '').replace(/^\s*/g, '').replace(/\s{2,}/g, ' ').toLowerCase();

    return a === b;
  }
})();
<commit_msg>Fix some input value oddities.<commit_after>/*
 * typeahead.js
 * https://github.com/twitter/typeahead
 * Copyright 2013 Twitter, Inc. and other contributors; Licensed MIT
 */

var InputView = (function() {

  // constructor
  // -----------

  function InputView(o) {
    var that = this;

    utils.bindAll(this);

    this.specialKeyCodeMap = {
      9: 'tab',
      27: 'esc',
      37: 'left',
      39: 'right',
      13: 'enter',
      38: 'up',
      40: 'down'
    };

    this.query = '';

    this.$hint = $(o.hint);
    this.$input = $(o.input)
    .on('blur.tt', this._handleBlur)
    .on('focus.tt', this._handleFocus)
    .on('keydown.tt', this._handleSpecialKeyEvent);

    // ie7 and ie8 don't support the input event
    // ie9 doesn't fire the input event when characters are removed
    // not sure if ie10 is compatible
    if (!utils.isMsie()) {
      this.$input.on('input.tt', this._compareQueryToInputValue);
    }

    else {
      this.$input
      .on('keydown.tt keypress.tt cut.tt paste.tt', function($e) {
        // if a special key triggered this, ignore it
        if (that.specialKeyCodeMap[$e.which || $e.keyCode]) { return; }

        // give the browser a chance to update the value of the input
        // before checking to see if the query changed
        setTimeout(that._compareQueryToInputValue, 0);
      });
    }

    // helps with calculating the width of the input's value
    this.$overflowHelper = buildOverflowHelper(this.$input);
  }

  utils.mixin(InputView.prototype, EventTarget, {
    // private methods
    // ---------------

    _handleFocus: function() {
      this.trigger('focused');
    },

    _handleBlur: function() {
      this.trigger('blured');
    },

    _handleSpecialKeyEvent: function($e) {
      // which is normalized and consistent (but not for IE)
      var keyName = this.specialKeyCodeMap[$e.which || $e.keyCode];

      keyName && this.trigger(keyName + 'Keyed', $e);
    },

    _compareQueryToInputValue: function() {
      var inputValue = this.getInputValue(),
          isSameQuery = compareQueries(this.query, inputValue),
          isSameQueryExceptWhitespace = isSameQuery ?
            this.query.length !== inputValue.length : false;

      if (isSameQueryExceptWhitespace) {
        this.trigger('whitespaceChanged', { value: this.query });
      }

      else if (!isSameQuery) {
        this.trigger('queryChanged', { value: this.query = inputValue });
      }
    },

    // public methods
    // --------------

    destroy: function() {
      this.$hint.off('.tt');
      this.$input.off('.tt');

      this.$hint = this.$input = this.$overflowHelper = null;
    },

    focus: function() {
      this.$input.focus();
    },

    blur: function() {
      this.$input.blur();
    },

    getQuery: function() {
      return this.query;
    },

    getInputValue: function() {
      return this.$input.val();
    },

    setInputValue: function(value, silent) {
      this.$input.val(value);

      // strict equal to support function(value) signature
      if (silent !== true) {
        this._compareQueryToInputValue();
      }
    },

    getHintValue: function() {
      return this.$hint.val();
    },

    setHintValue: function(value) {
      this.$hint.val(value);
    },

    getLanguageDirection: function() {
      return (this.$input.css('direction') || 'ltr').toLowerCase();
    },

    isOverflow: function() {
      this.$overflowHelper.text(this.getInputValue());

      return this.$overflowHelper.width() > this.$input.width();
    },

    isCursorAtEnd: function() {
      var valueLength = this.$input.val().length,
          selectionStart = this.$input[0].selectionStart,
          range;

      if (utils.isNumber(selectionStart)) {
       return selectionStart === valueLength;
      }

      else if (document.selection) {
        // this won't work unless the input has focus, the good news
        // is this code should only get called when the input has focus
        range = document.selection.createRange();
        range.moveStart('character', -valueLength);

        return valueLength === range.text.length;
      }

      return true;
    }
  });

  return InputView;

  function buildOverflowHelper($input) {
    return $('')
    .css({
      // position helper off-screen
      position: 'absolute',
      left: '-9999px',
      visibility: 'hidden',
      // avoid line breaks
      whiteSpace: 'nowrap',
      // use same font css as input to calculate accurate width
      fontFamily: $input.css('font-family'),
      fontSize: $input.css('font-size'),
      fontStyle: $input.css('font-style'),
      fontVariant: $input.css('font-variant'),
      fontWeight: $input.css('font-weight'),
      wordSpacing: $input.css('word-spacing'),
      letterSpacing: $input.css('letter-spacing'),
      textIndent: $input.css('text-indent'),
      textRendering: $input.css('text-rendering'),
      textTransform: $input.css('text-transform')
    })
    .insertAfter($input);
  }

  function compareQueries(a, b) {
    // strips leading whitespace and condenses all whitespace
    a = (a || '').replace(/^\s*/g, '').replace(/\s{2,}/g, ' ');
    b = (b || '').replace(/^\s*/g, '').replace(/\s{2,}/g, ' ');

    return a === b;
  }
})();
<|endoftext|>