private-bower
Version:
A simple private bower registry
25 lines • 4.82 kB
JavaScript
/*!
* Copyright © 2014 Hacklone,
* https://github.com/Hacklone
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
QArray=function(){function t(){for(var r=0,e=arguments.length;e>r;r++){var i=arguments[r];(i instanceof t||n(i))&&this.pushArray(i)}}function r(t){return"function"==typeof t}function n(t){return"[object Array]"===toString.call(t)}function e(t){return"string"==typeof t}return t.prototype=[],t.prototype.indexOf=t.prototype.indexOf||function(t){for(var r=0,n=this.length;n>r;r++)if(this[r]===t)return r;return-1},t.prototype.insert=function(t){return this.splice.apply(this,[t,0].concat(Array.prototype.slice.call(arguments,1))),this},t.prototype.concat=function(){for(var r=0,e=arguments.length;e>r;r++){var i=arguments[r];(i instanceof t||n(i))&&this.pushArray(i)}return this},t.prototype.select=function(n){var i=new t;if(e(n))for(var o=0,s=this.length;s>o;o++)i.push(this[o][n]);else if(r(n))for(var h=0,u=this.length;u>h;h++)i.push(n(this[h]));else for(var a=0,p=this.length;p>a;a++)i.push(this[a]);return i},t.prototype.selectMany=function(r){for(var n=new t,e=0,i=this.length;i>e;e++){var o=this[e];o instanceof Array?n.pushArray(new t(o).select(r)):o instanceof t&&n.pushArray(o.select(r))}return n},t.prototype.forEach=function(t){for(var r=0,n=this.length;n>r;r++)t(this[r],r);return this},t.prototype.setProperty=function(t,n){for(var e=r(n),i=0,o=this.length;o>i;i++){var s=this[i];s[t]=e?n(s):n}return this},t.prototype.pushArray=function(){function r(){for(var t=0,r=i.length;r>t;t++)this.push(i[t])}for(var n=0,e=arguments.length;e>n;n++){var i=arguments[n];i instanceof Array&&(i.length>1e4?r.apply(this):Array.prototype.push.apply(this,i instanceof t?i.toArray():i))}return this},t.prototype.contains=function(t){return-1!==this.indexOf(t)},t.prototype.remove=function(t){var r=this.indexOf(t);return-1!==r&&this.splice(r,1),this},t.prototype.removeArray=function(t){if(!n(t))return this;for(var r=0,e=t.length;e>r;r++)this.remove(t[r]);return this},t.prototype.toArray=function(){for(var t=[],r=0,n=this.length;n>r;r++)t.push(this[r]);return t},t.prototype.clear=function(){return this.length=0,this},t.prototype.firstOrDefault=function(t){function n(){for(var r=0,n=this.length;n>r;r++){var e=this[r];if(e[t.key]===t.value)return e}return null}function e(){for(var r=0,n=this.length;n>r;r++){var e=this[r];if(t(e,r))return e}return null}return t?r(t)?e.apply(this):n.apply(this):this.length?this[0]:null},t.prototype.first=function(t){var r=this.firstOrDefault(t);if(null===r)throw new Error("The Array does not contain the desired element");return r},t.prototype.where=function(n){function e(){for(var t=0,r=this.length;r>t;t++){var e=this[t];e[n.key]===n.value&&o.push(e)}}function i(){for(var t=0,r=this.length;r>t;t++){var e=this[t];n(e,t)&&o.push(e)}}var o=new t;return r(n)?i.apply(this):e.apply(this),o},t.prototype.count=function(t){function n(){for(var r=0,n=this.length;n>r;r++){var e=this[r];e[t.key]===t.value&&i++}}function e(){for(var r=0,n=this.length;n>r;r++){var e=this[r];t(e,r)&&i++}}var i=0;return r(t)?e.apply(this):n.apply(this),i},t.prototype.any=function(t){return null!==this.firstOrDefault(t)},t.prototype.all=function(t){function n(){for(var r=0,n=this.length;n>r;r++){var e=this[r];if(e[t.key]!==t.value)return!1}return!0}function e(){for(var r=0,n=this.length;n>r;r++){var e=this[r];if(!t(e,r))return!1}return!0}return t?r(t)?e.apply(this):n.apply(this):null},t.prototype.sum=function(t){function n(){for(var r=0,n=0,e=this.length;e>n;n++)r+=this[n][t]||0;return r}function e(){for(var r=0,n=0,e=this.length;e>n;n++)r+=t(this[n])||0;return r}return t?r(t)?e.apply(this):n.apply(this):0},t.prototype.moveItemToIndex=function(t,r){return 0>r||r>=this.length||!this.contains(t)?this:(this.remove(t).splice(r,0,t),this)},t}();