Comparing version 7.0.5 to 7.1.0
/** | ||
* bellajs@7.0.5 | ||
* built on: Mon, 12 Jun 2017 10:40:14 GMT | ||
* bellajs@7.1.0 | ||
* built on: Tue, 13 Jun 2017 09:53:49 GMT | ||
* repository: https://github.com/ndaidong/bellajs | ||
@@ -446,2 +446,33 @@ * maintainer: @ndaidong | ||
}; | ||
var curry = function curry(fn) { | ||
var totalArguments = fn.length; | ||
var next = function next(argumentLength, rest) { | ||
if (argumentLength > 0) { | ||
return function () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return next(argumentLength - args.length, [].concat(toConsumableArray(rest), args)); | ||
}; | ||
} | ||
return fn.apply(undefined, toConsumableArray(rest)); | ||
}; | ||
return next(totalArguments, []); | ||
}; | ||
var compose = function compose() { | ||
for (var _len2 = arguments.length, fns = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
fns[_key2] = arguments[_key2]; | ||
} | ||
return fns.reduce(function (prev, curr) { | ||
return function (x) { | ||
return prev(curr(x)); | ||
}; | ||
}); | ||
}; | ||
var pipe = function pipe() { | ||
for (var _len3 = arguments.length, fns = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { | ||
fns[_key3] = arguments[_key3]; | ||
} | ||
return compose.apply(null, fns.reverse()); | ||
}; | ||
var now = function now() { | ||
@@ -491,2 +522,5 @@ return new Date(); | ||
exports.unique = unique; | ||
exports.curry = curry; | ||
exports.compose = compose; | ||
exports.pipe = pipe; | ||
exports.now = now; | ||
@@ -493,0 +527,0 @@ exports.time = time; |
@@ -1,2 +0,2 @@ | ||
// bellajs@7.0.5, by @ndaidong - built on Mon, 12 Jun 2017 10:40:14 GMT - published under MIT license | ||
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(n.bella=n.bella||{})}(this,function(n){"use strict";var r=function(){for(var n=[],r=0;64>r;)n[r]=0|4294967296*Math.abs(Math.sin(++r));return function(r){for(var e,t,i,o,u=[],a=(r=unescape(encodeURI(r))).length,c=[e=1732584193,t=-271733879,~e,~t],f=0;f<=a;)u[f>>2]|=(r.charCodeAt(f)||128)<<f++%4*8;for(u[r=16*(a+8>>6)+14]=8*a,f=0;f<r;f+=16){for(a=c,o=0;64>o;)a=[i=a[3],(e=0|a[1])+((i=a[0]+[e&(t=a[2])|~e&i,i&e|~i&t,e^t^i,t^(e|~i)][a=o>>4]+(n[o]+(0|u[[o,5*o+1,3*o+5,7*o][a]%16+f])))<<(a=[7,12,17,22,5,9,14,20,4,11,16,23,6,10,15,21][4*a+o++%4])|i>>>32-a),e,t];for(o=4;o;)c[--o]=c[o]+a[o]}for(r="";32>o;)r+=(c[o>>3]>>4*(1^7&o++)&15).toString(16);return r}}(),e=function(n){if(Array.isArray(n)){for(var r=0,e=Array(n.length);r<n.length;r++)e[r]=n[r];return e}return Array.from(n)},t=Number.MAX_SAFE_INTEGER,i=function(n){return{}.toString.call(n)},o=function(n){return"[object Null]"===i(n)},u=function(n){return"[object Undefined]"===i(n)},a=function(n){return"[object Function]"===i(n)},c=function(n){return"[object String]"===i(n)},f=function(n){return"[object Number]"===i(n)},l=function(n){return Number.isInteger(n)},s=function(n){return Array.isArray(n)},g=function(n){return"[object Object]"===i(n)&&!s(n)},p=function(n){return!0===n||!1===n},h=function(n){return n instanceof Date&&!isNaN(n.valueOf())},v=function(n){return i(n).match(/^\[object HTML\w*Element]$/)},d=function(n){var r=/^[a-z]+$/i;return c(n)&&r.test(n)},m=function(n){var r=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;return c(n)&&r.test(n)},b=function(n){return!n||u(n)||o(n)||c(n)&&""===n||s(n)&&"[]"===JSON.stringify(n)||g(n)&&"{}"===JSON.stringify(n)},w=function(n,r){return!(!n||!r)&&Object.prototype.hasOwnProperty.call(n,r)},y=function n(r,e){var t=!0;if(b(r)&&b(e))return!0;if(h(r)&&h(e))return r.getTime()===e.getTime();if(f(r)&&f(e)||c(r)&&c(e))return r===e;if(s(r)&&s(e)){if(r.length!==e.length)return!1;if(r.length>0)for(var i=0,o=r.length;i<o;i++)if(!n(r[i],e[i])){t=!1;break}}else if(g(r)&&g(e)){var u=[],a=[];for(var l in r)w(r,l)&&u.push(l);for(var p in e)w(e,p)&&a.push(p);if(u.length!==a.length)return!1;for(var v in r)if(!w(e,v)||!n(r[v],e[v])){t=!1;break}}return t},j=function(n){var r=f(n)?String(n):n;if(!c(r))throw new Error("InvalidInput: String required.");return r},A=function(n){var r=j(n);return encodeURIComponent(r)},E=function(n){var r=j(n);return decodeURIComponent(r.replace(/\+/g," "))},S=function(n){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],e=j(n);return(e=e.replace(/^[\s\xa0]+|[\s\xa0]+$/g,""))&&r&&(e=e.replace(/\r?\n|\r/g," ").replace(/\s\s+|\r/g," ")),e},M=function(n,r){var e=j(n),t=r||140;if(e.length<=t)return e;var i=e.substring(0,t),o=i.split(" "),u="";return o.length>1?(o.pop(),(u+=o.join(" ")).length<e.length&&(u+="...")):u=(i=i.substring(0,t-3))+"...",u},O=function(n){var r=j(n);return S(r.replace(/<.*?>/gi," ").replace(/\s\s+/g," "))},N=function(n){return j(n).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")},x=function(n){return j(n).replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")},I=function(n){var r=j(n);return 1===r.length?r.toUpperCase():(r=r.toLowerCase()).charAt(0).toUpperCase()+r.slice(1)},C=function(n){var r=[];return j(n).split(" ").forEach(function(n){r.push(I(n))}),r.join(" ")},U=function(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"0",t=j(n);return t.length>=r?t:new Array(r-t.length+1).join(e)+t},R=function(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"0",t=j(n);return t.length>=r?t:t+new Array(r-t.length+1).join(e)},T=function(n,r){var e=j(n);if(!l(r)||r<1)return e;if(e.length*r>=1<<28)throw new RangeError("Repeat count must not overflow maximum string size.");var t=[];return t.length=r,t.fill(e,0,r).join("")},q=function n(r,e,t){var i=j(r);if(f(e)&&(e=String(e)),f(t)&&(t=String(t)),c(e)&&c(t)){var o=i.split(e);i=o.join(t)}else if(s(e)&&c(t))e.forEach(function(r){i=n(i,r,t)});else if(s(e)&&s(t)&&e.length===t.length){var u=e.length;if(u>0)for(var a=0;a<u;a++){var l=e[a],g=t[a];i=n(i,l,g)}}return i},D=function(n){var r=j(n),e={a:"á|à|ả|ã|ạ|ă|ắ|ặ|ằ|ẳ|ẵ|â|ấ|ầ|ẩ|ẫ|ậ|ä",A:"Á|À|Ả|Ã|Ạ|Ă|Ắ|Ặ|Ằ|Ẳ|Ẵ|Â|Ấ|Ầ|Ẩ|Ẫ|Ậ|Ä",c:"ç",C:"Ç",d:"đ",D:"Đ",e:"é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ|ë",E:"É|È|Ẻ|Ẽ|Ẹ|Ê|Ế|Ề|Ể|Ễ|Ệ|Ë",i:"í|ì|ỉ|ĩ|ị|ï|î",I:"Í|Ì|Ỉ|Ĩ|Ị|Ï|Î",o:"ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ|ö",O:"Ó|Ò|Ỏ|Õ|Ọ|Ô|Ố|Ồ|Ổ|Ô|Ộ|Ơ|Ớ|Ờ|Ở|Ỡ|Ợ|Ö",u:"ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự|û",U:"Ú|Ù|Ủ|Ũ|Ụ|Ư|Ứ|Ừ|Ử|Ữ|Ự|Û",y:"ý|ỳ|ỷ|ỹ|ỵ",Y:"Ý|Ỳ|Ỷ|Ỹ|Ỵ"},t=function(n,e){r=q(r,n,e)};for(var i in e)!function(n){w(e,n)&&e[n].split("|").forEach(function(r){return t(r,n)})}(i);return r},L=function(n,r){var e=S(D(n)),t=r||"-";return e.toLowerCase().replace(/\W+/g," ").replace(/\s+/g," ").replace(/\s/g,t)},P=function(n,r){var e=[];return r&&(c(r)||g(r)||s(r))?function n(r,t,i){i&&e.push(i);var o=[];for(var u in t)if(w(t,u)){var a=t[u];if(f(a)&&(a=String(a)),g(a)||s(a))o.push({key:u,data:a});else if(c(a)){a=q(a,["{","}"],["{","}"]);var l=e.concat([u]),p=new RegExp("{"+l.join(".")+"}","gi");r=r.replace(p,a)}}return o.length>0&&o.forEach(function(e){r=n(r,e.data,e.key)}),S(r,!0)}(n,r):n},k=function(n){return{compile:function(r){return P(n,r)}}},z=function(n,r){if((!n||n<0)&&(n=0),r||(r=t),n===r)return r;n>r&&(n=Math.min(n,r),r=Math.max(n,r));var e=n,i=r-n+1;return Math.floor(Math.random()*i)+e},$=function(n){for(var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",e="abcdefghijklmnopqrstuvwxyz",t=[e,e.toUpperCase(),"0123456789"].join("").split("").sort(function(){return Math.random()>.5}).join(""),i=t.length,o=Math.max(n||32,r.length),u=r;u.length<o;){var a=z(0,i);u+=t.charAt(a)||""}return u},_=function n(r){if(h(r))return new Date(r.valueOf());var t=function(r){var e=Object.create({});for(var t in r)w(r,t)&&(e[t]=n(r[t]));return e};return s(r)?function r(i){return[].concat(e(i)).map(function(e){return s(e)?r(e):g(e)?t(e):n(e)})}(r):g(r)?t(r):r},F=function n(r,e){var t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];for(var o in r)if(!(i.length>0&&i.includes(o))&&(!t||t&&e.hasOwnProperty(o))){var u=r[o],a=e[o];g(a)&&g(u)||s(a)&&s(u)?e[o]=n(u,e[o],t,i):e[o]=_(u)}return e},H=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return[].concat(e(new Set(n)))},J=function(){return new Date},B=function(){return Date.now()};n.isNull=o,n.isUndefined=u,n.isFunction=a,n.isString=c,n.isNumber=f,n.isInteger=l,n.isArray=s,n.isObject=g,n.isBoolean=p,n.isDate=h,n.isElement=v,n.isLetter=d,n.isEmail=m,n.isEmpty=b,n.hasProperty=w,n.equals=y,n.toString=j,n.encode=A,n.decode=E,n.trim=S,n.truncate=M,n.stripTags=O,n.escapeHTML=N,n.unescapeHTML=x,n.ucfirst=I,n.ucwords=C,n.leftPad=U,n.rightPad=R,n.repeat=T,n.replaceAll=q,n.stripAccent=D,n.createAlias=L,n.template=k,n.random=z,n.createId=$,n.clone=_,n.copies=F,n.unique=H,n.now=J,n.time=B,n.md5=r,Object.defineProperty(n,"__esModule",{value:!0})}); | ||
// bellajs@7.1.0, by @ndaidong - built on Tue, 13 Jun 2017 09:53:49 GMT - published under MIT license | ||
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(n.bella=n.bella||{})}(this,function(n){"use strict";var r=function(){for(var n=[],r=0;64>r;)n[r]=0|4294967296*Math.abs(Math.sin(++r));return function(r){for(var e,t,i,o,u=[],a=(r=unescape(encodeURI(r))).length,c=[e=1732584193,t=-271733879,~e,~t],f=0;f<=a;)u[f>>2]|=(r.charCodeAt(f)||128)<<f++%4*8;for(u[r=16*(a+8>>6)+14]=8*a,f=0;f<r;f+=16){for(a=c,o=0;64>o;)a=[i=a[3],(e=0|a[1])+((i=a[0]+[e&(t=a[2])|~e&i,i&e|~i&t,e^t^i,t^(e|~i)][a=o>>4]+(n[o]+(0|u[[o,5*o+1,3*o+5,7*o][a]%16+f])))<<(a=[7,12,17,22,5,9,14,20,4,11,16,23,6,10,15,21][4*a+o++%4])|i>>>32-a),e,t];for(o=4;o;)c[--o]=c[o]+a[o]}for(r="";32>o;)r+=(c[o>>3]>>4*(1^7&o++)&15).toString(16);return r}}(),e=function(n){if(Array.isArray(n)){for(var r=0,e=Array(n.length);r<n.length;r++)e[r]=n[r];return e}return Array.from(n)},t=Number.MAX_SAFE_INTEGER,i=function(n){return{}.toString.call(n)},o=function(n){return"[object Null]"===i(n)},u=function(n){return"[object Undefined]"===i(n)},a=function(n){return"[object Function]"===i(n)},c=function(n){return"[object String]"===i(n)},f=function(n){return"[object Number]"===i(n)},l=function(n){return Number.isInteger(n)},g=function(n){return Array.isArray(n)},s=function(n){return"[object Object]"===i(n)&&!g(n)},p=function(n){return!0===n||!1===n},h=function(n){return n instanceof Date&&!isNaN(n.valueOf())},v=function(n){return i(n).match(/^\[object HTML\w*Element]$/)},d=function(n){var r=/^[a-z]+$/i;return c(n)&&r.test(n)},m=function(n){var r=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;return c(n)&&r.test(n)},y=function(n){return!n||u(n)||o(n)||c(n)&&""===n||g(n)&&"[]"===JSON.stringify(n)||s(n)&&"{}"===JSON.stringify(n)},b=function(n,r){return!(!n||!r)&&Object.prototype.hasOwnProperty.call(n,r)},w=function n(r,e){var t=!0;if(y(r)&&y(e))return!0;if(h(r)&&h(e))return r.getTime()===e.getTime();if(f(r)&&f(e)||c(r)&&c(e))return r===e;if(g(r)&&g(e)){if(r.length!==e.length)return!1;if(r.length>0)for(var i=0,o=r.length;i<o;i++)if(!n(r[i],e[i])){t=!1;break}}else if(s(r)&&s(e)){var u=[],a=[];for(var l in r)b(r,l)&&u.push(l);for(var p in e)b(e,p)&&a.push(p);if(u.length!==a.length)return!1;for(var v in r)if(!b(e,v)||!n(r[v],e[v])){t=!1;break}}return t},j=function(n){var r=f(n)?String(n):n;if(!c(r))throw new Error("InvalidInput: String required.");return r},A=function(n){var r=j(n);return encodeURIComponent(r)},E=function(n){var r=j(n);return decodeURIComponent(r.replace(/\+/g," "))},S=function(n){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],e=j(n);return(e=e.replace(/^[\s\xa0]+|[\s\xa0]+$/g,""))&&r&&(e=e.replace(/\r?\n|\r/g," ").replace(/\s\s+|\r/g," ")),e},M=function(n,r){var e=j(n),t=r||140;if(e.length<=t)return e;var i=e.substring(0,t),o=i.split(" "),u="";return o.length>1?(o.pop(),(u+=o.join(" ")).length<e.length&&(u+="...")):u=(i=i.substring(0,t-3))+"...",u},O=function(n){var r=j(n);return S(r.replace(/<.*?>/gi," ").replace(/\s\s+/g," "))},N=function(n){return j(n).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")},x=function(n){return j(n).replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")},I=function(n){var r=j(n);return 1===r.length?r.toUpperCase():(r=r.toLowerCase()).charAt(0).toUpperCase()+r.slice(1)},C=function(n){var r=[];return j(n).split(" ").forEach(function(n){r.push(I(n))}),r.join(" ")},U=function(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"0",t=j(n);return t.length>=r?t:new Array(r-t.length+1).join(e)+t},R=function(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"0",t=j(n);return t.length>=r?t:t+new Array(r-t.length+1).join(e)},T=function(n,r){var e=j(n);if(!l(r)||r<1)return e;if(e.length*r>=1<<28)throw new RangeError("Repeat count must not overflow maximum string size.");var t=[];return t.length=r,t.fill(e,0,r).join("")},q=function n(r,e,t){var i=j(r);if(f(e)&&(e=String(e)),f(t)&&(t=String(t)),c(e)&&c(t)){var o=i.split(e);i=o.join(t)}else if(g(e)&&c(t))e.forEach(function(r){i=n(i,r,t)});else if(g(e)&&g(t)&&e.length===t.length){var u=e.length;if(u>0)for(var a=0;a<u;a++){var l=e[a],s=t[a];i=n(i,l,s)}}return i},D=function(n){var r=j(n),e={a:"á|à|ả|ã|ạ|ă|ắ|ặ|ằ|ẳ|ẵ|â|ấ|ầ|ẩ|ẫ|ậ|ä",A:"Á|À|Ả|Ã|Ạ|Ă|Ắ|Ặ|Ằ|Ẳ|Ẵ|Â|Ấ|Ầ|Ẩ|Ẫ|Ậ|Ä",c:"ç",C:"Ç",d:"đ",D:"Đ",e:"é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ|ë",E:"É|È|Ẻ|Ẽ|Ẹ|Ê|Ế|Ề|Ể|Ễ|Ệ|Ë",i:"í|ì|ỉ|ĩ|ị|ï|î",I:"Í|Ì|Ỉ|Ĩ|Ị|Ï|Î",o:"ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ|ö",O:"Ó|Ò|Ỏ|Õ|Ọ|Ô|Ố|Ồ|Ổ|Ô|Ộ|Ơ|Ớ|Ờ|Ở|Ỡ|Ợ|Ö",u:"ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự|û",U:"Ú|Ù|Ủ|Ũ|Ụ|Ư|Ứ|Ừ|Ử|Ữ|Ự|Û",y:"ý|ỳ|ỷ|ỹ|ỵ",Y:"Ý|Ỳ|Ỷ|Ỹ|Ỵ"},t=function(n,e){r=q(r,n,e)};for(var i in e)!function(n){b(e,n)&&e[n].split("|").forEach(function(r){return t(r,n)})}(i);return r},L=function(n,r){var e=S(D(n)),t=r||"-";return e.toLowerCase().replace(/\W+/g," ").replace(/\s+/g," ").replace(/\s/g,t)},P=function(n,r){var e=[];return r&&(c(r)||s(r)||g(r))?function n(r,t,i){i&&e.push(i);var o=[];for(var u in t)if(b(t,u)){var a=t[u];if(f(a)&&(a=String(a)),s(a)||g(a))o.push({key:u,data:a});else if(c(a)){a=q(a,["{","}"],["{","}"]);var l=e.concat([u]),p=new RegExp("{"+l.join(".")+"}","gi");r=r.replace(p,a)}}return o.length>0&&o.forEach(function(e){r=n(r,e.data,e.key)}),S(r,!0)}(n,r):n},k=function(n){return{compile:function(r){return P(n,r)}}},z=function(n,r){if((!n||n<0)&&(n=0),r||(r=t),n===r)return r;n>r&&(n=Math.min(n,r),r=Math.max(n,r));var e=n,i=r-n+1;return Math.floor(Math.random()*i)+e},$=function(n){for(var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",e="abcdefghijklmnopqrstuvwxyz",t=[e,e.toUpperCase(),"0123456789"].join("").split("").sort(function(){return Math.random()>.5}).join(""),i=t.length,o=Math.max(n||32,r.length),u=r;u.length<o;){var a=z(0,i);u+=t.charAt(a)||""}return u},_=function n(r){if(h(r))return new Date(r.valueOf());var t=function(r){var e=Object.create({});for(var t in r)b(r,t)&&(e[t]=n(r[t]));return e};return g(r)?function r(i){return[].concat(e(i)).map(function(e){return g(e)?r(e):s(e)?t(e):n(e)})}(r):s(r)?t(r):r},F=function n(r,e){var t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];for(var o in r)if(!(i.length>0&&i.includes(o))&&(!t||t&&e.hasOwnProperty(o))){var u=r[o],a=e[o];s(a)&&s(u)||g(a)&&g(u)?e[o]=n(u,e[o],t,i):e[o]=_(u)}return e},H=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return[].concat(e(new Set(n)))},J=function(n){return function r(t,i){return t>0?function(){for(var n=arguments.length,o=Array(n),u=0;u<n;u++)o[u]=arguments[u];return r(t-o.length,[].concat(e(i),o))}:n.apply(void 0,e(i))}(n.length,[])},B=function(){for(var n=arguments.length,r=Array(n),e=0;e<n;e++)r[e]=arguments[e];return r.reduce(function(n,r){return function(e){return n(r(e))}})},G=function(){for(var n=arguments.length,r=Array(n),e=0;e<n;e++)r[e]=arguments[e];return B.apply(null,r.reverse())},W=function(){return new Date},X=function(){return Date.now()};n.isNull=o,n.isUndefined=u,n.isFunction=a,n.isString=c,n.isNumber=f,n.isInteger=l,n.isArray=g,n.isObject=s,n.isBoolean=p,n.isDate=h,n.isElement=v,n.isLetter=d,n.isEmail=m,n.isEmpty=y,n.hasProperty=b,n.equals=w,n.toString=j,n.encode=A,n.decode=E,n.trim=S,n.truncate=M,n.stripTags=O,n.escapeHTML=N,n.unescapeHTML=x,n.ucfirst=I,n.ucwords=C,n.leftPad=U,n.rightPad=R,n.repeat=T,n.replaceAll=q,n.stripAccent=D,n.createAlias=L,n.template=k,n.random=z,n.createId=$,n.clone=_,n.copies=F,n.unique=H,n.curry=J,n.compose=B,n.pipe=G,n.now=W,n.time=X,n.md5=r,Object.defineProperty(n,"__esModule",{value:!0})}); |
{ | ||
"version": "7.0.5", | ||
"version": "7.1.0", | ||
"name": "bellajs", | ||
@@ -4,0 +4,0 @@ "description": "A useful helper for any javascript program", |
148
README.md
@@ -13,2 +13,24 @@ BellaJS | ||
# Contents | ||
* [Setup](#setup) | ||
* [APIs](#apis) | ||
* [DataType detection](#datatype-detection) | ||
* [String manipulation](#string-manipulation) | ||
* [Template](#template) | ||
* [Other utils](#other-utils) | ||
* [clone](#cloneanything-val) | ||
* [copies](#copiesobject-source-object-target-boolean-requirematching-array-excepts) | ||
* [createId](#createidnumber-length--string-prefix) | ||
* [equals](#equalsanything-a-anything-b) | ||
* [md5](#md5string-s) | ||
* [random](#randomnumber-min--number-max) | ||
* [unique](#uniquearray-a) | ||
* [curry](#curryfn) | ||
* [compose](#composef1-f2-fn) | ||
* [pipe](#pipef1-f2-fn) | ||
* [Test](#test) | ||
* [License](#license) | ||
## Setup | ||
@@ -73,3 +95,3 @@ | ||
### String manipulation | ||
### String manipulation | ||
- .createAlias(String s) | ||
@@ -218,7 +240,131 @@ - .encode(String s) | ||
##### .createId([Number length [, String prefix]]) | ||
``` | ||
import {createId} from 'bellajs'; | ||
createId(); // => random 32 chars | ||
createId(16); // => random 16 chars | ||
createId(5); // => random 5 chars | ||
createId(5, 'X_'); // => X_{random 3 chars} | ||
``` | ||
##### .equals(Anything a, Anything b) | ||
``` | ||
import {equals} from 'bellajs'; | ||
equals({}, {}); // => true | ||
equals(0, 1); // => false | ||
``` | ||
##### .md5(String s) | ||
``` | ||
import {md5} from 'bellajs'; | ||
md5('abc'); // => 900150983cd24fb0d6963f7d28e17f72 | ||
``` | ||
##### .random([Number min [, Number max]]) | ||
``` | ||
import {random} from 'bellajs'; | ||
random(); // => a random integer | ||
random(1, 5); // => a random integer between 3 and 5, including 1 and 5 | ||
``` | ||
##### .unique(Array a) | ||
``` | ||
import {unique} from 'bellajs'; | ||
unique([1, 2, 3, 2, 3, 1, 5]); // => [ 1, 2, 3, 5 ] | ||
``` | ||
##### .curry(fn) | ||
``` | ||
import {curry} from 'bellajs'; | ||
let sum = curry((a, b, c) => { | ||
return a + b + c; | ||
}); | ||
sum(3)(2)(1) // => 6 | ||
sum(1)(2)(3) // => 6 | ||
sum(1, 2)(3) // => 6 | ||
sum(1)(2, 3) // => 6 | ||
sum(1, 2, 3) // => 6 | ||
``` | ||
##### .compose(f1, f2, ...fN) | ||
Performs right-to-left function composition. | ||
``` | ||
import {compose} from 'bellajs'; | ||
let f1 = (name) => { | ||
return `f1 ${name}`; | ||
}; | ||
let f2 = (name) => { | ||
return `f2 ${name}`; | ||
}; | ||
let f3 = (name) => { | ||
return `f3 ${name}`; | ||
}; | ||
let addF = compose(f1, f2, f3); | ||
addF('Hello') // => 'f1 f2 f3 Hello' | ||
let add1 = (num) => { | ||
return num + 1; | ||
}; | ||
let mult2 = (num) => { | ||
return num * 2; | ||
}; | ||
let add1AndMult2 = compose(add1, mult2); | ||
add1AndMult2(3) // => 7 | ||
// because multiple to 2 first, then add 1 late => 3 * 2 + 1 | ||
``` | ||
##### .pipe(f1, f2, ...fN) | ||
Performs left-to-right function composition. | ||
``` | ||
import {pipe} from 'bellajs'; | ||
let f1 = (name) => { | ||
return `f1 ${name}`; | ||
}; | ||
let f2 = (name) => { | ||
return `f2 ${name}`; | ||
}; | ||
let f3 = (name) => { | ||
return `f3 ${name}`; | ||
}; | ||
let addF = pipe(f1, f2, f3); | ||
addF('Hello') // => 'f3 f2 f1 Hello' | ||
let add1 = (num) => { | ||
return num + 1; | ||
}; | ||
let mult2 = (num) => { | ||
return num * 2; | ||
}; | ||
let add1AndMult2 = pipe(add1, mult2); | ||
add1AndMult2(3) // => 8 | ||
// because add 1 first, then multiple to 2 late => (3 + 1) * 2 | ||
``` | ||
## Note | ||
@@ -225,0 +371,0 @@ |
@@ -480,2 +480,27 @@ /** | ||
export let curry = (fn) => { | ||
let totalArguments = fn.length; | ||
let next = (argumentLength, rest) => { | ||
if (argumentLength > 0) { | ||
return (...args) => { | ||
return next(argumentLength - args.length, [...rest, ...args]); | ||
}; | ||
} | ||
return fn(...rest); | ||
}; | ||
return next(totalArguments, []); | ||
}; | ||
export let compose = (...fns) => { | ||
return fns.reduce((prev, curr) => { | ||
return (x) => { | ||
return prev(curr(x)); | ||
}; | ||
}); | ||
}; | ||
export let pipe = (...fns) => { | ||
return compose.apply(null, fns.reverse()); | ||
}; | ||
export let now = () => { | ||
@@ -482,0 +507,0 @@ return new Date(); |
@@ -15,3 +15,3 @@ /** | ||
let arr = []; | ||
while (arr.length < 10000) { | ||
while (arr.length < 1000) { | ||
let key = bella.createId(); | ||
@@ -18,0 +18,0 @@ assert.deepEquals(key.length, 32, 'key must be a string with 32 chars'); |
Sorry, the diff of this file is not supported yet
29
390
4
92598
2320