diff --git a/lodash.js b/lodash.js index 32cfbd49d..0449afb05 100644 --- a/lodash.js +++ b/lodash.js @@ -457,7 +457,7 @@ index = fromIndex - 1; while (++index < length) { - // manually coerce `value` to string because `hasOwnProperty`, in some + // manually coerce `value` to a string because `hasOwnProperty`, in some // older versions of Firefox, coerces objects incorrectly var key = array[index] + ''; (hasOwnProperty.call(cache, key) ? cache[key] : (cache[key] = [])).push(array[index]); @@ -3004,8 +3004,9 @@ computed = callback ? callback(value, index, array) : value; if (isLarge) { - var key = computed + ''; - seen = hasOwnProperty.call(cache, key) ? cache[key] : (cache[key] = []); + // manually coerce `computed` to a string because `hasOwnProperty`, in + // some older versions of Firefox, coerces objects incorrectly + seen = hasOwnProperty.call(cache, computed + '') ? cache[computed] : (cache[computed] = []); } if (isSorted ? !index || seen[seen.length - 1] !== computed @@ -3697,7 +3698,7 @@ * * // using custom template delimiters * _.templateSettings = { - * 'interpolate': /\{\{([\s\S]+?)\}\}/g + * 'interpolate': /{{([\s\S]+?)}}/g * }; * * _.template('hello {{ name }}!', { 'name': 'mustache' }); @@ -3744,11 +3745,18 @@ // compile regexp to match each delimiter var reDelimiters = RegExp( (options.escape || settings.escape || reNoMatch).source + '|' + - (options.interpolate || settings.interpolate || reNoMatch).source + '|' + + (options.interpolate || settings.interpolate || reNoMatch).source + + + // match ES6 template delimiters + // http://people.mozilla.org/~jorendorff/es6-draft.html#sec-7.8.6 + '|\\$\\{((?:(?=\\\\?)\\\\?[\\s\\S])*?)}|' + + (options.evaluate || settings.evaluate || reNoMatch).source + '|$' , 'g'); - text.replace(reDelimiters, function(match, escapeValue, interpolateValue, evaluateValue, offset) { + text.replace(reDelimiters, function(match, escapeValue, interpolateValue, es6TemplateValue, evaluateValue, offset) { + interpolateValue || (interpolateValue = es6TemplateValue); + // escape characters that cannot be included in string literals source += text.slice(index, offset).replace(reUnescapedString, escapeStringChar); diff --git a/lodash.min.js b/lodash.min.js index f904d16d3..bc76c42d7 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -14,8 +14,8 @@ t.toString&&"string"==typeof (t+"")))return i;var u=e.constructor,f=t.constructo ,n=(0>n?Tt(0,i+n):n)||0;return"number"==typeof i?-1<(yt.call(e)==Pt?e.indexOf(t,n):j(e,t,n)):P(e,function(e){return++r>=n&&e===t})}function C(e,t,r){var i=n,t=f(t,r);return an(e,function(e,n,r){return i=!!t(e,n,r)}),i}function k(e,t,n){var r=[],t=f(t,n);return an(e,function(e,n,i){t(e,n,i)&&r.push(e)}),r}function L(e,t,r){var i,t=f(t,r);return P(e,function(e,r,s){return t(e,r,s)&&(i=e,n)}),i}function A(e,t,n){var r=-1,i=e?e.length:0,s=Array("number"==typeof i?i:0),t=f(t,n);if(sn(e))for(;++rr&&(r=n,o=e)});else for(;++io&&(o=e[i]);return o}function M(e,t){var n=[];return an(e,function(e){n.push(e[t])}),n}function _(e,t,n,r){var s=3>arguments.length,t=f(t,r);return an(e,function(e,r,o){n=s?(s=i,e):t(n,e,r,o)}),n}function D(e,t,n,r){var s=e,o=e?e.length:0,u=3>arguments.length;if("number"!=typeof o)var a=un(e),o=a.length;else Rt&&yt.call(e)==Pt&&(s=e.split(""));return an(e,function(e,f,l){f=a?a[--o]:--o,n=u?(u=i,s[f]):t.call(r,n,s[f],f,l)}),n}function P(e,t,n){var r,t=f(t,n);return an(e,function(e,n,i){return!(r=t(e,n,i))}),!!r}function H(e,t,n){if(e)return t==r||n?e[0]:gt.call(e,0,t)}function B(e,t){for(var n=-1,r=e?e.length:0,i=[];++nn?Tt(0,i+n):n||0)-1;else if( -n)return r=I(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])j(a,h))(n||l)&&a.push -(h),u.push(r)}return u}function R(e,t){return Wt||bt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/ +n)return r=I(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])j(a,h))(n||l)&&a.push( +h),u.push(r)}return u}function R(e,t){return Wt||bt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/ ,Z=/&(?:amp|lt|gt|quot|#x27);/g,et=/\b__p\+='';/g,tt=/\b(__p\+=)''\+/g,nt=/(__e\(.*?\)|\b__t\))\+'';/g,rt=/\w*$/,it=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,st=RegExp("^"+($.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),ot=/($^)/,ut=/[&<>"']/g,at=/['\n\r\t\u2028\u2029\\]/g,ft="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),lt=Math.ceil,ct=V.concat,ht=Math.floor,pt=st.test(pt=Object.getPrototypeOf )&&pt,dt=$.hasOwnProperty,vt=V.push,mt=$.propertyIsEnumerable,gt=V.slice,yt=$.toString,bt=st.test(bt=gt.bind)&&bt,wt=st.test(wt=Array.isArray)&&wt,Et=e.isFinite,St=e.isNaN,xt=st.test(xt=Object.keys)&&xt,Tt=Math.max,Nt=Math.min,Ct=Math.random,kt="[object Arguments]",Lt="[object Array]",At="[object Boolean]",Ot="[object Date]",Mt="[object Number]",_t="[object Object]",Dt="[object RegExp]",Pt="[object String]",Ht,Bt,jt=(jt={0:1,length:1},V.splice.call(jt,0,1),jt[0]),Ft=n;(function(){function e(){this .x=1}var t=[];e.prototype={valueOf:1,y:1};for(var n in new e)t.push(n);for(n in arguments)Ft=!n;Ht=!/valueOf/.test(t),Bt="x"!=t[0]})(1);var It=!v(arguments),qt="x"!=gt.call("x")[0],Rt="xx"!="x"[0]+Object("x")[0];try{var Ut=("[object Object]",yt.call(e.document||0)==_t)}catch(zt){}var Wt=bt&&/\n|Opera/.test(bt+yt.call(e.opera)),Xt=xt&&/^.+$|true/.test(xt+!!e.attachEvent),Vt={};Vt[kt]=Vt["[object Function]"]=i,Vt[Lt]=Vt[At]=Vt[Ot]=Vt[Mt]=Vt[_t]=Vt[Dt]=Vt[Pt]=n;var $t={"boolean":i,"function":n,object @@ -31,9 +31,9 @@ n||e===i||yt.call(e)==At},s.isDate=function(e){return yt.call(e)==Ot},s.isElemen i[s]=t[n]:i[s[0]]=s[1]}return i},s.omit=function(e,t,n){var r="function"==typeof t,i={};if(r)t=f(t,n);else var s=ct.apply(V,arguments);return Yt(e,function(e,n,o){if(r?!t(e,n,o):0>j(s,n,1))i[n]=e}),i},s.once=function(e){var t,s=i;return function(){return s?t:(s=n,t=e.apply(this,arguments),e=r,t)}},s.pairs=function(e){var t=[];return Zt(e,function(e,n){t.push([n,e])}),t},s.partial=function(e){return a(e,gt.call(arguments,1))},s.pick=function(e,t,n){var r={};if("function"!=typeof t)for(var i=0,s=ct .apply(V,arguments),o=s.length;++i=f?(clearTimeout(u),a=r,s=e.apply(o,i)):u||(u=setTimeout(n,f)),s}},s.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++r=f?(clearTimeout(u),a=r,s=e.apply(o,i)):u||(u=setTimeout(n,f)),s}},s.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++r