react / wstein / node_modules / jest-cli / node_modules / istanbul / node_modules / handlebars / dist / amd / handlebars / utils.js
80713 viewsdefine(1["exports"],2function(__exports__) {3"use strict";4/*jshint -W004 */5var escape = {6"&": "&",7"<": "<",8">": ">",9'"': """,10"'": "'",11"`": "`"12};1314var badChars = /[&<>"'`]/g;15var possible = /[&<>"'`]/;1617function escapeChar(chr) {18return escape[chr];19}2021function extend(obj /* , ...source */) {22for (var i = 1; i < arguments.length; i++) {23for (var key in arguments[i]) {24if (Object.prototype.hasOwnProperty.call(arguments[i], key)) {25obj[key] = arguments[i][key];26}27}28}2930return obj;31}3233__exports__.extend = extend;var toString = Object.prototype.toString;34__exports__.toString = toString;35// Sourced from lodash36// https://github.com/bestiejs/lodash/blob/master/LICENSE.txt37var isFunction = function(value) {38return typeof value === 'function';39};40// fallback for older versions of Chrome and Safari41/* istanbul ignore next */42if (isFunction(/x/)) {43isFunction = function(value) {44return typeof value === 'function' && toString.call(value) === '[object Function]';45};46}47var isFunction;48__exports__.isFunction = isFunction;49/* istanbul ignore next */50var isArray = Array.isArray || function(value) {51return (value && typeof value === 'object') ? toString.call(value) === '[object Array]' : false;52};53__exports__.isArray = isArray;54// Older IE versions do not directly support indexOf so we must implement our own, sadly.55function indexOf(array, value) {56for (var i = 0, len = array.length; i < len; i++) {57if (array[i] === value) {58return i;59}60}61return -1;62}6364__exports__.indexOf = indexOf;65function escapeExpression(string) {66// don't escape SafeStrings, since they're already safe67if (string && string.toHTML) {68return string.toHTML();69} else if (string == null) {70return "";71} else if (!string) {72return string + '';73}7475// Force a string conversion as this will be done by the append regardless and76// the regex test will do this transparently behind the scenes, causing issues if77// an object's to string has escaped characters in it.78string = "" + string;7980if(!possible.test(string)) { return string; }81return string.replace(badChars, escapeChar);82}8384__exports__.escapeExpression = escapeExpression;function isEmpty(value) {85if (!value && value !== 0) {86return true;87} else if (isArray(value) && value.length === 0) {88return true;89} else {90return false;91}92}9394__exports__.isEmpty = isEmpty;function blockParams(params, ids) {95params.path = ids;96return params;97}9899__exports__.blockParams = blockParams;function appendContextPath(contextPath, id) {100return (contextPath ? contextPath + '.' : '') + id;101}102103__exports__.appendContextPath = appendContextPath;104});105106