Comparing version 0.2.7 to 0.2.8
30
n8iv.js
;!function( util, Name, PACKAGE ) { | ||
"use strict"; | ||
/*~ n8iv/src/Object.js ~*/ | ||
/*~ src/Object.js ~*/ | ||
util.x.cache( 'Object', function( Type ) { | ||
@@ -25,5 +25,5 @@ function arraysEqual( a1, a2 ) { | ||
equalTo : function( o, k ) { | ||
switch ( util.nativeType( o ) ) { | ||
case 'array' : return Array.isArray( k ) ? arraysEqual( o, k ) : false; | ||
case 'object' : return util.nativeType( k ) == 'object' ? objectsEqual( o, k ) : false; | ||
switch ( util.ntype( o ) ) { | ||
case 'array' : return Array.isArray( k ) ? arraysEqual( o, k ) : false; | ||
case 'object' : return util.ntype( k ) == 'object' ? objectsEqual( o, k ) : false; | ||
case 'date' : return +o == +k; | ||
@@ -38,3 +38,3 @@ } | ||
/*~ n8iv/src/Function.js ~*/ | ||
/*~ src/Function.js ~*/ | ||
util.x.cache( 'Function', function( Type ) { | ||
@@ -44,3 +44,3 @@ var re_args = /^[\s\(]*function[^\(]*\(([^\)]*)\)/, | ||
util.def( Type, 'coerce', util.describe( function coerce( o ) { return util.nativeType( o ) == 'function' ? o : function() { return o; }; }, 'w' ) ); | ||
util.def( Type, 'coerce', util.describe( function coerce( o ) { return util.ntype( o ) == 'function' ? o : function() { return o; }; }, 'w' ) ); | ||
@@ -83,3 +83,3 @@ util.defs( Type.prototype, { | ||
memoize : function( ctx, cache ) { | ||
var fn = this; util.nativeType( cache ) == 'object' || ( cache = util.obj() ); | ||
var fn = this; util.ntype( cache ) == 'object' || ( cache = util.obj() ); | ||
function memo() { | ||
@@ -103,3 +103,3 @@ var args = Array.coerce( arguments ), s = args.toString(); | ||
/*~ n8iv/src/Array.js ~*/ | ||
/*~ src/Array.js ~*/ | ||
util.x.cache( 'Array', function( Type ) { | ||
@@ -154,3 +154,3 @@ function groupByFn( field, v ) { return field( v ) ? '0' : '1'; } | ||
var a = this; fn || ( fn = util ); ctx || ( ctx = a ); | ||
util.nativeType( re ) != 'string' || ( re = new RegExp( re.escapeRE(), 'g' ) ); | ||
util.ntype( re ) != 'string' || ( re = new RegExp( re.escapeRE(), 'g' ) ); | ||
return PROTO.aggregate.call( a, [], function( v, o, i ) { | ||
@@ -193,3 +193,3 @@ !re.test( o ) || v.push( fn.call( ctx, o, i, a ) ); | ||
return PROTO.mapc.call( this, function( o, i ) { | ||
return util.nativeType( o[fn] ) == 'function' ? o[fn].apply( o, args ) : null; | ||
return util.ntype( o[fn] ) == 'function' ? o[fn].apply( o, args ) : null; | ||
} ); | ||
@@ -219,3 +219,3 @@ }, | ||
return PROTO.map.call( this, sortingVal, f ) | ||
.sort( util.nativeType( d ) == 'function' ? d : sort[String( d ).toLowerCase()] || sort.asc ) | ||
.sort( util.ntype( d ) == 'function' ? d : sort[String( d ).toLowerCase()] || sort.asc ) | ||
.map( sortedVal ); | ||
@@ -244,3 +244,3 @@ }, | ||
/*~ n8iv/src/Number.js ~*/ | ||
/*~ src/Number.js ~*/ | ||
util.x.cache( 'Number', function( Type ) { | ||
@@ -274,3 +274,3 @@ var abs = Math.abs, big_int = 9007199254740992, floor = Math.floor; | ||
/*~ n8iv/src/String.js ~*/ | ||
/*~ src/String.js ~*/ | ||
util.x.cache( 'String', function( Type ) { | ||
@@ -360,3 +360,3 @@ var cache_chars = util.obj(), cache_slices = util.obj(), | ||
truncate : function( i, c ) { | ||
i || ( i = 50 ); util.nativeType( c ) == 'string' || ( c = '...' ); | ||
i || ( i = 50 ); util.ntype( c ) == 'string' || ( c = '...' ); | ||
return this.length < i ? Type( this ) : this.substring( 0, i ).trimRight() + c; | ||
@@ -368,3 +368,3 @@ }, | ||
/*~ n8iv/src/expose.js ~*/ | ||
/*~ src/expose.js ~*/ | ||
function __lib__() { | ||
@@ -371,0 +371,0 @@ util.x.apply( util, arguments ); |
@@ -1,1 +0,1 @@ | ||
!function(e,t,n){"use strict";function r(){return e.x.apply(e,arguments),r}function i(t,n){return e.x.cache(t.__name__,n).x(t),r}e.x.cache("Object",function(t){function n(e,n){return e.length==n.length&&Array.coerce(e).every(function(e,r){return t.equalTo(n[r],e)})}function r(n,r){if(e.len(n)!==e.len(r)||t.ownLen(n)!==t.ownLen(r))return!1;for(var i in r)if(e.has(n,i)!==e.has(r,i)||!t.equalTo(n[i],r[i]))return!1;return!0}e.defs(t,{aggregate:function(e,n,r,i){return i||(i=e),t.keys(e).reduce(function(t,n,s){return r.call(i,t,e[n],n,e,s)},n)},clear:function(e){return t.keys(e).forEach(function(t){delete e[t]},e),e},equalTo:function(t,i){switch(e.nativeType(t)){case"array":return Array.isArray(i)?n(t,i):!1;case"object":return e.nativeType(i)=="object"?r(t,i):!1;case"date":return+t==+i}return t==i},ownKeys:function(e){return t.getOwnPropertyNames(e)},ownLen:function(e){return t.ownKeys(e).length}},"w")}),e.x.cache("Function",function(t){var n=/^[\s\(]*function[^\(]*\(([^\)]*)\)/,r=/\s*,\s*/;e.def(t,"coerce",e.describe(function(n){return e.nativeType(n)=="function"?n:function(){return n}},"w")),e.defs(t.prototype,{params:{get:function(){var e=String(this).match(n)[1].trim().split(r);return e.length==1&&!e[0]?[]:e}},attempt:function(e){var t=Array.coerce(arguments,1),n=this;return function(){try{return n.apply(e||this,t)}catch(i){return i}}()},bake:function(){var t="baked",n=this;return n[t]||!e.def(n,t,e.describe(function(){return n.apply(this,[this].concat(Array.coerce(arguments)))}.mimic(n),"w"))||n[t]},defer:e.ENV=="commonjs"?function(e){return process.nextTick(this.bind.apply(this,[e].concat(Array.coerce(arguments,1))))}:function(){return this.delay.apply(this,[1].concat(Array.coerce(arguments)))},delay:function(t,n){function s(){return s.stop(),i.apply(n||this,r)}var r=Array.coerce(arguments,2),i=this;return e.copy(s,{stop:function(){return clearTimeout(this.timeoutId),delete this.timeoutId,i},timeoutId:setTimeout(s,t)})},memoize:function(t,n){function i(){var e=Array.coerce(arguments),i=e.toString();return i in n?n[i]:n[i]=r.apply(t,e)}var r=this;return e.nativeType(n)=="object"||(n=e.obj()),i.unmemoize=function(){return r},i},stop:function(){return this},unmemoize:function(){return this},wrap:function(e){var t=Array.coerce(arguments,1),n=this;return function(){return e.apply(this,[n.bind(this)].concat(t).concat(Array.coerce(arguments)))}.mimic(e)}},"w")}),e.x.cache("Array",function(t){function n(e,t){return e(t)?"0":"1"}function r(e,t){return e.test(t)?"0":"1"}function i(e,t){return Object.value(t,e)||"1"}function s(e){return e?e:null}function o(e){return e[0]}function u(e){return[e,typeof this=="function"?this(e):Object.value(e,this)]}var a=t.prototype,f={desc:function(e,t){return e[1]==t[1]?0:e[1]<t[1]?1:-1},asc:function(e,t){return e[1]==t[1]?0:e[1]>t[1]?1:-1}};f[String(!0)]=f[1]=f.asc,f[String(!1)]=f[0]=f.desc,e.def(t,"sortFns",e.describe({value:f},"w")),e.defs(t.prototype,{aggregate:function(e,t,n){return a.reduce.call(this,function(e,r,i,s){return t.call(n||r,e,r,i,s)},e)},associate:function(t,n,r){return n||(n=e),r||(r=this),a.reduce.call(this,function(e,i,s){return e[t[s]]=n.call(r,i,s,this),e},e.obj())},clear:function(){return this.length=0,this},clone:function(){return a.slice.call(this)},compact:function(t){return a.mapc.call(this,t===!0?s:e)},contains:function(e){return!!~a.indexOf.call(this,e)},each:function(e,t){return a.forEach.call(this,e,t||this),this},flatten:function(n){if(e.type(n)=="number"){if(!(n>0))return this;--n}return a.aggregate.call(this,[],function(e,r,i){return t.isArray(r)?e.splice.apply(e,[e.length,0].concat(r.flatten(n))):e.push(r),e},this)},grep:function(t,n,r){var i=this;return n||(n=e),r||(r=i),e.nativeType(t)!="string"||(t=new RegExp(t.escapeRE(),"g")),a.aggregate.call(i,[],function(e,s,o){return!t.test(s)||e.push(n.call(r,s,o,i)),e})},groupBy:function(t,s,o){s||(s=e);var u=this,f,l,c={};switch(e.type(t)){case"function":l=n;break;case"regexp":l=r;break;case"number":case"string":l=i,f=a.pluck.call(u,t,!0);break;default:throw new TypeError("Array.prototype.groupBy can only match based on a Function, RegExp or String.")}return f?f.forEach(function(e){c[e]=[]}):(c[0]=[],c[1]=[]),a.aggregate.call(u,c,function(e,n,r){return e[l(t,n)].push(s.call(this,n,r,u)),e},o||u)},include:function(e){return a.contains.call(this,e)?!1:!this.push(e)||!0},invoke:function(e){var n=t.coerce(arguments,1);return a.map.call(this,function(t,r){return t[e].apply(t,n)})},invokec:function(n){var r=t.coerce(arguments,1);return a.mapc.call(this,function(t,i){return e.nativeType(t[n])=="function"?t[n].apply(t,r):null})},item:function(e){return this[e<0?this.length+e:e]},last:function(){return this[this.length-1]},mapc:function(t,n){return n||(n=this),a.reduce.call(this,function(r,i,s,o){return!e.exists(i=t.call(n,i,s,o))||r.push(i),r},[])},pluck:function(e,t){return a[t===!0?"mapc":"map"].call(this,function(t){return Object.value(t,e)})},remove:function(){var e=t.coerce(arguments),n,r=[],i;while(i=e.shift())!~(n=a.indexOf.call(this,i))||r.push(a.splice.call(this,n,1)[0]);return r},sortBy:function(t,n){return a.map.call(this,u,t).sort(e.nativeType(n)=="function"?n:f[String(n).toLowerCase()]||f.asc).map(o)},tuck:function(e,n){var r=t.isArray(n);return a.each.call(this,function(t,i){t[e]=r?n[i]:n})},uniq:function(){return a.reduce.call(this,function(e,t){return e.contains(t)||e.push(t),e},[])},without:function(){var e=a.clone.call(this);return e.remove.apply(e,arguments),e},zip:function(){var e=t.coerce(arguments);return e.unshift(this),a.map.call(this,function(t,n){return e.pluck(n)})}},"w")}),e.x.cache("Number",function(t){var n=Math.abs,r=9007199254740992,i=Math.floor;e.defs(t,{isInteger:function(t){return e.type(t)=="number"&&isFinite(t)&&t>-r&&t<r&&i(t)===t},toInteger:function(e){return e=+e,isNaN(e)?0:e===0||!isFinite(e)?e:(e<0?-1:1)*n(i(e))}},"w"),e.defs(t.prototype,{pad:function(e,t){var n=this.toString(t||10);return"0".times(e-n.length)+n},times:function(t,n){return e.range(0,this).forEach(t,n||e.global),this},toHex:function(){return this.pad(2,16)}},"w")}),e.x.cache("String",function(t){function h(e,t){return t+t.toLowerCase()}function p(e){e=e.trim();var t=e.charAt(0),n=e.charAt(1),r=t.toLowerCase()==t&&n!=" "&&n.toUpperCase()==n?2:1,i=e.substring(r).replace(o,h).split(l);return i[0]=e.substring(0,r)+i[0],i}var n=e.obj(),r=e.obj(),i=/([-\*\+\?\.\|\^\$\/\\\(\)[\]\{\}])/g,s="\\$1",o=/([A-Z])/g,u=/\$?\{([^\}]+)\}/g,a=/#?(\w{1,6})/,f=/(\d{1,3})/g,l=/[\sA-Z_-]+/g,c=/(.*?)\s*$/;e.defs(t.prototype,{blank:function(){return!!this.trim().empty()},capitalize:function(){return this.charAt(0).toUpperCase()+this.substring(1).toLowerCase()},clean:function(e){return e||(e=" "),e=n[e]||(n[e]={re:new RegExp("("+e+"){1,}","g"),fill:e}),this.split(e.re).filter(function(t){return!t.blank()&&t!=e.fill}).join(e.fill)},contains:function(e){return!!~this.indexOf(e)},empty:function(){return t(this)===""},endsWith:function(e){return this.length&&this.lastIndexOf(e)==this.length-e.length},format:function(){return this.gsub.call(this,Array.coerce(arguments))},gsub:function(e,t){return this.replace(t||u,function(t,n){return e[n]||""})},hyphenate:function(){return p(this).join("-").toLowerCase()},includes:function(e){return this.toLowerCase().contains(t(e).toLowerCase())},parts:function(e){var t=Array.coerce(this.match(e));switch(t.length){case 1:if(t[0]===null||t[0]===this)return[];default:return t[0]!==this||t.shift(),t}},regexpEsc:function(){return this.replace(i,s)},sliceEvery:function(e){return e=parseInt(e,10),isNaN(e)||this.length<e||e==0?[t(this)]:this.match(r[e]||(r[e]=new RegExp("(.{1,"+e+"})","g")))},startsWith:function(e){return!this.indexOf(e)},times:function(e){return(new Array(Number.toInteger(e)+1)).join(this)},toCamelCase:function(){var e=p(this),t=[e.shift()];return e.reduce(function(e,t){return e.push(t.capitalize()),e},t).join("")},toHex:function(){function e(e){return parseInt(e,10).pad(2,16)}return function(){var t=this.match(f);return"#"+(t.length==1?e(t[0]).times(3):t.map(e).join(""))}}(),toJSON:function(){return JSON.parse(this)},toRGB:function(e){var t=this.match(a)[1],n=t.length,r;switch(n){case 6:break;case 3:t=this.times(2);break;case 2:t=this.times(3);break;default:t=n>6?t.substring(0,6):n==4?t+"00":t+"0"}return r=t.sliceEvery(2).map(function(e){return parseInt(e,16)}),e===!0?r:"rgb("+r.join(", ")+")"},trimRight:function(){return this.replace(c,"$1")},truncate:function(n,r){return n||(n=50),e.nativeType(r)=="string"||(r="..."),this.length<n?t(this):this.substring(0,n).trimRight()+r},underscore:function(){return p(this).join("_").toLowerCase()}},"w")}),e.iter(n)||(n=e.ENV=="commonjs"?module:e.global),e.defs(r=e.expose(r,t,n),{util:e,x:i},"r"),e.expose(e,r),e.x(Object,Array,Function,Number,String)}(typeof m8!="undefined"?m8:typeof require!="undefined"?require("m8"):null,"n8iv") | ||
!function(e,t,n){"use strict";function r(){return e.x.apply(e,arguments),r}function i(t,n){return e.x.cache(t.__name__,n).x(t),r}e.x.cache("Object",function(t){function n(e,n){return e.length==n.length&&Array.coerce(e).every(function(e,r){return t.equalTo(n[r],e)})}function r(n,r){if(e.len(n)!==e.len(r)||t.ownLen(n)!==t.ownLen(r))return!1;for(var i in r)if(e.has(n,i)!==e.has(r,i)||!t.equalTo(n[i],r[i]))return!1;return!0}e.defs(t,{aggregate:function(e,n,r,i){return i||(i=e),t.keys(e).reduce(function(t,n,s){return r.call(i,t,e[n],n,e,s)},n)},clear:function(e){return t.keys(e).forEach(function(t){delete e[t]},e),e},equalTo:function(t,i){switch(e.ntype(t)){case"array":return Array.isArray(i)?n(t,i):!1;case"object":return e.ntype(i)=="object"?r(t,i):!1;case"date":return+t==+i}return t==i},ownKeys:function(e){return t.getOwnPropertyNames(e)},ownLen:function(e){return t.ownKeys(e).length}},"w")}),e.x.cache("Function",function(t){var n=/^[\s\(]*function[^\(]*\(([^\)]*)\)/,r=/\s*,\s*/;e.def(t,"coerce",e.describe(function(n){return e.ntype(n)=="function"?n:function(){return n}},"w")),e.defs(t.prototype,{params:{get:function(){var e=String(this).match(n)[1].trim().split(r);return e.length==1&&!e[0]?[]:e}},attempt:function(e){var t=Array.coerce(arguments,1),n=this;return function(){try{return n.apply(e||this,t)}catch(i){return i}}()},bake:function(){var t="baked",n=this;return n[t]||!e.def(n,t,e.describe(function(){return n.apply(this,[this].concat(Array.coerce(arguments)))}.mimic(n),"w"))||n[t]},defer:e.ENV=="commonjs"?function(e){return process.nextTick(this.bind.apply(this,[e].concat(Array.coerce(arguments,1))))}:function(){return this.delay.apply(this,[1].concat(Array.coerce(arguments)))},delay:function(t,n){function s(){return s.stop(),i.apply(n||this,r)}var r=Array.coerce(arguments,2),i=this;return e.copy(s,{stop:function(){return clearTimeout(this.timeoutId),delete this.timeoutId,i},timeoutId:setTimeout(s,t)})},memoize:function(t,n){function i(){var e=Array.coerce(arguments),i=e.toString();return i in n?n[i]:n[i]=r.apply(t,e)}var r=this;return e.ntype(n)=="object"||(n=e.obj()),i.unmemoize=function(){return r},i},stop:function(){return this},unmemoize:function(){return this},wrap:function(e){var t=Array.coerce(arguments,1),n=this;return function(){return e.apply(this,[n.bind(this)].concat(t).concat(Array.coerce(arguments)))}.mimic(e)}},"w")}),e.x.cache("Array",function(t){function n(e,t){return e(t)?"0":"1"}function r(e,t){return e.test(t)?"0":"1"}function i(e,t){return Object.value(t,e)||"1"}function s(e){return e?e:null}function o(e){return e[0]}function u(e){return[e,typeof this=="function"?this(e):Object.value(e,this)]}var a=t.prototype,f={desc:function(e,t){return e[1]==t[1]?0:e[1]<t[1]?1:-1},asc:function(e,t){return e[1]==t[1]?0:e[1]>t[1]?1:-1}};f[String(!0)]=f[1]=f.asc,f[String(!1)]=f[0]=f.desc,e.def(t,"sortFns",e.describe({value:f},"w")),e.defs(t.prototype,{aggregate:function(e,t,n){return a.reduce.call(this,function(e,r,i,s){return t.call(n||r,e,r,i,s)},e)},associate:function(t,n,r){return n||(n=e),r||(r=this),a.reduce.call(this,function(e,i,s){return e[t[s]]=n.call(r,i,s,this),e},e.obj())},clear:function(){return this.length=0,this},clone:function(){return a.slice.call(this)},compact:function(t){return a.mapc.call(this,t===!0?s:e)},contains:function(e){return!!~a.indexOf.call(this,e)},each:function(e,t){return a.forEach.call(this,e,t||this),this},flatten:function(n){if(e.type(n)=="number"){if(!(n>0))return this;--n}return a.aggregate.call(this,[],function(e,r,i){return t.isArray(r)?e.splice.apply(e,[e.length,0].concat(r.flatten(n))):e.push(r),e},this)},grep:function(t,n,r){var i=this;return n||(n=e),r||(r=i),e.ntype(t)!="string"||(t=new RegExp(t.escapeRE(),"g")),a.aggregate.call(i,[],function(e,s,o){return!t.test(s)||e.push(n.call(r,s,o,i)),e})},groupBy:function(t,s,o){s||(s=e);var u=this,f,l,c={};switch(e.type(t)){case"function":l=n;break;case"regexp":l=r;break;case"number":case"string":l=i,f=a.pluck.call(u,t,!0);break;default:throw new TypeError("Array.prototype.groupBy can only match based on a Function, RegExp or String.")}return f?f.forEach(function(e){c[e]=[]}):(c[0]=[],c[1]=[]),a.aggregate.call(u,c,function(e,n,r){return e[l(t,n)].push(s.call(this,n,r,u)),e},o||u)},include:function(e){return a.contains.call(this,e)?!1:!this.push(e)||!0},invoke:function(e){var n=t.coerce(arguments,1);return a.map.call(this,function(t,r){return t[e].apply(t,n)})},invokec:function(n){var r=t.coerce(arguments,1);return a.mapc.call(this,function(t,i){return e.ntype(t[n])=="function"?t[n].apply(t,r):null})},item:function(e){return this[e<0?this.length+e:e]},last:function(){return this[this.length-1]},mapc:function(t,n){return n||(n=this),a.reduce.call(this,function(r,i,s,o){return!e.exists(i=t.call(n,i,s,o))||r.push(i),r},[])},pluck:function(e,t){return a[t===!0?"mapc":"map"].call(this,function(t){return Object.value(t,e)})},remove:function(){var e=t.coerce(arguments),n,r=[],i;while(i=e.shift())!~(n=a.indexOf.call(this,i))||r.push(a.splice.call(this,n,1)[0]);return r},sortBy:function(t,n){return a.map.call(this,u,t).sort(e.ntype(n)=="function"?n:f[String(n).toLowerCase()]||f.asc).map(o)},tuck:function(e,n){var r=t.isArray(n);return a.each.call(this,function(t,i){t[e]=r?n[i]:n})},uniq:function(){return a.reduce.call(this,function(e,t){return e.contains(t)||e.push(t),e},[])},without:function(){var e=a.clone.call(this);return e.remove.apply(e,arguments),e},zip:function(){var e=t.coerce(arguments);return e.unshift(this),a.map.call(this,function(t,n){return e.pluck(n)})}},"w")}),e.x.cache("Number",function(t){var n=Math.abs,r=9007199254740992,i=Math.floor;e.defs(t,{isInteger:function(t){return e.type(t)=="number"&&isFinite(t)&&t>-r&&t<r&&i(t)===t},toInteger:function(e){return e=+e,isNaN(e)?0:e===0||!isFinite(e)?e:(e<0?-1:1)*n(i(e))}},"w"),e.defs(t.prototype,{pad:function(e,t){var n=this.toString(t||10);return"0".times(e-n.length)+n},times:function(t,n){return e.range(0,this).forEach(t,n||e.global),this},toHex:function(){return this.pad(2,16)}},"w")}),e.x.cache("String",function(t){function h(e,t){return t+t.toLowerCase()}function p(e){e=e.trim();var t=e.charAt(0),n=e.charAt(1),r=t.toLowerCase()==t&&n!=" "&&n.toUpperCase()==n?2:1,i=e.substring(r).replace(o,h).split(l);return i[0]=e.substring(0,r)+i[0],i}var n=e.obj(),r=e.obj(),i=/([-\*\+\?\.\|\^\$\/\\\(\)[\]\{\}])/g,s="\\$1",o=/([A-Z])/g,u=/\$?\{([^\}]+)\}/g,a=/#?(\w{1,6})/,f=/(\d{1,3})/g,l=/[\sA-Z_-]+/g,c=/(.*?)\s*$/;e.defs(t.prototype,{blank:function(){return!!this.trim().empty()},capitalize:function(){return this.charAt(0).toUpperCase()+this.substring(1).toLowerCase()},clean:function(e){return e||(e=" "),e=n[e]||(n[e]={re:new RegExp("("+e+"){1,}","g"),fill:e}),this.split(e.re).filter(function(t){return!t.blank()&&t!=e.fill}).join(e.fill)},contains:function(e){return!!~this.indexOf(e)},empty:function(){return t(this)===""},endsWith:function(e){return this.length&&this.lastIndexOf(e)==this.length-e.length},format:function(){return this.gsub.call(this,Array.coerce(arguments))},gsub:function(e,t){return this.replace(t||u,function(t,n){return e[n]||""})},hyphenate:function(){return p(this).join("-").toLowerCase()},includes:function(e){return this.toLowerCase().contains(t(e).toLowerCase())},parts:function(e){var t=Array.coerce(this.match(e));switch(t.length){case 1:if(t[0]===null||t[0]===this)return[];default:return t[0]!==this||t.shift(),t}},regexpEsc:function(){return this.replace(i,s)},sliceEvery:function(e){return e=parseInt(e,10),isNaN(e)||this.length<e||e==0?[t(this)]:this.match(r[e]||(r[e]=new RegExp("(.{1,"+e+"})","g")))},startsWith:function(e){return!this.indexOf(e)},times:function(e){return(new Array(Number.toInteger(e)+1)).join(this)},toCamelCase:function(){var e=p(this),t=[e.shift()];return e.reduce(function(e,t){return e.push(t.capitalize()),e},t).join("")},toHex:function(){function e(e){return parseInt(e,10).pad(2,16)}return function(){var t=this.match(f);return"#"+(t.length==1?e(t[0]).times(3):t.map(e).join(""))}}(),toJSON:function(){return JSON.parse(this)},toRGB:function(e){var t=this.match(a)[1],n=t.length,r;switch(n){case 6:break;case 3:t=this.times(2);break;case 2:t=this.times(3);break;default:t=n>6?t.substring(0,6):n==4?t+"00":t+"0"}return r=t.sliceEvery(2).map(function(e){return parseInt(e,16)}),e===!0?r:"rgb("+r.join(", ")+")"},trimRight:function(){return this.replace(c,"$1")},truncate:function(n,r){return n||(n=50),e.ntype(r)=="string"||(r="..."),this.length<n?t(this):this.substring(0,n).trimRight()+r},underscore:function(){return p(this).join("_").toLowerCase()}},"w")}),e.iter(n)||(n=e.ENV=="commonjs"?module:e.global),e.defs(r=e.expose(r,t,n),{util:e,x:i},"r"),e.expose(e,r),e.x(Object,Array,Function,Number,String)}(typeof m8!="undefined"?m8:typeof require!="undefined"?require("m8"):null,"n8iv") |
@@ -9,3 +9,3 @@ { | ||
"dependencies" : { | ||
"m8" : ">= 0.2.7" | ||
"m8" : ">= 0.3.1" | ||
}, | ||
@@ -18,3 +18,3 @@ "devDependencies" : { | ||
"engines" : { | ||
"node" : ">= 0.4.x" | ||
"node" : ">= 0.8.x" | ||
}, | ||
@@ -35,3 +35,3 @@ "keywords" : ["api", "framework", "functional", "javascript", "library", "programming"], | ||
}, | ||
"version" : "0.2.7" | ||
"version" : "0.2.8" | ||
} |
@@ -40,2 +40,7 @@ # n8iv.js [![build status](https://secure.travis-ci.org/constantology/n8iv.png)](http://travis-ci.org/constantology/n8iv) | ||
## File size | ||
- n8iv.js ≅ 4.6kb (gzipped) | ||
- n8iv.min.js ≅ 3.2kb (minzipped) | ||
## License | ||
@@ -42,0 +47,0 @@ |
@@ -50,3 +50,3 @@ util.x.cache( 'Array', function( Type ) { | ||
var a = this; fn || ( fn = util ); ctx || ( ctx = a ); | ||
util.nativeType( re ) != 'string' || ( re = new RegExp( re.escapeRE(), 'g' ) ); | ||
util.ntype( re ) != 'string' || ( re = new RegExp( re.escapeRE(), 'g' ) ); | ||
return PROTO.aggregate.call( a, [], function( v, o, i ) { | ||
@@ -89,3 +89,3 @@ !re.test( o ) || v.push( fn.call( ctx, o, i, a ) ); | ||
return PROTO.mapc.call( this, function( o, i ) { | ||
return util.nativeType( o[fn] ) == 'function' ? o[fn].apply( o, args ) : null; | ||
return util.ntype( o[fn] ) == 'function' ? o[fn].apply( o, args ) : null; | ||
} ); | ||
@@ -115,3 +115,3 @@ }, | ||
return PROTO.map.call( this, sortingVal, f ) | ||
.sort( util.nativeType( d ) == 'function' ? d : sort[String( d ).toLowerCase()] || sort.asc ) | ||
.sort( util.ntype( d ) == 'function' ? d : sort[String( d ).toLowerCase()] || sort.asc ) | ||
.map( sortedVal ); | ||
@@ -118,0 +118,0 @@ }, |
@@ -5,3 +5,3 @@ util.x.cache( 'Function', function( Type ) { | ||
util.def( Type, 'coerce', util.describe( function coerce( o ) { return util.nativeType( o ) == 'function' ? o : function() { return o; }; }, 'w' ) ); | ||
util.def( Type, 'coerce', util.describe( function coerce( o ) { return util.ntype( o ) == 'function' ? o : function() { return o; }; }, 'w' ) ); | ||
@@ -44,3 +44,3 @@ util.defs( Type.prototype, { | ||
memoize : function( ctx, cache ) { | ||
var fn = this; util.nativeType( cache ) == 'object' || ( cache = util.obj() ); | ||
var fn = this; util.ntype( cache ) == 'object' || ( cache = util.obj() ); | ||
function memo() { | ||
@@ -47,0 +47,0 @@ var args = Array.coerce( arguments ), s = args.toString(); |
@@ -21,5 +21,5 @@ util.x.cache( 'Object', function( Type ) { | ||
equalTo : function( o, k ) { | ||
switch ( util.nativeType( o ) ) { | ||
case 'array' : return Array.isArray( k ) ? arraysEqual( o, k ) : false; | ||
case 'object' : return util.nativeType( k ) == 'object' ? objectsEqual( o, k ) : false; | ||
switch ( util.ntype( o ) ) { | ||
case 'array' : return Array.isArray( k ) ? arraysEqual( o, k ) : false; | ||
case 'object' : return util.ntype( k ) == 'object' ? objectsEqual( o, k ) : false; | ||
case 'date' : return +o == +k; | ||
@@ -26,0 +26,0 @@ } |
@@ -85,3 +85,3 @@ util.x.cache( 'String', function( Type ) { | ||
truncate : function( i, c ) { | ||
i || ( i = 50 ); util.nativeType( c ) == 'string' || ( c = '...' ); | ||
i || ( i = 50 ); util.ntype( c ) == 'string' || ( c = '...' ); | ||
return this.length < i ? Type( this ) : this.substring( 0, i ).trimRight() + c; | ||
@@ -88,0 +88,0 @@ }, |
56
102403
Updatedm8@>= 0.3.1