Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bellajs

Package Overview
Dependencies
Maintainers
1
Versions
147
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bellajs - npm Package Compare versions

Comparing version 3.4.8 to 3.4.9

2

package.json
{
"version": "3.4.8",
"version": "3.4.9",
"name": "bellajs",

@@ -4,0 +4,0 @@ "description": "A set of must-have utilities for JS programs",

@@ -106,5 +106,2 @@ bella.js

// or attach to response object to reuse at another place
res.device = deviceInfo;
res.end();

@@ -171,2 +168,5 @@ });

### Array & Object
- Bella.inherits(Proto o)
- Bella.clone(Array|Object|Date o)
- Bella.copies(Array|Object src, Array|Object dest [, Boolean mustMatch[, Array exclude] ])
- Bella.unique(Array a)

@@ -178,6 +178,2 @@ - Bella.max(Array a)

- Bella.sort(Array a [, String order | Object option ])
- Bella.inherits(Proto o)
- Bella.clone(Array|Object|Date o)
- Bella.copies(Array|Object src, Array|Object dest [, Boolean mustMatch[, Array exclude] ])
- Bella.bind(Object o, Function f)

@@ -273,3 +269,3 @@ How to use Bella.sort?

- A: AM, PM
- O: timezone offset
- O: timezone

@@ -361,5 +357,5 @@ Examples:

Bella.scheduler.once do the same thing as Bella.scheduler.every, but just once. The remain fours methods just are the shortcuts.
Bella.scheduler.once do the same thing as Bella.scheduler.every, but just once. The 4 remain methods yearly(), monthly(), daily(), hourly() can be looked as the shortcuts of every().
The following object Bella.dom, Bella.event and Bella.device are not available on Node.js environment.
The following Bella.dom and Bella.event are not available on Node.js environment.

@@ -366,0 +362,0 @@ ### DOM & Event manipulation

/**
* BellaJS v3.4.8
* BellaJS v3.4.9
* Author by @ndaidong

@@ -530,3 +530,3 @@ * GitHub : https://github.com/techpush/bella.js.git

}
return a;
return a || [];
}

@@ -635,2 +635,19 @@ Bella.max = function(a){

Bella.empty = function (a){
if(isArray(a)){
for(var i=a.length-1; i>=0; i--){
a[i] = null;
delete a[i];
}
a.length=0;
}
else if(isObject(a)){
for(var k in a){
a[k] = null;
delete a[k];
}
}
return a;
}
// for browser only

@@ -637,0 +654,0 @@ if(Bella.ENV=='browser'){

/**
* BellaJS v3.4.8 - min
* BellaJS v3.4.9 - min
* Author by @ndaidong

@@ -11,29 +11,29 @@ * GitHub : https://github.com/techpush/bella.js.git

c=!{toString:null}.propertyIsEnumerable("toString"),b="toString toLocaleString valueOf hasOwnProperty isPrototypeOf propertyIsEnumerable constructor".split(" "),d=b.length;return function(e){if("object"!==typeof e&&("function"!==typeof e||null===e))throw new TypeError("Object.keys called on non-object");var g=[],k;for(k in e)a.call(e,k)&&g.push(k);if(c)for(k=0;k<d;k++)a.call(e,b[k])&&g.push(b[k]);return g}}());var C=function(a){return"undefined"!==a},D=function(a){return!a||null===a||q(a)&&0===a.length||
x(a)&&0===Object.keys(a).length},q=function(a){return null!==a&&"array"==z(a)},n=function(a){return null!==a&&"string"==typeof a},w=function(a){return!isNaN(a)&&"number"==typeof Number(a)},E=function(a){return null!==a&&"function"==z(a)},A=function(a){return null!==a&&"element"==z(a)},x=function(a){return null!==a&&"object"==typeof a};d.isDef=C;d.isNull=function(a){return null===a};d.isEmpty=D;d.isEND=function(a){return D(a)||!C(a)};d.isBoolean=function(a){return!0===a||!1===a};d.isArray=q;d.isString=
n;d.isNumber=w;d.isFunction=E;d.isElement=A;d.isObject=x;var y=function(a){var c={type:"",browser:"",engine:"",version:"",os:""},b=a||navigator.userAgent,d=b.toLowerCase(),e=function(a){return a.test(d)},g=e(/chrome/i),k=e(/safari/i),m=e(/firefox/i),l=e(/vivaldi/i),f=e(/opera/i),h=e(/opera mini/i),r=e(/msie/i),p=e(/midori/i),n=e(/maxthon/i),q=e(/konqueror/i),u=e(/minefield/i),v=e(/omniweb/i),x=e(/ucbrowser/),w=e(/webkit/i),y=e(/gecko/i),z=e(/presto/i),A=e(/trident/i);c.type=function(){var a="Unknown";
w(a)&&0===Object.keys(a).length},q=function(a){return null!==a&&"array"==z(a)},n=function(a){return null!==a&&"string"==typeof a},x=function(a){return!isNaN(a)&&"number"==typeof Number(a)},E=function(a){return null!==a&&"function"==z(a)},A=function(a){return null!==a&&"element"==z(a)},w=function(a){return null!==a&&"object"==typeof a};d.isDef=C;d.isNull=function(a){return null===a};d.isEmpty=D;d.isEND=function(a){return D(a)||!C(a)};d.isBoolean=function(a){return!0===a||!1===a};d.isArray=q;d.isString=
n;d.isNumber=x;d.isFunction=E;d.isElement=A;d.isObject=w;var y=function(a){var c={type:"",browser:"",engine:"",version:"",os:""},b=a||navigator.userAgent,d=b.toLowerCase(),e=function(a){return a.test(d)},g=e(/chrome/i),k=e(/safari/i),m=e(/firefox/i),l=e(/vivaldi/i),f=e(/opera/i),h=e(/opera mini/i),r=e(/msie/i),p=e(/midori/i),n=e(/maxthon/i),q=e(/konqueror/i),u=e(/minefield/i),v=e(/omniweb/i),w=e(/ucbrowser/),x=e(/webkit/i),y=e(/gecko/i),z=e(/presto/i),A=e(/trident/i);c.type=function(){var a="Unknown";
b.match(/GoogleTV|SmartTV|Internet TV|NetCast|NETTV|AppleTV|boxee|Kylo|Roku|DLNADOC|CE\-HTML/i)?a="TV":b.match(/Xbox|PLAYSTATION 3|Wii/i)?a="TV":b.match(/iP(a|ro)d/i)||b.match(/tablet/i)&&!b.match(/RX-34/i)||b.match(/FOLIO/i)?a="tablet":b.match(/Linux/i)&&b.match(/Android/i)&&!b.match(/Fennec|mobi|HTC Magic|HTCX06HT|Nexus One|SC-02B|fone 945/i)?a="tablet":b.match(/Kindle/i)||b.match(/Mac OS/i)&&b.match(/Silk/i)||b.match(/AppleWebKit/i)&&b.match(/Silk/i)&&!b.match(/Playstation Vita/i)?a="tablet":b.match(/GT-P10|SC-01C|SHW-M180S|SGH-T849|SCH-I800|SHW-M180L|SPH-P100|SGH-I987|zt180|HTC( Flyer|_Flyer)|Sprint ATP51|ViewPad7|pandigital(sprnova|nova)|Ideos S7|Dell Streak 7|Advent Vega|A101IT|A70BHT|MID7015|Next2|nook/i)||
b.match(/MB511/i)&&b.match(/RUTEM/i)?a="tablet":b.match(/BOLT|Fennec|Iris|Maemo|Minimo|Mobi|mowser|NetFront|Novarra|Prism|RX-34|Skyfire|Tear|XV6875|XV6975|Google Wireless Transcoder/i)?a="mobile":b.match(/Opera/i)&&b.match(/Windows NT 5/i)&&b.match(/HTC|Xda|Mini|Vario|SAMSUNG\-GT\-i8000|SAMSUNG\-SGH\-i9/i)?a="mobile":b.match(/Windows (NT|XP|ME|9)/)&&!b.match(/Phone/i)&&!b.match(/Bot|Spider|ia_archiver|NewsGator/i)||b.match(/Win( ?9|NT)/i)?a="desktop":b.match(/Macintosh|PowerPC/i)&&!b.match(/Silk/i)?
a="desktop":b.match(/Linux/i)&&b.match(/X11/i)&&!b.match(/Charlotte/i)?a="desktop":b.match(/CrOS/)?a="desktop":b.match(/Solaris|SunOS|BSD/i)?a="desktop":b.match(/curl|Bot|B-O-T|Crawler|Spider|Spyder|Yahoo|ia_archiver|Covario-IDS|findlinks|DataparkSearch|larbin|Mediapartners-Google|NG-Search|Snappy|Teoma|Jeeves|Charlotte|NewsGator|TinEye|Cerberian|SearchSight|Zao|Scrubby|Qseero|PycURL|Pompos|oegp|SBIder|yoogliFetchAgent|yacy|webcollage|VYU2|voyager|updated|truwoGPS|StackRambler|Sqworm|silk|semanticdiscovery|ScoutJet|Nymesis|NetResearchServer|MVAClient|mogimogi|Mnogosearch|Arachmo|Accoona|holmes|htdig|ichiro|webis|LinkWalker|lwp-trivial|facebookexternalhit/i)&&
!b.match(/phone|Playstation/i)&&(a="bot");return a}();c.os=function(){var a="Unknown";e(/cros/i)?a="ChromeOS":e(/android/i)?a="Android":e(/(ipad|iphone|ipod)/i)?a="iOS":e(/linux/i)?a="Linux":e(/mac/i)?a="Mac":e(/iemobile/i)?a="WindowsPhone":e(/win/i)&&(a="Windows");return a}();c.browser=function(){var a="Unknown";w&&g&&!p&&!l?a="Chrome":u?a="Minefield":y&&m?a="Firefox":!w||!k||g||p||v||x||l||n?v?a="OmniWeb":x?a="UCBrowser":q?a="Konqueror":n?a="Maxthon":l?a="Vivaldi":p?a="Midori":h?a="OperaMini":f?
a="Opera":e(/iemobile/i)?a="IEMobile":!r||f||l||(a="MSIE"):a="Safari";return a}();c.engine=function(){var a="Unknown";w?a="Webkit":y?a="Gecko":A?a="Trident":z&&(a="Presto");return a}();c.version=function(){for(var a=c.browser,b="Unknown",e=d.split(" "),a=a.toLowerCase(),a="safari"==a?"version/":a+"/",g=0;g<e.length;g++){var k=e[g];if(-1!==k.indexOf(a)){e=k.split("/");1<e.length&&(b=e[1]);break}}return b}();return c};d.detectDevice=y;d.id=B(32);d.createId=B;d.encode=function(a){return n(a)?encodeURIComponent(a):
!b.match(/phone|Playstation/i)&&(a="bot");return a}();c.os=function(){var a="Unknown";e(/cros/i)?a="ChromeOS":e(/android/i)?a="Android":e(/(ipad|iphone|ipod)/i)?a="iOS":e(/linux/i)?a="Linux":e(/mac/i)?a="Mac":e(/iemobile/i)?a="WindowsPhone":e(/win/i)&&(a="Windows");return a}();c.browser=function(){var a="Unknown";x&&g&&!p&&!l?a="Chrome":u?a="Minefield":y&&m?a="Firefox":!x||!k||g||p||v||w||l||n?v?a="OmniWeb":w?a="UCBrowser":q?a="Konqueror":n?a="Maxthon":l?a="Vivaldi":p?a="Midori":h?a="OperaMini":f?
a="Opera":e(/iemobile/i)?a="IEMobile":!r||f||l||(a="MSIE"):a="Safari";return a}();c.engine=function(){var a="Unknown";x?a="Webkit":y?a="Gecko":A?a="Trident":z&&(a="Presto");return a}();c.version=function(){for(var a=c.browser,b="Unknown",e=d.split(" "),a=a.toLowerCase(),a="safari"==a?"version/":a+"/",g=0;g<e.length;g++){var k=e[g];if(-1!==k.indexOf(a)){e=k.split("/");1<e.length&&(b=e[1]);break}}return b}();return c};d.detectDevice=y;d.id=B(32);d.createId=B;d.encode=function(a){return n(a)?encodeURIComponent(a):
""};d.decode=function(a){return n(a)?decodeURIComponent(a.replace(/\+/g," ")):""};d.trim=function(a){return(a&&n(a)?a.replace(/^[\s\xa0]+|[\s\xa0]+$/g,""):a)||""};d.truncate=function(a,c){if(!a||!n(a))return"...";a=d.trim(a);if(""==a)return a;var b=c||140;if(a.length<=b)return a;var t=a.substring(0,b),e=t.split(" "),g="";1<e.length?(e.pop(),g+=e.join(" "),g.length<a.length&&(g+="...")):(t.substring(0,b-3),g+="...");return g};d.stripTags=function(a){return n(a)?a.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>])+)?>|<\/\w+>/gi,
""):""};d.escapeHTML=function(a){return n(a)?a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"):""};d.unescapeHTML=function(a){return n(a)?a.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&"):""};d.strtolower=function(a){return n(a)?a.toLowerCase():""};d.strtoupper=function(a){return n(a)?a.toUpperCase():""};d.ucfirst=function(a){return n(a)?a.charAt(0).toUpperCase()+a.slice(1):""};d.ucwords=function(a){if(n(a)){var c=[];a.split(" ").forEach(function(a){c.push(d.ucfirst(a))});
return c.join(" ")}return""};d.leftPad=function(a,c,b){w(a)&&(a+="");return n(a)?(a+="",c=c||2,a.length>=c?a:Array(c-a.length+1).join(b||"0")+a):""};d.rightPad=function(a,c,b){w(a)&&(a+="");return n(a)?(a+="",c=c||2,a.length>=c?a:a+Array(c-a.length+1).join(b||"0")):""};d.replaceAll=function(a,c,b){if(!n(a))return"";w(c)&&(c+="");w(b)&&(b+="");if(n(c)&&n(b))a=a.split(c).join(b);else if(q(c)&&n(b))c.forEach(function(c){a=d.replaceAll(a,c,b)});else if(q(c)&&q(b)&&c.length===b.length){var t=c.length;
return c.join(" ")}return""};d.leftPad=function(a,c,b){x(a)&&(a+="");return n(a)?(a+="",c=c||2,a.length>=c?a:Array(c-a.length+1).join(b||"0")+a):""};d.rightPad=function(a,c,b){x(a)&&(a+="");return n(a)?(a+="",c=c||2,a.length>=c?a:a+Array(c-a.length+1).join(b||"0")):""};d.replaceAll=function(a,c,b){if(!n(a))return"";x(c)&&(c+="");x(b)&&(b+="");if(n(c)&&n(b))a=a.split(c).join(b);else if(q(c)&&n(b))c.forEach(function(c){a=d.replaceAll(a,c,b)});else if(q(c)&&q(b)&&c.length===b.length){var t=c.length;
if(0<t)for(var e=0;e<t;e++)a=d.replaceAll(a,c[e],b[e])}return a};d.md5=function(){for(var a=[],c=0;64>c;)a[c]=0|4294967296*Math.abs(Math.sin(++c));return function(b){var c,e,g,d,m=[];b=unescape(encodeURI(b));for(var l=b.length,f=[c=1732584193,e=-271733879,~c,~e],h=0;h<=l;)m[h>>2]|=(b.charCodeAt(h)||128)<<8*(h++%4);m[b=16*(l+8>>6)+14]=8*l;for(h=0;h<b;h+=16){l=f;for(d=0;64>d;)l=[g=l[3],(c=l[1]|0)+((g=l[0]+[c&(e=l[2])|~c&g,g&c|~g&e,c^e^g,e^(c|~g)][l=d>>4]+(a[d]+(m[[d,5*d+1,3*d+5,7*d][l]%16+h]|0)))<<
(l=[7,12,17,22,5,9,14,20,4,11,16,23,6,10,15,21][4*l+d++%4])|g>>>32-l),c,e];for(d=4;d;)f[--d]=f[d]+l[d]}for(b="";32>d;)b+=(f[d>>3]>>4*(1^d++&7)&15).toString(16);return b}}();d.sha256=function(){function a(a,b){return a>>>b|a<<32-b}for(var c=1,b,d=[],e=[];18>++c;)for(b=c*c;312>b;b+=c)e[b]=1;c=1;for(b=0;313>c;)e[++c]||(e[b]=Math.pow(c,.5)%1*4294967296|0,d[b++]=Math.pow(c,1/3)%1*4294967296|0);return function(g){for(var k=e.slice(c=0),m=unescape(encodeURI(g)),l=[],f=m.length,h=[],r,p;c<f;)h[c>>2]|=(m.charCodeAt(c)&
255)<<8*(3-c++%4);f*=8;h[f>>5]|=128<<24-f%32;h[p=(f+64>>9<<4)+15]=f;for(c=0;c<p;c+=16){for(m=k.slice(b=0,8);64>b;m[4]+=r)l[b]=16>b?h[b+c]:(a(r=l[b-2],17)^a(r,19)^r>>>10)+(l[b-7]|0)+(a(r=l[b-15],7)^a(r,18)^r>>>3)+(l[b-16]|0),m.unshift((r=(m.pop()+(a(g=m[4],6)^a(g,11)^a(g,25))+((g&m[5]^~g&m[6])+d[b])|0)+(l[b++]|0))+(a(f=m[0],2)^a(f,13)^a(f,22))+(f&m[1]^m[1]&m[2]^m[2]&f));for(b=8;b--;)k[b]=m[b]+k[b]}for(m="";63>b;)m+=(k[++b>>3]>>4*(7-b%8)&15).toString(16);return m}}();d.unique=function(a){if(q(a)){for(var c=
[],b=0;b<a.length;b++)-1===c.indexOf(a[b])&&c.push(a[b]);return c}return a};d.max=function(a){return q(a)?Math.max.apply({},a):a};d.min=function(a){return q(a)?Math.min.apply({},a):a};d.contains=function(a,c,b){if(q(a))for(var d=0;d<a.length;d++){var e=a[d];if(b&&e[b]===c[b]||e===c)return!0}return!1};d.sort=function(a,c){var b=[],t,e=c||1;if(q(a)&&0<a.length)if(b=d.clone(a),t=b[0],1===e||-1===e)b.sort(function(a,b){return a>b?e:a<b?-1*e:0});else if(n(e)&&t.hasOwnProperty(e))b.sort(function(a,b){return a[e]>
b[e]?1:a[e]<b[e]?-1:0});else if(x(e))for(var g in e){var k=1;t.hasOwnProperty(g)&&(k=-1===e[g]?-1:1,b.sort(function(a,b){return a[g]>b[g]?k:a[g]<b[g]?-1*k:0}))}return b};d.inherits=Object.create;d.copies=function(a,c,b,t){b=b||!1;t=t||[];for(var e in a)if(!(0<t.length&&d.contains(t,e))&&(!b||b&&c.hasOwnProperty(e))){var g=a[e],k=c[e];x(k)&&x(g)||q(k)&&q(g)?c[e]=d.copies(g,c[e],b,t):c[e]=g}return c};d.clone=function(a){if(null==a||"object"!=typeof a)return a;if(a instanceof Date){var c=new Date;c.setTime(a.getTime());
return c}if(a instanceof Array){c=[];a=a.slice(0);for(var b=0,t=a.length;b<t;++b)c[b]=d.clone(a[b]);return c}if(a instanceof Object){c={};for(b in a)"clone"!=b&&a.hasOwnProperty(b)&&(c[b]=d.clone(a[b]));return c}return!1};if("browser"==d.ENV){d.device=y();var u=function(a){var c=(n(a)?document.getElementById(a):a)||null;c&&A(c)&&(c.hasClass=function(a){var c=!0,e=this.className.split(" ");a=a.split(" ");for(var d=0;d<a.length;d++)if(-1===e.indexOf(a[d])){c=!1;break}return c},c.addClass=function(a){a=
a.split(" ");var c=this.className.split(" ");a=a.concat(c);this.className=d.unique(a).join(" ");return this},c.removeClass=function(a){var c=this.className.split(" ");a=a.split(" ");for(var e=0;e<a.length;e++)this.hasClass(a[e])&&c.splice(c.indexOf(a[e]),1);this.className=c.join(" ");return this},c.toggleClass=function(a){c.hasClass(a)?c.removeClass(a):c.addClass(a);return this},c.empty=function(){for(;c.firstChild;)c.removeChild(c.firstChild);return c},c.html=function(a){if(!a)return c.innerHTML;
c.innerHTML=a;return c},c.text=function(a){if(!a)return c.innerText||c.textContent;c.innerText?c.innerText=a:c.textContent&&(c.textContent=a);return c},c.destroy=function(){this.parentNode&&this.parentNode.removeChild(this)});return c},y=function(){var a=[],c,b=document,d=(b.documentElement.doScroll?/^loaded|^c/:/^loaded|^i|^c/).test(b.readyState);d||b.addEventListener("DOMContentLoaded",c=function(){b.removeEventListener("DOMContentLoaded",c);for(d=1;c=a.shift();)c()});return function(b){d?setTimeout(b,
0):a.push(b)}}();d.dom={ready:y,one:function(a){var c=null;(a=document.querySelector(a))&&(c=u(a));return c},all:function(a){var c=[];if(a=document.querySelectorAll(a))for(var b=0;b<a.length;b++)c.push(u(a[b]));return c},get:u,add:function(a,c){var b=c?u(c):document.body,d=A(a)?a:document.createElement(a);b.appendChild(d);return u(d)},create:function(a){return u(document.createElement(a))}};d.event=function(){return{listen:function(a,c,b){"wheel"==c&&(c="Gecko"===d.device.engine?"DOMMouseScroll":
"mousewheel");a=n(a)?u(a):a;b=b||function(){};a.addEventListener?a.addEventListener(c,b,!1):a.attachEvent&&a.attachEvent("on"+c,b)},ignore:function(a,c,b){a=n(a)?u(a):a;a.removeEventListener?a.removeEventListener(c,b,!1):a.detachEvent&&a.detachEvent("on"+c,b)},simulate:function(a,c){var b,d=n(a)?u(a):a;document.createEventObject?(b=document.createEventObject(),d.fireEvent("on"+c,b)):(b=document.createEvent("HTMLEvents"),b.initEvent(c,!0,!0),d.dispatchEvent(b))},exit:function(a){a.cancelBubble=!0;
a.stopPropagation&&a.stopPropagation();a.preventDefault&&a.preventDefault();return!1},locate:function(a){a=a||window.event;(a=a.target||a.srcElement)&&3==a.nodeType&&(a=a.parentNode);return u(a)}}}()}d.now=function(){return new Date};d.time=function(){return(new Date).getTime()};d.date=function(){var a="D, M d, Y H:i:s A",c="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),b="January February March April May June July August September October November December".split(" "),n=function(){var a=
(new Date).getTimezoneOffset(),b=Math.abs(a/60);return["GMT",0>a?"+":"-",d.leftPad(b,2)].join("")}(),e=function(e,k){var m=!1,l,f;k=k?(new Date(k)).getTime():d.time();e||(e=a);var h=function(a){return""+(10>a?"0"+a:a)};l=k instanceof Date?k:new Date(k);if(isNaN(l.getTime()))if(/^(\d+-\d+-\d+)\s(\d+:\d+:\d+)$/i.test(k))l=new Date(k.replace(" ","T"));else return k+" !";if(0<e.indexOf("a")||0<e.indexOf("A"))m=!0;f={Y:function(){return l.getFullYear()},y:function(){return(f.Y()+"").slice(-2)},F:function(){return b[f.n()-
1]},M:function(){return(f.F()+"").slice(0,3)},m:function(){return h(f.n())},n:function(){return l.getMonth()+1},S:function(){var a=f.j()+" ",b=a.charAt(a.length-2);return"1"===b?a+"st":"2"===b?a+"nd":"3"===b?a+"rd":a+"th"},j:function(){return l.getDate()},d:function(){return h(f.j())},t:function(){return(new Date(f.Y(),f.n(),0)).getDate()},w:function(){return l.getDay()},l:function(){return c[f.w()]},D:function(){return(f.l()+"").slice(0,3)},G:function(){return l.getHours()},g:function(){return f.G()%
12||12},h:function(){return h(f.g())},H:function(){return m?f.h():h(f.G())},i:function(){return h(l.getMinutes())},s:function(){return h(l.getSeconds())},a:function(){return 11<f.G()?"pm":"am"},A:function(){return f.a().toUpperCase()},O:function(){return n}};return e.replace(/\.*\\?([a-z])/gi,function(a,b){return f[a]?f[a]():b})};return{pattern:function(b){return b?a=b:a},utc:function(a){return(new Date(a||d.now())).toUTCString()},local:function(a){return e("D, j M Y H:i:s O",a)},strtotime:function(a){return(new Date(a)).getTime()},
format:e,relativize:function(a){var b=a instanceof Date?a:new Date(a);a=new Date-b;b=parseInt(b,10);isNaN(b)&&(b=0);if(a<=b)return"Just now";var b=null,c={millisecond:1,second:1E3,minute:60,hour:60,day:24,month:30,year:12},e;for(e in c)if(a<c[e])break;else b=e,a/=c[e];a=Math.floor(a);1!==a&&(b+="s");return[a,b].join(" ")+" ago"}}}();d.scheduler=function(){function a(){var a=d.time(),c=Math.round(a/1E3),k=d.date.format("Y m d H i s",a),a=d.date.format("l",a);if(0<b.length)for(var m=b.length-1;0<=m;m--){var l=
b[m],f;f=k;var h=a,r=c,p=l.time,q=Math.round(l.at/1E3);if(p.match(/^(sun|mon|tue|wed|thu|fri|sat)+(\w+)?(\s+)+(\d+(:\d)?)+$/gi)){p=p.split(" ");r=!1;if(1<p.length&&(q=d.trim(p[0]),p=d.trim(p[1]),h.match(new RegExp(q,"gi"))))for(h=p.split(":"),1===h.length&&(h=h.concat(["00","00"])),2===h.length&&(h=h.concat(["00"])),f=f.split(" ").slice(3,6),r=!0,q=0;q<f.length;q++)if(parseInt(f[q],10)!==parseInt(h[q],10)){r=!1;break}f=r}else if(p.match(/(d|h|m|s)/gi))f=parseInt(p,10),p=p.replace(f,""),h=0,"s"===
p?h=1:"m"===p?h=60:"h"===p?h=3600:"d"===p&&(h=86400),h*=f,f=r-q,f=0<h&&0===f%h;else{h=p.split(" ");f=f.split(" ");q=r="";for(p=0;p<h.length;p++)"*"===h[p]&&(f[p]="*"),r+=h[p],q+=f[p];f=r===q}f&&(l.fn(),l.repeat||b.splice(m,1))}else clearInterval(n),n=null}function c(c,g,k){k=k||!1;b.push({fn:g,time:c,at:d.time(),repeat:!k});n||(n=setInterval(a,1E3))}var b=[],n;return{yearly:function(a,b){c("* "+a,b)},monthly:function(a,b){c("* * "+a,b)},daily:function(a,b){c("* * * "+a,b)},hourly:function(a,b){c("* * * * "+
a,b)},every:function(a,b){c(a,b)},once:function(a,b){c(a,b,!0)}}}();"node"===d.ENV?module.exports=d:(v=v||window,E(v.define)&&v.define.amd&&v.define(function(){return d}),v.Bella=d)})();
[],b=0;b<a.length;b++)-1===c.indexOf(a[b])&&c.push(a[b]);return c}return a||[]};d.max=function(a){return q(a)?Math.max.apply({},a):a};d.min=function(a){return q(a)?Math.min.apply({},a):a};d.contains=function(a,c,b){if(q(a))for(var d=0;d<a.length;d++){var e=a[d];if(b&&e[b]===c[b]||e===c)return!0}return!1};d.sort=function(a,c){var b=[],t,e=c||1;if(q(a)&&0<a.length)if(b=d.clone(a),t=b[0],1===e||-1===e)b.sort(function(a,b){return a>b?e:a<b?-1*e:0});else if(n(e)&&t.hasOwnProperty(e))b.sort(function(a,
b){return a[e]>b[e]?1:a[e]<b[e]?-1:0});else if(w(e))for(var g in e){var k=1;t.hasOwnProperty(g)&&(k=-1===e[g]?-1:1,b.sort(function(a,b){return a[g]>b[g]?k:a[g]<b[g]?-1*k:0}))}return b};d.inherits=Object.create;d.copies=function(a,c,b,t){b=b||!1;t=t||[];for(var e in a)if(!(0<t.length&&d.contains(t,e))&&(!b||b&&c.hasOwnProperty(e))){var g=a[e],k=c[e];w(k)&&w(g)||q(k)&&q(g)?c[e]=d.copies(g,c[e],b,t):c[e]=g}return c};d.clone=function(a){if(null==a||"object"!=typeof a)return a;if(a instanceof Date){var c=
new Date;c.setTime(a.getTime());return c}if(a instanceof Array){c=[];a=a.slice(0);for(var b=0,t=a.length;b<t;++b)c[b]=d.clone(a[b]);return c}if(a instanceof Object){c={};for(b in a)"clone"!=b&&a.hasOwnProperty(b)&&(c[b]=d.clone(a[b]));return c}return!1};d.empty=function(a){if(q(a)){for(var c=a.length-1;0<=c;c--)a[c]=null,delete a[c];a.length=0}else if(w(a))for(c in a)a[c]=null,delete a[c];return a};if("browser"==d.ENV){d.device=y();var u=function(a){var c=(n(a)?document.getElementById(a):a)||null;
c&&A(c)&&(c.hasClass=function(a){var c=!0,e=this.className.split(" ");a=a.split(" ");for(var d=0;d<a.length;d++)if(-1===e.indexOf(a[d])){c=!1;break}return c},c.addClass=function(a){a=a.split(" ");var c=this.className.split(" ");a=a.concat(c);this.className=d.unique(a).join(" ");return this},c.removeClass=function(a){var c=this.className.split(" ");a=a.split(" ");for(var e=0;e<a.length;e++)this.hasClass(a[e])&&c.splice(c.indexOf(a[e]),1);this.className=c.join(" ");return this},c.toggleClass=function(a){c.hasClass(a)?
c.removeClass(a):c.addClass(a);return this},c.empty=function(){for(;c.firstChild;)c.removeChild(c.firstChild);return c},c.html=function(a){if(!a)return c.innerHTML;c.innerHTML=a;return c},c.text=function(a){if(!a)return c.innerText||c.textContent;c.innerText?c.innerText=a:c.textContent&&(c.textContent=a);return c},c.destroy=function(){this.parentNode&&this.parentNode.removeChild(this)});return c},y=function(){var a=[],c,b=document,d=(b.documentElement.doScroll?/^loaded|^c/:/^loaded|^i|^c/).test(b.readyState);
d||b.addEventListener("DOMContentLoaded",c=function(){b.removeEventListener("DOMContentLoaded",c);for(d=1;c=a.shift();)c()});return function(b){d?setTimeout(b,0):a.push(b)}}();d.dom={ready:y,one:function(a){var c=null;(a=document.querySelector(a))&&(c=u(a));return c},all:function(a){var c=[];if(a=document.querySelectorAll(a))for(var b=0;b<a.length;b++)c.push(u(a[b]));return c},get:u,add:function(a,c){var b=c?u(c):document.body,d=A(a)?a:document.createElement(a);b.appendChild(d);return u(d)},create:function(a){return u(document.createElement(a))}};
d.event=function(){return{listen:function(a,c,b){"wheel"==c&&(c="Gecko"===d.device.engine?"DOMMouseScroll":"mousewheel");a=n(a)?u(a):a;b=b||function(){};a.addEventListener?a.addEventListener(c,b,!1):a.attachEvent&&a.attachEvent("on"+c,b)},ignore:function(a,c,b){a=n(a)?u(a):a;a.removeEventListener?a.removeEventListener(c,b,!1):a.detachEvent&&a.detachEvent("on"+c,b)},simulate:function(a,c){var b,d=n(a)?u(a):a;document.createEventObject?(b=document.createEventObject(),d.fireEvent("on"+c,b)):(b=document.createEvent("HTMLEvents"),
b.initEvent(c,!0,!0),d.dispatchEvent(b))},exit:function(a){a.cancelBubble=!0;a.stopPropagation&&a.stopPropagation();a.preventDefault&&a.preventDefault();return!1},locate:function(a){a=a||window.event;(a=a.target||a.srcElement)&&3==a.nodeType&&(a=a.parentNode);return u(a)}}}()}d.now=function(){return new Date};d.time=function(){return(new Date).getTime()};d.date=function(){var a="D, M d, Y H:i:s A",c="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),b="January February March April May June July August September October November December".split(" "),
n=function(){var a=(new Date).getTimezoneOffset(),b=Math.abs(a/60);return["GMT",0>a?"+":"-",d.leftPad(b,2)].join("")}(),e=function(e,k){var m=!1,l,f;k=k?(new Date(k)).getTime():d.time();e||(e=a);var h=function(a){return""+(10>a?"0"+a:a)};l=k instanceof Date?k:new Date(k);if(isNaN(l.getTime()))if(/^(\d+-\d+-\d+)\s(\d+:\d+:\d+)$/i.test(k))l=new Date(k.replace(" ","T"));else return k+" !";if(0<e.indexOf("a")||0<e.indexOf("A"))m=!0;f={Y:function(){return l.getFullYear()},y:function(){return(f.Y()+"").slice(-2)},
F:function(){return b[f.n()-1]},M:function(){return(f.F()+"").slice(0,3)},m:function(){return h(f.n())},n:function(){return l.getMonth()+1},S:function(){var a=f.j()+" ",b=a.charAt(a.length-2);return"1"===b?a+"st":"2"===b?a+"nd":"3"===b?a+"rd":a+"th"},j:function(){return l.getDate()},d:function(){return h(f.j())},t:function(){return(new Date(f.Y(),f.n(),0)).getDate()},w:function(){return l.getDay()},l:function(){return c[f.w()]},D:function(){return(f.l()+"").slice(0,3)},G:function(){return l.getHours()},
g:function(){return f.G()%12||12},h:function(){return h(f.g())},H:function(){return m?f.h():h(f.G())},i:function(){return h(l.getMinutes())},s:function(){return h(l.getSeconds())},a:function(){return 11<f.G()?"pm":"am"},A:function(){return f.a().toUpperCase()},O:function(){return n}};return e.replace(/\.*\\?([a-z])/gi,function(a,b){return f[a]?f[a]():b})};return{pattern:function(b){return b?a=b:a},utc:function(a){return(new Date(a||d.now())).toUTCString()},local:function(a){return e("D, j M Y H:i:s O",
a)},strtotime:function(a){return(new Date(a)).getTime()},format:e,relativize:function(a){var b=a instanceof Date?a:new Date(a);a=new Date-b;b=parseInt(b,10);isNaN(b)&&(b=0);if(a<=b)return"Just now";var b=null,c={millisecond:1,second:1E3,minute:60,hour:60,day:24,month:30,year:12},e;for(e in c)if(a<c[e])break;else b=e,a/=c[e];a=Math.floor(a);1!==a&&(b+="s");return[a,b].join(" ")+" ago"}}}();d.scheduler=function(){function a(){var a=d.time(),c=Math.round(a/1E3),k=d.date.format("Y m d H i s",a),a=d.date.format("l",
a);if(0<b.length)for(var m=b.length-1;0<=m;m--){var l=b[m],f;f=k;var h=a,r=c,p=l.time,q=Math.round(l.at/1E3);if(p.match(/^(sun|mon|tue|wed|thu|fri|sat)+(\w+)?(\s+)+(\d+(:\d)?)+$/gi)){p=p.split(" ");r=!1;if(1<p.length&&(q=d.trim(p[0]),p=d.trim(p[1]),h.match(new RegExp(q,"gi"))))for(h=p.split(":"),1===h.length&&(h=h.concat(["00","00"])),2===h.length&&(h=h.concat(["00"])),f=f.split(" ").slice(3,6),r=!0,q=0;q<f.length;q++)if(parseInt(f[q],10)!==parseInt(h[q],10)){r=!1;break}f=r}else if(p.match(/(d|h|m|s)/gi))f=
parseInt(p,10),p=p.replace(f,""),h=0,"s"===p?h=1:"m"===p?h=60:"h"===p?h=3600:"d"===p&&(h=86400),h*=f,f=r-q,f=0<h&&0===f%h;else{h=p.split(" ");f=f.split(" ");q=r="";for(p=0;p<h.length;p++)"*"===h[p]&&(f[p]="*"),r+=h[p],q+=f[p];f=r===q}f&&(l.fn(),l.repeat||b.splice(m,1))}else clearInterval(n),n=null}function c(c,g,k){k=k||!1;b.push({fn:g,time:c,at:d.time(),repeat:!k});n||(n=setInterval(a,1E3))}var b=[],n;return{yearly:function(a,b){c("* "+a,b)},monthly:function(a,b){c("* * "+a,b)},daily:function(a,
b){c("* * * "+a,b)},hourly:function(a,b){c("* * * * "+a,b)},every:function(a,b){c(a,b)},once:function(a,b){c(a,b,!0)}}}();"node"===d.ENV?module.exports=d:(v=v||window,E(v.define)&&v.define.amd&&v.define(function(){return d}),v.Bella=d)})();

@@ -852,1 +852,268 @@ /*global describe, it, expect*/

});
describe('BellaJS : Array & Object', function(){
describe('Bella.unique(Array a)', function(){
var sampleArray = [
1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 4, 3, 2, 1
];
it('Bella.unique('+JSON.stringify(sampleArray)+') should not contain duplicate items', function(){
var uniqueArray = Bella.unique(sampleArray);
var expectResult = 1;
var arr1 = uniqueArray.filter(function(item){
return item===1;
});
expect(arr1.length).toEqual(expectResult);
var arr2 = uniqueArray.filter(function(item){
return item===2;
});
expect(arr2.length).toEqual(expectResult);
var arr3 = uniqueArray.filter(function(item){
return item===3;
});
expect(arr3.length).toEqual(expectResult);
var arr4 = uniqueArray.filter(function(item){
return item===4;
});
expect(arr4.length).toEqual(expectResult);
var arr5 = uniqueArray.filter(function(item){
return item===5;
});
expect(arr5.length).toEqual(expectResult);
});
});
var sampleArray = [
18, 55, 97, 1, 48, 100, 62, 80
];
describe('Bella.max(Array a)', function(){
it('Bella.max('+JSON.stringify(sampleArray)+') should return 100', function(){
var realResult = Bella.max(sampleArray);
var expectResult = 100;
expect(realResult).toEqual(expectResult);
});
});
describe('Bella.min(Array a)', function(){
it('Bella.min('+JSON.stringify(sampleArray)+') should return 1', function(){
var realResult = Bella.min(sampleArray);
var expectResult = 1;
expect(realResult).toEqual(expectResult);
});
});
describe('Bella.contains(Array a, String|Object search [, String key])', function(){
it('Bella.contains('+JSON.stringify(sampleArray)+', 1) should return true', function(){
var realResult = Bella.contains(sampleArray, 1);
var expectResult = true;
expect(realResult).toBe(expectResult);
});
it('Bella.contains('+JSON.stringify(sampleArray)+', 80) should return true', function(){
var realResult = Bella.contains(sampleArray, 80);
var expectResult = true;
expect(realResult).toBe(expectResult);
});
it('Bella.contains('+JSON.stringify(sampleArray)+', 1000) should return false', function(){
var realResult = Bella.contains(sampleArray, 1000);
var expectResult = false;
expect(realResult).toBe(expectResult);
});
});
describe('Bella.sort(Array a [, String order | Object option ])', function(){
it('Bella.sort('+JSON.stringify(sampleArray)+') should have 1 at first', function(){
var sortedArray = Bella.sort(sampleArray);
var realResult = sortedArray[0];
var expectResult = 1;
expect(realResult).toEqual(expectResult);
});
it('Bella.sort('+JSON.stringify(sampleArray)+') should have 18 at second', function(){
var sortedArray = Bella.sort(sampleArray);
var realResult = sortedArray[1];
var expectResult = 18;
expect(realResult).toEqual(expectResult);
});
it('Bella.sort('+JSON.stringify(sampleArray)+') should have 97 at second last', function(){
var sortedArray = Bella.sort(sampleArray);
var realResult = sortedArray[sortedArray.length-2];
var expectResult = 97;
expect(realResult).toEqual(expectResult);
});
it('Bella.sort('+JSON.stringify(sampleArray)+') should have 100 at last', function(){
var sortedArray = Bella.sort(sampleArray);
var realResult = sortedArray[sortedArray.length-1];
var expectResult = 100;
expect(realResult).toEqual(expectResult);
});
it('Bella.sort('+JSON.stringify(sampleArray)+', -1) should have 100 at first', function(){
var sortedArray = Bella.sort(sampleArray, -1);
var realResult = sortedArray[0];
var expectResult = 100;
expect(realResult).toEqual(expectResult);
});
it('Bella.sort('+JSON.stringify(sampleArray)+', -1) should have 97 at second', function(){
var sortedArray = Bella.sort(sampleArray, -1);
var realResult = sortedArray[1];
var expectResult = 97;
expect(realResult).toEqual(expectResult);
});
it('Bella.sort('+JSON.stringify(sampleArray)+', -1) should have 18 at second last', function(){
var sortedArray = Bella.sort(sampleArray, -1);
var realResult = sortedArray[sortedArray.length-2];
var expectResult = 18;
expect(realResult).toEqual(expectResult);
});
it('Bella.sort('+JSON.stringify(sampleArray)+', -1) should have 1 at last', function(){
var sortedArray = Bella.sort(sampleArray, -1);
var realResult = sortedArray[sortedArray.length-1];
var expectResult = 1;
expect(realResult).toEqual(expectResult);
});
});
describe('Bella.empty(Array a)', function(){
it('Bella.empty('+JSON.stringify(sampleArray)+') should return []', function(){
var realResult = Bella.empty(sampleArray);
var expectResult = [];
expect(realResult).toEqual(expectResult);
});
var sampleObject = {name: 'Alice', age: 18};
it('Bella.empty('+JSON.stringify(sampleObject)+') should return {}', function(){
var realResult = Bella.empty(sampleObject);
var expectResult = {};
expect(realResult).toEqual(expectResult);
});
});
describe('Bella.clone(Array a)', function(){
var sampleArray = [
1, 3, 4, 6, 9, 12
];
it('Bella.clone('+JSON.stringify(sampleArray)+') should return '+JSON.stringify(sampleArray), function(){
var realResult = Bella.clone(sampleArray);
var expectResult = [
1, 3, 4, 6, 9, 12
];
expect(realResult).toEqual(expectResult);
});
var sampleObject = {name: 'Alice', age: 18};
it('Bella.clone('+JSON.stringify(sampleObject)+') should return '+JSON.stringify(sampleObject), function(){
var realResult = Bella.clone(sampleObject);
var expectResult = {name: 'Alice', age: 18};
expect(realResult).toEqual(expectResult);
});
});
describe('Bella.copies(Array|Object src, Array|Object dest [, Boolean mustMatch[, Array exclude] ])', function(){
var srcObject1 = {name: 'Alice', age: 18};
var destObject1 = {country: 'USA'};
var expectResult1 = {name: 'Alice', age: 18, country: 'USA'};
it('Bella.copies('+JSON.stringify(srcObject1)+', '+JSON.stringify(destObject1)+') should return '+JSON.stringify(expectResult1), function(){
var realResult = Bella.copies(srcObject1, destObject1);
expect(realResult).toEqual(expectResult1);
});
var srcObject2 = {name: 'Alice', age: 18};
var destObject2 = {name: 'Helen', country: 'USA'};
var expectResult2 = {name: 'Alice', country: 'USA'};
it('Bella.copies('+JSON.stringify(srcObject2)+', '+JSON.stringify(destObject2)+', true) should return '+JSON.stringify(expectResult2), function(){
var realResult = Bella.copies(srcObject2, destObject2, true);
expect(realResult).toEqual(expectResult2);
});
var srcObject3 = {name: 'Alice', age: 18};
var destObject3 = {name: 'Helen', country: 'USA'};
var expectResult3 = {name: 'Helen', country: 'USA'};
it('Bella.copies('+JSON.stringify(srcObject3)+', '+JSON.stringify(destObject3)+', true, [\'name\']) should return '+JSON.stringify(expectResult3), function(){
var realResult = Bella.copies(srcObject3, destObject3, true, ['name']);
expect(realResult).toEqual(expectResult3);
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc