Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update aliases, forgot about that. heh. 2.4

  • Loading branch information...
commit 0275164b456714f10d744bfd56a2fda802dab3ce 1 parent c0c7ffb
@Nijikokun authored
Showing with 24 additions and 24 deletions.
  1. +8 −8 estro.js
  2. +15 −15 estro.min.js
  3. +1 −1  package.json
View
16 estro.js
@@ -9,7 +9,7 @@
// Initialize Estro Object
// This will be our holder for all of the Prototype functions.
var Estro = {
- version: "2.3"
+ version: "2.4"
};
// Quick Prototype access, for looping or in-code access.
@@ -385,13 +385,13 @@
},
// Aliases
- ord: Estro.Number.ordinalize,
- chr: Estro.Number.charCode,
- mod: Estro.Number.modulo,
- clamp: Estro.Number.limit,
- toInt: Estro.Number.toNumber,
- toRad: Estro.Number.toRadians,
- toDeg: Estro.Number.toDegrees
+ ord: function () { return this.ordinalize(); },
+ chr: function () { return this.charCode(); },
+ mod: function (n) { return this.modulo(n); },
+ clamp: function (m,x) { return this.limit(m,x); },
+ toInt: function () { return this.toNumber(); },
+ toRad: function () { return this.toRadians(); },
+ toDeg: function () { return this.toDegrees(); }
};
// String based functions
View
30 estro.min.js
@@ -1,18 +1,18 @@
// http://okij.in/bh
-(function(){var e={version:"2.3"},j={Array:Array.prototype,Object:Object.prototype,String:String.prototype,Number:Number.prototype},g={InvalidArgument:function(a){this.name="InvalidArgument";this.message=a}};e.Array={each:function(a,b){if(!this||null==this||this.isEmpty())throw new g.InvalidArgument("Array given was empty or null");for(var c in this)if(this.hasOwnProperty(c)&&a.call(b,this[c],c,this)==={})break},map:function(a,b){var c=[];if(!this||null==this||this.isEmpty())return c;if(!a)return this;
-this.each(function(d,h,e){c[c.length]=a.call(b,d,h,e)});return c},every:function(a,b){var c=this.length,d=0;if(!this||null==this||this.isEmpty())throw new g.InvalidArgument("Array given was empty or null");if(!a)throw new g.InvalidArgument("Callback function for `some` was empty!");for(;d<c;){if(d in this&&!this[d].match(a,b,[d,this]))return!1;d++}return!0},some:function(a,b){var c=this.length,d=0;if(!this||null==this||this.isEmpty())throw new g.InvalidArgument("Array given was empty or null");if(!a)throw new g.InvalidArgument("Callback function for `some` was empty!");
-for(;d<c;){if(d in this&&this[d].match(a,b,[d,this]))return!0;d++}return!1},filter:function(a,b){var c=this.length,d=0,h=[];if(!this||null==this||this.isEmpty())return results;if(!a)return this;for(;d<c;)d in this&&this[d].match(a,b,[d,this])&&h.push(this[d]),d++;return h},reduce:function(a,b,c){var d=void 0!==b;if(!this||null==this||this.isEmpty())throw new g.InvalidArgument("Array given was empty or invalid");this.each(function(h,e,f){b=d?a.call(c,b,h,e,f):value;d=!0});return b},reduceRight:function(a,
-b,c){if(!this||null==this||this.isEmpty())throw new g.InvalidArgument("Array given was empty or invalid");return(this.isArray()?this.slice():obj.toArray()).reverse().reduce(iterator,memo,c)}};e.Object={hop:function(a){return this.hasOwnProperty(a)},each:function(a,b){if(!this||null==this||this.isEmpty())throw new g.InvalidArgument("Object given was empty or invalid");for(var c in this)if(this.hasOwnProperty(c)&&a.call(b,this[c],c,this)==={})break},isEmpty:function(){if(this.isArray()||this.isString())return 0===
+(function(){var g={version:"2.4"},j={Array:Array.prototype,Object:Object.prototype,String:String.prototype,Number:Number.prototype},f={InvalidArgument:function(a){this.name="InvalidArgument";this.message=a}};g.Array={each:function(a,b){if(!this||null==this||this.isEmpty())throw new f.InvalidArgument("Array given was empty or null");for(var c in this)if(this.hasOwnProperty(c)&&a.call(b,this[c],c,this)==={})break},map:function(a,b){var c=[];if(!this||null==this||this.isEmpty())return c;if(!a)return this;
+this.each(function(d,h,e){c[c.length]=a.call(b,d,h,e)});return c},every:function(a,b){var c=this.length,d=0;if(!this||null==this||this.isEmpty())throw new f.InvalidArgument("Array given was empty or null");if(!a)throw new f.InvalidArgument("Callback function for `some` was empty!");for(;d<c;){if(d in this&&!this[d].match(a,b,[d,this]))return!1;d++}return!0},some:function(a,b){var c=this.length,d=0;if(!this||null==this||this.isEmpty())throw new f.InvalidArgument("Array given was empty or null");if(!a)throw new f.InvalidArgument("Callback function for `some` was empty!");
+for(;d<c;){if(d in this&&this[d].match(a,b,[d,this]))return!0;d++}return!1},filter:function(a,b){var c=this.length,d=0,h=[];if(!this||null==this||this.isEmpty())return results;if(!a)return this;for(;d<c;)d in this&&this[d].match(a,b,[d,this])&&h.push(this[d]),d++;return h},reduce:function(a,b,c){var d=void 0!==b;if(!this||null==this||this.isEmpty())throw new f.InvalidArgument("Array given was empty or invalid");this.each(function(h,e,f){b=d?a.call(c,b,h,e,f):value;d=!0});return b},reduceRight:function(a,
+b,c){if(!this||null==this||this.isEmpty())throw new f.InvalidArgument("Array given was empty or invalid");return(this.isArray()?this.slice():obj.toArray()).reverse().reduce(iterator,memo,c)}};g.Object={hop:function(a){return this.hasOwnProperty(a)},each:function(a,b){if(!this||null==this||this.isEmpty())throw new f.InvalidArgument("Object given was empty or invalid");for(var c in this)if(this.hasOwnProperty(c)&&a.call(b,this[c],c,this)==={})break},isEmpty:function(){if(this.isArray()||this.isString())return 0===
this.length;for(var a in this)if(this.hop(a))return!1;return!0},isElement:function(){return!!(this&&1==this.nodeType)},isObject:function(){return this==Object(this)},isBoolean:function(){return!0===this||!1===this||"[object Boolean]"==Object.prototype.toString.call(this)},isNaN:function(){return this!==this},isNull:function(){return null===this},isUndefined:function(){return void 0===this},match:function(a,b,c){return this===a?!0:object.isRegExp(a)?regexp(a).test(this):object.isFunction(a)?a.apply(b,
-[this].concat(c)):object.equal(a,this)},typeOf:function(){return Object.prototype.toString.call(this)},cacheResults:function(a){if(this.isFunction()){var b={};a||(a=function(a){return a});return function(){var c=a.apply(this,arguments);return hasOwnProperty.call(b,c)?b[c]:b[c]=this.apply(this,arguments)}}},toArray:function(){return!this||this.isEmpty()?[]:this.isString()||this.isDate()||this.isFunction()||this.isNumber()||this.isRegExp()?[this]:this.toArray&&this.toArray!=e.Object.toArray?this.toArray():
-this.isArray?slice.call(this):this.isArguments?slice.call(this):this.map(function(a){return a})}};(function(a,b){var c="Array Arguments Date Function Number Object RegExp String".split(" "),d;for(d in c)c.hasOwnProperty(d)&&(b[c[d]]="[object "+c[d]+"]",a["is"+c[d]]||(a["is"+c[d]]=function(a){return function(){return Object.prototype.toString.call(this)==b[a]}}(c[d])))})(e.Object,{});e.Number={abs:function(){return Math.abs(this)},round:function(a){a=Math.pow(10,a||0);return Math.round(this*a)/a},
+[this].concat(c)):object.equal(a,this)},typeOf:function(){return Object.prototype.toString.call(this)},cacheResults:function(a){if(this.isFunction()){var b={};a||(a=function(a){return a});return function(){var c=a.apply(this,arguments);return hasOwnProperty.call(b,c)?b[c]:b[c]=this.apply(this,arguments)}}},toArray:function(){return!this||this.isEmpty()?[]:this.isString()||this.isDate()||this.isFunction()||this.isNumber()||this.isRegExp()?[this]:this.toArray&&this.toArray!=g.Object.toArray?this.toArray():
+this.isArray?slice.call(this):this.isArguments?slice.call(this):this.map(function(a){return a})}};(function(a,b){var c="Array Arguments Date Function Number Object RegExp String".split(" "),d;for(d in c)c.hasOwnProperty(d)&&(b[c[d]]="[object "+c[d]+"]",a["is"+c[d]]||(a["is"+c[d]]=function(a){return function(){return Object.prototype.toString.call(this)==b[a]}}(c[d])))})(g.Object,{});g.Number={abs:function(){return Math.abs(this)},round:function(a){a=Math.pow(10,a||0);return Math.round(this*a)/a},
ceil:function(){return Math.ceil(this)},floor:function(){return Math.floor(this)},modulo:function(a){return this%a},pad:function(a,b){var c=0===this.toInt()?"":(this+"").replace(/^-/,""),c=c.padLeft("0",a-c.replace(/\.\d+$/,"").length);if(b||0>this)c=(0>this?"-":"+")+c;return c},map:function(a,b,c,d){return c+(d-c)*((this-a)/(b-a))},limit:function(a,b){return Math.min(b,Math.max(a,this))},isEven:function(){return this.isMultipleOf(2)},isOdd:function(){return!this.isMultipleOf(2)},isMultipleOf:function(a){return 0===
-this.mod(a)},toNumber:function(){return this|0},toRadians:function(){return this/180*Math.PI},toDegrees:function(){return 180*this/Math.PI},format:function(a,b,c){var d,e,f=/(\d+)(\d{3})/;b||(b=",");c||(c=".");if((""+b).match(/\d/))throw new g.InvalidArgument("Thousands seperator cannot contain digits.");d=a.isNumber()?this.round(a).toFixed(Math.max(a,0)):this+"";e=d.split(".");d=e[0];for(e=e[1];d.match(f);)d=d.replace(f,"$1"+b+"$2");0<e.length&&(d+=c+e.padRight("0",a-e.length));return d},ordinalize:function(){if(11<=
-this&&13>=this)return this+"th";switch(this.mod(10)){case 1:return this+"st";case 2:return this+"nd";case 3:return this+"rd";default:return this+"th"}},charCode:function(){return String.fromCharCode(this)},ord:e.Number.ordinalize,chr:e.Number.charCode,mod:e.Number.modulo,clamp:e.Number.limit,toInt:e.Number.toNumber,toRad:e.Number.toRadians,toDeg:e.Number.toDegrees};e.String={isEmpty:function(){return!this||0===this.length},isBlank:function(){return!this||/^\s*$/.test(this)},compareTo:function(a){for(var b=
-this.length,c=a.length,d=b<c?b:c,e=0;e<d;e++){var f=this.charCodeAt(e),g=a.charCodeAt(e);if(f!=g)return f-g}return b-c},startsWith:function(a){return!this.indexOf(a)},endsWith:function(a){return-1!==this.indexOf(a,this.length-a.length)},contains:function(a){return-1!=this.indexOf(a)},equals:function(a){return this==a},equalsIgnoreCase:function(a){return this==a?!0:!a.isEmpty()&&a.length==this.length&&this.toLowerCase()==a.toLowerCase()},trim:function(){return this.replace(/^\s\s*/,"").replace(/\s\s*$/,
-"")},trimLeft:function(){return this.trimLeft?this.trimLeft():this.replace(/^\s+/,"")},trimRight:function(){return this.trimRight?this.trimRight():this.replace(/\s+$/,"")},trimNonAlpha:function(){return this.replace(/[^A-Za-z ]+/g,"")},trimNonAlphaNumeric:function(){return this.replace(/[^A-Za-z0-9 ]+/g,"")},trimNonNumeric:function(){return this.replace(/[^0-9-.]/g,"")},trimNumeric:function(){return this.replace(/[0-9]/g,"")},repeat:function(a){return Array(a?a+1:2).join(this)},reverse:function(){return this.split("").reverse().join("")},
-insert:function(a,b){return this.slice(0,b)+a+this.slice(b)},remove:function(a,b){return this.slice(0,a)+this.slice(b)},pop:function(a){return this.slice(a?0<a?a:1*a:1,this.length)},chop:function(a){return this.slice(0,a?0>a?a:-1*a:-1)},capitalize:function(){return this.charAt(0).toUpperCase()+this.slice(1)},uncapitalize:function(){return this.charAt(0).toLowerCase()+this.slice(1)},capitalizeWords:function(){return this.replace(/\w+/g,function(a){return a.capitalize()})},uncapitalizeWords:function(){return this.replace(/\w+/g,
-function(a){return a.uncapitalize()})},isUpperCaseAt:function(a){return this.charAt(a).toUpperCase()===this.charAt(a)},isLowerCaseAt:function(a){return this.charAt(a).toLowerCase()===this.charAt(a)},swapCase:function(){return this.replace(/([a-z]+)|([A-Z]+)/g,function(a,b){return b?a.toUpperCase():a.toLowerCase()})},camelize:function(){return this.replace(/\W+(.)/g,function(a,b){return b.toUpperCase()})},dasherize:function(){return this.replace(/\W+/g,"-").replace(/([a-z\d])([A-Z])/g,"$1-$2").toLowerCase()},
-underscore:function(){return this.replace(/\W+/g,"_").replace(/([a-z\d])([A-Z])/g,"$1_$2").toLowerCase()},pad:function(a,b,c){a=a.isString()?a:""+a;b.isNumber()||(b=1);c.isNumber()||(c=1);return a.repeat(b)+this+a.repeat(c)},padLeft:function(a,b){return this.pad(a,b,0)},padRight:function(a,b){return this.pad(a,0,b)},bind:function(a){for(var b,c=this;b=/%\{\s*([^\}\s]+)\s*\}/.exec(c);)c=c.replace(b[0],a[b[1]]||"??");return c},extract:function(a,b){b=void 0===b?0:b;if(!a.global)return this.match(a)[b]||
-"";for(var c,d=[];c=a.exec(this);)d[d.length]=c[b]||"";return d},toInt:function(){for(var a=[],b=0;b<this.length;b++)a[b]=this.charCodeAt(b);return a},toHash:function(){for(var a=0,b=this.length,c=0;c<b;c++)a=31*a+this.charCodeAt(c);return a}};for(var f in g)if(g.hasOwnProperty(f)){window&&!window[f]&&(window[f]=g[f]);if(window[f]==g[f])window[f].prototype=Error.prototype;g[f].prototype=Error.prototype}for(f in e)if(e.hasOwnProperty(f)&&j[f])for(var i in e[f])e[f].hasOwnProperty(i)&&!j[f][i]&&(j[f][i]=
-e[f][i])})();
+this.mod(a)},toNumber:function(){return this|0},toRadians:function(){return this/180*Math.PI},toDegrees:function(){return 180*this/Math.PI},format:function(a,b,c){var d,e,g=/(\d+)(\d{3})/;b||(b=",");c||(c=".");if((""+b).match(/\d/))throw new f.InvalidArgument("Thousands seperator cannot contain digits.");d=a.isNumber()?this.round(a).toFixed(Math.max(a,0)):this+"";e=d.split(".");d=e[0];for(e=e[1];d.match(g);)d=d.replace(g,"$1"+b+"$2");0<e.length&&(d+=c+e.padRight("0",a-e.length));return d},ordinalize:function(){if(11<=
+this&&13>=this)return this+"th";switch(this.mod(10)){case 1:return this+"st";case 2:return this+"nd";case 3:return this+"rd";default:return this+"th"}},charCode:function(){return String.fromCharCode(this)},ord:function(){return this.ordinalize()},chr:function(){return this.charCode()},mod:function(a){return this.modulo(a)},clamp:function(a,b){return this.limit(a,b)},toInt:function(){return this.toNumber()},toRad:function(){return this.toRadians()},toDeg:function(){return this.toDegrees()}};g.String=
+{isEmpty:function(){return!this||0===this.length},isBlank:function(){return!this||/^\s*$/.test(this)},compareTo:function(a){for(var b=this.length,c=a.length,d=b<c?b:c,e=0;e<d;e++){var f=this.charCodeAt(e),g=a.charCodeAt(e);if(f!=g)return f-g}return b-c},startsWith:function(a){return!this.indexOf(a)},endsWith:function(a){return-1!==this.indexOf(a,this.length-a.length)},contains:function(a){return-1!=this.indexOf(a)},equals:function(a){return this==a},equalsIgnoreCase:function(a){return this==a?!0:
+!a.isEmpty()&&a.length==this.length&&this.toLowerCase()==a.toLowerCase()},trim:function(){return this.replace(/^\s\s*/,"").replace(/\s\s*$/,"")},trimLeft:function(){return this.trimLeft?this.trimLeft():this.replace(/^\s+/,"")},trimRight:function(){return this.trimRight?this.trimRight():this.replace(/\s+$/,"")},trimNonAlpha:function(){return this.replace(/[^A-Za-z ]+/g,"")},trimNonAlphaNumeric:function(){return this.replace(/[^A-Za-z0-9 ]+/g,"")},trimNonNumeric:function(){return this.replace(/[^0-9-.]/g,
+"")},trimNumeric:function(){return this.replace(/[0-9]/g,"")},repeat:function(a){return Array(a?a+1:2).join(this)},reverse:function(){return this.split("").reverse().join("")},insert:function(a,b){return this.slice(0,b)+a+this.slice(b)},remove:function(a,b){return this.slice(0,a)+this.slice(b)},pop:function(a){return this.slice(a?0<a?a:1*a:1,this.length)},chop:function(a){return this.slice(0,a?0>a?a:-1*a:-1)},capitalize:function(){return this.charAt(0).toUpperCase()+this.slice(1)},uncapitalize:function(){return this.charAt(0).toLowerCase()+
+this.slice(1)},capitalizeWords:function(){return this.replace(/\w+/g,function(a){return a.capitalize()})},uncapitalizeWords:function(){return this.replace(/\w+/g,function(a){return a.uncapitalize()})},isUpperCaseAt:function(a){return this.charAt(a).toUpperCase()===this.charAt(a)},isLowerCaseAt:function(a){return this.charAt(a).toLowerCase()===this.charAt(a)},swapCase:function(){return this.replace(/([a-z]+)|([A-Z]+)/g,function(a,b){return b?a.toUpperCase():a.toLowerCase()})},camelize:function(){return this.replace(/\W+(.)/g,
+function(a,b){return b.toUpperCase()})},dasherize:function(){return this.replace(/\W+/g,"-").replace(/([a-z\d])([A-Z])/g,"$1-$2").toLowerCase()},underscore:function(){return this.replace(/\W+/g,"_").replace(/([a-z\d])([A-Z])/g,"$1_$2").toLowerCase()},pad:function(a,b,c){a=a.isString()?a:""+a;b.isNumber()||(b=1);c.isNumber()||(c=1);return a.repeat(b)+this+a.repeat(c)},padLeft:function(a,b){return this.pad(a,b,0)},padRight:function(a,b){return this.pad(a,0,b)},bind:function(a){for(var b,c=this;b=/%\{\s*([^\}\s]+)\s*\}/.exec(c);)c=
+c.replace(b[0],a[b[1]]||"??");return c},extract:function(a,b){b=void 0===b?0:b;if(!a.global)return this.match(a)[b]||"";for(var c,d=[];c=a.exec(this);)d[d.length]=c[b]||"";return d},toInt:function(){for(var a=[],b=0;b<this.length;b++)a[b]=this.charCodeAt(b);return a},toHash:function(){for(var a=0,b=this.length,c=0;c<b;c++)a=31*a+this.charCodeAt(c);return a}};for(var e in f)if(f.hasOwnProperty(e)){window&&!window[e]&&(window[e]=f[e]);if(window[e]==f[e])window[e].prototype=Error.prototype;f[e].prototype=
+Error.prototype}for(e in g)if(g.hasOwnProperty(e)&&j[e])for(var i in g[e])g[e].hasOwnProperty(i)&&!j[e][i]&&(j[e][i]=g[e][i])})();
View
2  package.json
@@ -1,7 +1,7 @@
{
"name": "Estro",
"description": "Extended Prototype Object",
- "version": "2.3",
+ "version": "2.4",
"homepage": "https://github.com/Nijikokun/Estro",
"author": "Nijikokun <nijikokun@gmail.com> (@nijikokun)",
"repository": {
Please sign in to comment.
Something went wrong with that request. Please try again.