jeefo_core
Advanced tools
Comparing version 0.0.11 to 0.0.12
/** | ||
* jeefo_core : v0.0.10 | ||
* jeefo_core : v0.0.12 | ||
* Author : je3f0o, <je3f0o@gmail.com> | ||
@@ -13,3 +13,3 @@ * Homepage : https://github.com/je3f0o/jeefo_core | ||
* Created at : 2017-04-08 | ||
* Updated at : 2017-05-07 | ||
* Updated at : 2017-05-10 | ||
* Author : jeefo | ||
@@ -34,62 +34,128 @@ * Purpose : | ||
to_string = Object.prototype.toString, | ||
function_to_string = Function.toString, | ||
_to_string = Object.prototype.toString, | ||
_function_to_string = Function.toString, | ||
IS_DIGITS_SIGNED_INT = /^\-?\d+$/, | ||
IS_DIGITS_UNSIGNED_INT = /^\d+$/, | ||
IS_DIGITS_SIGNED_NUMBER = /^\-?\d+(?:.\d+)?$/, | ||
IS_DIGITS_UNSIGNED_NUMNER = /^\d+(?:.\d+)?$/, | ||
is_date = { | ||
fn : function () { | ||
var to_string = _to_string; | ||
// Used to detect host constructors (Safari > 4; really typed array specific) | ||
HOST_CONSTRUCTOR_REGEX = /^\[object .+?Constructor\]$/, | ||
/* | ||
// Compile a regexp using a common native method as a template. | ||
// We chose `Object#toString` because there's a good chance it is not being mucked with. | ||
new RegExp('^' + | ||
// Coerce `Object#toString` to a string | ||
String(to_string). | ||
// Escape any special regexp characters | ||
replace(/[.*+?^${}()|[\]\/\\]/g, "\\$&"). | ||
// Replace mentions of `toString` with `.*?` to keep the template generic. | ||
// Replace thing like `for ...` to support environments like Rhino which add extra info | ||
// such as method arity. | ||
replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + '$' | ||
) | ||
*/ | ||
NATIVE_REGEX = /^function.*?\(\) \{ \[native code\] \}$/, | ||
return function (value) { | ||
return to_string.call(value) === "[object Date]"; | ||
}; | ||
} | ||
}, | ||
is_date = function (value) { | ||
return to_string.call(value) === "[object Date]"; | ||
is_regex = { | ||
fn : function () { | ||
var to_string = _to_string; | ||
return function (value) { | ||
return to_string.call(value) === "[object RegExp]"; | ||
}; | ||
} | ||
}, | ||
is_regex = function (value) { | ||
return to_string.call(value) === "[object RegExp]"; | ||
is_digits = { | ||
IS_DIGITS_SIGNED_NUMBER : /^\-?\d+(?:.\d+)?$/, | ||
IS_DIGITS_UNSIGNED_NUMNER : /^\d+(?:.\d+)?$/, | ||
fn : function () { | ||
var IS_DIGITS_SIGNED_NUMBER = this.IS_DIGITS_SIGNED_NUMBER, | ||
IS_DIGITS_UNSIGNED_NUMNER = this.IS_DIGITS_UNSIGNED_NUMNER; | ||
return function (value, is_unsigned) { | ||
return (is_unsigned ? IS_DIGITS_UNSIGNED_NUMNER : IS_DIGITS_SIGNED_NUMBER).test(value); | ||
}; | ||
} | ||
}, | ||
is_digits = function (value, is_unsigned) { | ||
return (is_unsigned ? IS_DIGITS_UNSIGNED_NUMNER : IS_DIGITS_SIGNED_NUMBER).test(value); | ||
is_digits_int = { | ||
IS_DIGITS_SIGNED_INT : /^\-?\d+$/, | ||
IS_DIGITS_UNSIGNED_INT : /^\d+$/, | ||
fn : function () { | ||
var IS_DIGITS_SIGNED_INT = this.IS_DIGITS_SIGNED_INT, | ||
IS_DIGITS_UNSIGNED_INT = this.IS_DIGITS_UNSIGNED_INT; | ||
return function (value, is_unsigned) { | ||
return (is_unsigned ? IS_DIGITS_UNSIGNED_INT : IS_DIGITS_SIGNED_INT).test(value); | ||
}; | ||
} | ||
}, | ||
is_digits_int = function (value, is_unsigned) { | ||
return (is_unsigned ? IS_DIGITS_UNSIGNED_INT : IS_DIGITS_SIGNED_INT).test(value); | ||
is_native = { | ||
// Used to detect host constructors (Safari > 4; really typed array specific) | ||
HOST_CONSTRUCTOR_REGEX : /^\[object .+?Constructor\]$/, | ||
/* | ||
// Compile a regexp using a common native method as a template. | ||
// We chose `Object#toString` because there's a good chance it is not being mucked with. | ||
new RegExp('^' + | ||
// Coerce `Object#toString` to a string | ||
String(to_string). | ||
// Escape any special regexp characters | ||
replace(/[.*+?^${}()|[\]\/\\]/g, "\\$&"). | ||
// Replace mentions of `toString` with `.*?` to keep the template generic. | ||
// Replace thing like `for ...` to support environments like Rhino which add extra info | ||
// such as method arity. | ||
replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + '$' | ||
) | ||
*/ | ||
NATIVE_REGEX : /^function.*?\(\) \{ \[native code\] \}$/, | ||
fn : function () { | ||
var NATIVE_REGEX = this.NATIVE_REGEX, | ||
HOST_CONSTRUCTOR_REGEX = this. HOST_CONSTRUCTOR_REGEX, | ||
to_string = _to_string, | ||
function_to_string = _function_to_string; | ||
return function (value) { | ||
var type = typeof value; | ||
return type === "function" ? | ||
// Use `Function#toString` to bypass the value's own `toString` method | ||
// and avoid being faked out. | ||
NATIVE_REGEX.test(function_to_string.call(value)) : | ||
// Fallback to a host object check because some environments will represent | ||
// things like typed arrays as DOM methods which may not conform to the | ||
// normal native pattern. | ||
(value && type === "object" && HOST_CONSTRUCTOR_REGEX.test(to_string.call(value))) || false; | ||
}; | ||
} | ||
}, | ||
is_native = function (value) { | ||
var type = typeof value; | ||
return type === "function" ? | ||
// Use `Function#toString` to bypass the value's own `toString` method | ||
// and avoid being faked out. | ||
NATIVE_REGEX.test(function_to_string.call(value)) : | ||
// Fallback to a host object check because some environments will represent | ||
// things like typed arrays as DOM methods which may not conform to the | ||
// normal native pattern. | ||
(value && type === "object" && HOST_CONSTRUCTOR_REGEX.test(to_string.call(value))) || false; | ||
json_parse = { | ||
JSON : JSON, | ||
fn : function () { | ||
return function (value) { | ||
try { | ||
return this.JSON.parse(value); | ||
} catch (e) {} | ||
}; | ||
} | ||
}, | ||
json_parse = function (value) { | ||
try { | ||
return JSON.parse(value); | ||
} catch (e) {} | ||
}; | ||
createJeefoObject = function (assign) { | ||
var JeefoObject = function () {}; | ||
JeefoObject.create = function (object) { | ||
return assign(new JeefoObject(), object); | ||
}; | ||
JeefoObject.prototype = { | ||
Array : Array, | ||
assign : assign, | ||
JeefoObject : JeefoObject, | ||
$new : function () { | ||
return new this.JeefoObject(); | ||
}, | ||
$copy : function () { | ||
return this.assign(new this.JeefoObject(), this); | ||
}, | ||
}; | ||
return { | ||
fn : function () { return JeefoObject; } | ||
}; | ||
}, | ||
jeefo_object; | ||
core_module.extend("namespace", ["$injector", "make_injectable"], function (injector, make_injectable) { | ||
@@ -203,25 +269,17 @@ return function (full_name) { | ||
run("$injector", function ($injector) { | ||
run(["$injector", "object.assign"], function ($injector, assign) { | ||
if (! jeefo_object) { | ||
jeefo_object = createJeefoObject(assign); | ||
} | ||
$injector.register("is_date", { | ||
fn : function () { return is_date; } | ||
}). | ||
register("is_regex", { | ||
fn : function () { return is_regex; } | ||
}). | ||
register("is_digit", { | ||
fn : function () { return is_digits; } | ||
}). | ||
register("is_digit_int", { | ||
fn : function () { return is_digits_int; } | ||
}). | ||
register("is_native", { | ||
fn : function () { return is_native; } | ||
}). | ||
register("json_parse", { | ||
fn : function () { return json_parse; } | ||
}); | ||
$injector. | ||
register("is_date" , is_date). | ||
register("is_regex" , is_regex). | ||
register("is_digit" , is_digits). | ||
register("is_digit_int" , is_digits_int). | ||
register("is_native" , is_native). | ||
register("json_parse" , json_parse). | ||
register("JeefoObject" , jeefo_object); | ||
}); | ||
}); |
/** | ||
* jeefo_core : v0.0.10 | ||
* jeefo_core : v0.0.12 | ||
* Author : je3f0o, <je3f0o@gmail.com> | ||
@@ -8,2 +8,2 @@ * Homepage : https://github.com/je3f0o/jeefo_core | ||
**/ | ||
!function(n,e,t){"use strict";n.use(function(n){var e=n.module("jeefo_core",[]),t=function(n){return n.replace(/[A-Z]/g,function(n,e){return(e?"-":"")+n.toLowerCase()})},r=function(n){return n.replace(/[A-Z]/g,function(n,e){return(e?"_":"")+n.toLowerCase()})},i=Object.prototype.toString,c=Function.toString,o=/^\[object .+?Constructor\]$/,u=/^function.*?\(\) \{ \[native code\] \}$/,s=function(n){return"[object Date]"===i.call(n)},a=function(n){return"[object RegExp]"===i.call(n)},f=function(n,e){return(e?/^\d+(?:.\d+)?$/:/^\-?\d+(?:.\d+)?$/).test(n)},l=function(n,e){return(e?/^\d+$/:/^\-?\d+$/).test(n)},p=function(n){var e=typeof n;return"function"===e?u.test(c.call(n)):n&&"object"===e&&o.test(i.call(n))||!1},_=function(n){try{return JSON.parse(n)}catch(n){}};e.extend("namespace",["$injector","make_injectable"],function(n,e){return function(t){for(var r,i,c=t.split("."),o=c.pop(),u=0,s="";u<c.length;++u)r=c[u],s&&(i=n.resolve_sync(s)),s=s?s+"."+r:r,n.has(s)||(n.register(s,{fn:function(){return{}}}),i&&(i[r]=n.resolve_sync(s)));return n.register(t,e.apply(null,arguments)),s&&(i=n.resolve_sync(s),i[o]=n.resolve_sync(t)),this}}).namespace("transform.dash_case",function(){return t}).namespace("transform.snake_case",function(){return r}).extend("curry",["$injector","make_injectable","transform.snake_case"],function(n,e,t){return function(r){return n.register(t(r+"Curry"),e.apply(null,arguments)),this}}).extend("run",["$injector","$q","Array"],function(n,e,t){var r=this;return function(i,c){if("function"===typeof i)i.call(this);else if("string"===typeof i)n.resolve(i).then(function(n){c.call(r,n)});else{var o=new t(i.length);e.for_each_async(i,function(e,t,r){n.resolve(e).then(function(n){o[t]=n,r()})}).then(function(){c.apply(r,o)})}return this}}).extend("factory",["$injector","make_injectable","transform.snake_case"],function(n,e,t){return function(r){return n.register(t(r+"Factory"),e.apply(null,arguments)),this}}).extend("service",["$injector","make_injectable","transform.snake_case"],function(n,e,t){return function(r){var i=e.apply(null,arguments);return i.is_constructor=!0,n.register(t(r+"Service"),i),this}}).run("$injector",function(n){n.register("is_date",{fn:function(){return s}}).register("is_regex",{fn:function(){return a}}).register("is_digit",{fn:function(){return f}}).register("is_digit_int",{fn:function(){return l}}).register("is_native",{fn:function(){return p}}).register("json_parse",{fn:function(){return _}})})})}(window.jeefo,window,document); | ||
!function(n,e,t){"use strict";n.use(function(n){var e,t=n.module("jeefo_core",[]),r=function(n){return n.replace(/[A-Z]/g,function(n,e){return(e?"-":"")+n.toLowerCase()})},i=function(n){return n.replace(/[A-Z]/g,function(n,e){return(e?"_":"")+n.toLowerCase()})},c=Object.prototype.toString,o=Function.toString,u={fn:function(){var n=c;return function(e){return"[object Date]"===n.call(e)}}},s={fn:function(){var n=c;return function(e){return"[object RegExp]"===n.call(e)}}},a={IS_DIGITS_SIGNED_NUMBER:/^\-?\d+(?:.\d+)?$/,IS_DIGITS_UNSIGNED_NUMNER:/^\d+(?:.\d+)?$/,fn:function(){var n=this.IS_DIGITS_SIGNED_NUMBER,e=this.IS_DIGITS_UNSIGNED_NUMNER;return function(t,r){return(r?e:n).test(t)}}},f={IS_DIGITS_SIGNED_INT:/^\-?\d+$/,IS_DIGITS_UNSIGNED_INT:/^\d+$/,fn:function(){var n=this.IS_DIGITS_SIGNED_INT,e=this.IS_DIGITS_UNSIGNED_INT;return function(t,r){return(r?e:n).test(t)}}},_={HOST_CONSTRUCTOR_REGEX:/^\[object .+?Constructor\]$/,NATIVE_REGEX:/^function.*?\(\) \{ \[native code\] \}$/,fn:function(){var n=this.NATIVE_REGEX,e=this.HOST_CONSTRUCTOR_REGEX,t=c,r=o;return function(i){var c=typeof i;return"function"===c?n.test(r.call(i)):i&&"object"===c&&e.test(t.call(i))||!1}}},l={JSON:JSON,fn:function(){return function(n){try{return this.JSON.parse(n)}catch(n){}}}},I=function(n){var e=function(){};return e.create=function(t){return n(new e,t)},e.prototype={Array:Array,assign:n,JeefoObject:e,$new:function(){return new this.JeefoObject},$copy:function(){return this.assign(new this.JeefoObject,this)}},{fn:function(){return e}}};t.extend("namespace",["$injector","make_injectable"],function(n,e){return function(t){for(var r,i,c=t.split("."),o=c.pop(),u=0,s="";u<c.length;++u)r=c[u],s&&(i=n.resolve_sync(s)),s=s?s+"."+r:r,n.has(s)||(n.register(s,{fn:function(){return{}}}),i&&(i[r]=n.resolve_sync(s)));return n.register(t,e.apply(null,arguments)),s&&(i=n.resolve_sync(s),i[o]=n.resolve_sync(t)),this}}).namespace("transform.dash_case",function(){return r}).namespace("transform.snake_case",function(){return i}).extend("curry",["$injector","make_injectable","transform.snake_case"],function(n,e,t){return function(r){return n.register(t(r+"Curry"),e.apply(null,arguments)),this}}).extend("run",["$injector","$q","Array"],function(n,e,t){var r=this;return function(i,c){if("function"===typeof i)i.call(this);else if("string"===typeof i)n.resolve(i).then(function(n){c.call(r,n)});else{var o=new t(i.length);e.for_each_async(i,function(e,t,r){n.resolve(e).then(function(n){o[t]=n,r()})}).then(function(){c.apply(r,o)})}return this}}).extend("factory",["$injector","make_injectable","transform.snake_case"],function(n,e,t){return function(r){return n.register(t(r+"Factory"),e.apply(null,arguments)),this}}).extend("service",["$injector","make_injectable","transform.snake_case"],function(n,e,t){return function(r){var i=e.apply(null,arguments);return i.is_constructor=!0,n.register(t(r+"Service"),i),this}}).run(["$injector","object.assign"],function(n,t){e||(e=I(t)),n.register("is_date",u).register("is_regex",s).register("is_digit",a).register("is_digit_int",f).register("is_native",_).register("json_parse",l).register("JeefoObject",e)})})}(window.jeefo,window,document); |
@@ -7,3 +7,3 @@ | ||
/** | ||
* jeefo_core : v0.0.10 | ||
* jeefo_core : v0.0.12 | ||
* Author : je3f0o, <je3f0o@gmail.com> | ||
@@ -19,3 +19,3 @@ * Homepage : https://github.com/je3f0o/jeefo_core | ||
* Created at : 2017-04-08 | ||
* Updated at : 2017-05-07 | ||
* Updated at : 2017-05-10 | ||
* Author : jeefo | ||
@@ -40,62 +40,128 @@ * Purpose : | ||
to_string = Object.prototype.toString, | ||
function_to_string = Function.toString, | ||
_to_string = Object.prototype.toString, | ||
_function_to_string = Function.toString, | ||
IS_DIGITS_SIGNED_INT = /^\-?\d+$/, | ||
IS_DIGITS_UNSIGNED_INT = /^\d+$/, | ||
IS_DIGITS_SIGNED_NUMBER = /^\-?\d+(?:.\d+)?$/, | ||
IS_DIGITS_UNSIGNED_NUMNER = /^\d+(?:.\d+)?$/, | ||
is_date = { | ||
fn : function () { | ||
var to_string = _to_string; | ||
// Used to detect host constructors (Safari > 4; really typed array specific) | ||
HOST_CONSTRUCTOR_REGEX = /^\[object .+?Constructor\]$/, | ||
/* | ||
// Compile a regexp using a common native method as a template. | ||
// We chose `Object#toString` because there's a good chance it is not being mucked with. | ||
new RegExp('^' + | ||
// Coerce `Object#toString` to a string | ||
String(to_string). | ||
// Escape any special regexp characters | ||
replace(/[.*+?^${}()|[\]\/\\]/g, "\\$&"). | ||
// Replace mentions of `toString` with `.*?` to keep the template generic. | ||
// Replace thing like `for ...` to support environments like Rhino which add extra info | ||
// such as method arity. | ||
replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + '$' | ||
) | ||
*/ | ||
NATIVE_REGEX = /^function.*?\(\) \{ \[native code\] \}$/, | ||
return function (value) { | ||
return to_string.call(value) === "[object Date]"; | ||
}; | ||
} | ||
}, | ||
is_date = function (value) { | ||
return to_string.call(value) === "[object Date]"; | ||
is_regex = { | ||
fn : function () { | ||
var to_string = _to_string; | ||
return function (value) { | ||
return to_string.call(value) === "[object RegExp]"; | ||
}; | ||
} | ||
}, | ||
is_regex = function (value) { | ||
return to_string.call(value) === "[object RegExp]"; | ||
is_digits = { | ||
IS_DIGITS_SIGNED_NUMBER : /^\-?\d+(?:.\d+)?$/, | ||
IS_DIGITS_UNSIGNED_NUMNER : /^\d+(?:.\d+)?$/, | ||
fn : function () { | ||
var IS_DIGITS_SIGNED_NUMBER = this.IS_DIGITS_SIGNED_NUMBER, | ||
IS_DIGITS_UNSIGNED_NUMNER = this.IS_DIGITS_UNSIGNED_NUMNER; | ||
return function (value, is_unsigned) { | ||
return (is_unsigned ? IS_DIGITS_UNSIGNED_NUMNER : IS_DIGITS_SIGNED_NUMBER).test(value); | ||
}; | ||
} | ||
}, | ||
is_digits = function (value, is_unsigned) { | ||
return (is_unsigned ? IS_DIGITS_UNSIGNED_NUMNER : IS_DIGITS_SIGNED_NUMBER).test(value); | ||
is_digits_int = { | ||
IS_DIGITS_SIGNED_INT : /^\-?\d+$/, | ||
IS_DIGITS_UNSIGNED_INT : /^\d+$/, | ||
fn : function () { | ||
var IS_DIGITS_SIGNED_INT = this.IS_DIGITS_SIGNED_INT, | ||
IS_DIGITS_UNSIGNED_INT = this.IS_DIGITS_UNSIGNED_INT; | ||
return function (value, is_unsigned) { | ||
return (is_unsigned ? IS_DIGITS_UNSIGNED_INT : IS_DIGITS_SIGNED_INT).test(value); | ||
}; | ||
} | ||
}, | ||
is_digits_int = function (value, is_unsigned) { | ||
return (is_unsigned ? IS_DIGITS_UNSIGNED_INT : IS_DIGITS_SIGNED_INT).test(value); | ||
is_native = { | ||
// Used to detect host constructors (Safari > 4; really typed array specific) | ||
HOST_CONSTRUCTOR_REGEX : /^\[object .+?Constructor\]$/, | ||
/* | ||
// Compile a regexp using a common native method as a template. | ||
// We chose `Object#toString` because there's a good chance it is not being mucked with. | ||
new RegExp('^' + | ||
// Coerce `Object#toString` to a string | ||
String(to_string). | ||
// Escape any special regexp characters | ||
replace(/[.*+?^${}()|[\]\/\\]/g, "\\$&"). | ||
// Replace mentions of `toString` with `.*?` to keep the template generic. | ||
// Replace thing like `for ...` to support environments like Rhino which add extra info | ||
// such as method arity. | ||
replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + '$' | ||
) | ||
*/ | ||
NATIVE_REGEX : /^function.*?\(\) \{ \[native code\] \}$/, | ||
fn : function () { | ||
var NATIVE_REGEX = this.NATIVE_REGEX, | ||
HOST_CONSTRUCTOR_REGEX = this. HOST_CONSTRUCTOR_REGEX, | ||
to_string = _to_string, | ||
function_to_string = _function_to_string; | ||
return function (value) { | ||
var type = typeof value; | ||
return type === "function" ? | ||
// Use `Function#toString` to bypass the value's own `toString` method | ||
// and avoid being faked out. | ||
NATIVE_REGEX.test(function_to_string.call(value)) : | ||
// Fallback to a host object check because some environments will represent | ||
// things like typed arrays as DOM methods which may not conform to the | ||
// normal native pattern. | ||
(value && type === "object" && HOST_CONSTRUCTOR_REGEX.test(to_string.call(value))) || false; | ||
}; | ||
} | ||
}, | ||
is_native = function (value) { | ||
var type = typeof value; | ||
return type === "function" ? | ||
// Use `Function#toString` to bypass the value's own `toString` method | ||
// and avoid being faked out. | ||
NATIVE_REGEX.test(function_to_string.call(value)) : | ||
// Fallback to a host object check because some environments will represent | ||
// things like typed arrays as DOM methods which may not conform to the | ||
// normal native pattern. | ||
(value && type === "object" && HOST_CONSTRUCTOR_REGEX.test(to_string.call(value))) || false; | ||
json_parse = { | ||
JSON : JSON, | ||
fn : function () { | ||
return function (value) { | ||
try { | ||
return this.JSON.parse(value); | ||
} catch (e) {} | ||
}; | ||
} | ||
}, | ||
json_parse = function (value) { | ||
try { | ||
return JSON.parse(value); | ||
} catch (e) {} | ||
}; | ||
createJeefoObject = function (assign) { | ||
var JeefoObject = function () {}; | ||
JeefoObject.create = function (object) { | ||
return assign(new JeefoObject(), object); | ||
}; | ||
JeefoObject.prototype = { | ||
Array : Array, | ||
assign : assign, | ||
JeefoObject : JeefoObject, | ||
$new : function () { | ||
return new this.JeefoObject(); | ||
}, | ||
$copy : function () { | ||
return this.assign(new this.JeefoObject(), this); | ||
}, | ||
}; | ||
return { | ||
fn : function () { return JeefoObject; } | ||
}; | ||
}, | ||
jeefo_object; | ||
core_module.extend("namespace", ["$injector", "make_injectable"], function (injector, make_injectable) { | ||
@@ -209,23 +275,15 @@ return function (full_name) { | ||
run("$injector", function ($injector) { | ||
run(["$injector", "object.assign"], function ($injector, assign) { | ||
if (! jeefo_object) { | ||
jeefo_object = createJeefoObject(assign); | ||
} | ||
$injector.register("is_date", { | ||
fn : function () { return is_date; } | ||
}). | ||
register("is_regex", { | ||
fn : function () { return is_regex; } | ||
}). | ||
register("is_digit", { | ||
fn : function () { return is_digits; } | ||
}). | ||
register("is_digit_int", { | ||
fn : function () { return is_digits_int; } | ||
}). | ||
register("is_native", { | ||
fn : function () { return is_native; } | ||
}). | ||
register("json_parse", { | ||
fn : function () { return json_parse; } | ||
}); | ||
$injector. | ||
register("is_date" , is_date). | ||
register("is_regex" , is_regex). | ||
register("is_digit" , is_digits). | ||
register("is_digit_int" , is_digits_int). | ||
register("is_native" , is_native). | ||
register("json_parse" , json_parse). | ||
register("JeefoObject" , jeefo_object); | ||
}); | ||
@@ -232,0 +290,0 @@ |
/** | ||
* jeefo_core : v0.0.10 | ||
* jeefo_core : v0.0.12 | ||
* Author : je3f0o, <je3f0o@gmail.com> | ||
@@ -8,2 +8,2 @@ * Homepage : https://github.com/je3f0o/jeefo_core | ||
**/ | ||
"use strict";module.exports=function(n){return n.use(function(n){var e=n.module("jeefo_core",[]),t=function(n){return n.replace(/[A-Z]/g,function(n,e){return(e?"-":"")+n.toLowerCase()})},r=function(n){return n.replace(/[A-Z]/g,function(n,e){return(e?"_":"")+n.toLowerCase()})},c=Object.prototype.toString,i=Function.toString,o=/^\[object .+?Constructor\]$/,u=/^function.*?\(\) \{ \[native code\] \}$/,s=function(n){return"[object Date]"===c.call(n)},a=function(n){return"[object RegExp]"===c.call(n)},f=function(n,e){return(e?/^\d+(?:.\d+)?$/:/^\-?\d+(?:.\d+)?$/).test(n)},l=function(n,e){return(e?/^\d+$/:/^\-?\d+$/).test(n)},p=function(n){var e=typeof n;return"function"===e?u.test(i.call(n)):n&&"object"===e&&o.test(c.call(n))||!1},_=function(n){try{return JSON.parse(n)}catch(n){}};e.extend("namespace",["$injector","make_injectable"],function(n,e){return function(t){for(var r,c,i=t.split("."),o=i.pop(),u=0,s="";u<i.length;++u)r=i[u],s&&(c=n.resolve_sync(s)),s=s?s+"."+r:r,n.has(s)||(n.register(s,{fn:function(){return{}}}),c&&(c[r]=n.resolve_sync(s)));return n.register(t,e.apply(null,arguments)),s&&(c=n.resolve_sync(s),c[o]=n.resolve_sync(t)),this}}).namespace("transform.dash_case",function(){return t}).namespace("transform.snake_case",function(){return r}).extend("curry",["$injector","make_injectable","transform.snake_case"],function(n,e,t){return function(r){return n.register(t(r+"Curry"),e.apply(null,arguments)),this}}).extend("run",["$injector","$q","Array"],function(n,e,t){var r=this;return function(c,i){if("function"===typeof c)c.call(this);else if("string"===typeof c)n.resolve(c).then(function(n){i.call(r,n)});else{var o=new t(c.length);e.for_each_async(c,function(e,t,r){n.resolve(e).then(function(n){o[t]=n,r()})}).then(function(){i.apply(r,o)})}return this}}).extend("factory",["$injector","make_injectable","transform.snake_case"],function(n,e,t){return function(r){return n.register(t(r+"Factory"),e.apply(null,arguments)),this}}).extend("service",["$injector","make_injectable","transform.snake_case"],function(n,e,t){return function(r){var c=e.apply(null,arguments);return c.is_constructor=!0,n.register(t(r+"Service"),c),this}}).run("$injector",function(n){n.register("is_date",{fn:function(){return s}}).register("is_regex",{fn:function(){return a}}).register("is_digit",{fn:function(){return f}}).register("is_digit_int",{fn:function(){return l}}).register("is_native",{fn:function(){return p}}).register("json_parse",{fn:function(){return _}})})}),n}; | ||
"use strict";module.exports=function(n){return n.use(function(n){var e,t=n.module("jeefo_core",[]),r=function(n){return n.replace(/[A-Z]/g,function(n,e){return(e?"-":"")+n.toLowerCase()})},i=function(n){return n.replace(/[A-Z]/g,function(n,e){return(e?"_":"")+n.toLowerCase()})},c=Object.prototype.toString,o=Function.toString,u={fn:function(){var n=c;return function(e){return"[object Date]"===n.call(e)}}},s={fn:function(){var n=c;return function(e){return"[object RegExp]"===n.call(e)}}},a={IS_DIGITS_SIGNED_NUMBER:/^\-?\d+(?:.\d+)?$/,IS_DIGITS_UNSIGNED_NUMNER:/^\d+(?:.\d+)?$/,fn:function(){var n=this.IS_DIGITS_SIGNED_NUMBER,e=this.IS_DIGITS_UNSIGNED_NUMNER;return function(t,r){return(r?e:n).test(t)}}},f={IS_DIGITS_SIGNED_INT:/^\-?\d+$/,IS_DIGITS_UNSIGNED_INT:/^\d+$/,fn:function(){var n=this.IS_DIGITS_SIGNED_INT,e=this.IS_DIGITS_UNSIGNED_INT;return function(t,r){return(r?e:n).test(t)}}},_={HOST_CONSTRUCTOR_REGEX:/^\[object .+?Constructor\]$/,NATIVE_REGEX:/^function.*?\(\) \{ \[native code\] \}$/,fn:function(){var n=this.NATIVE_REGEX,e=this.HOST_CONSTRUCTOR_REGEX,t=c,r=o;return function(i){var c=typeof i;return"function"===c?n.test(r.call(i)):i&&"object"===c&&e.test(t.call(i))||!1}}},l={JSON:JSON,fn:function(){return function(n){try{return this.JSON.parse(n)}catch(n){}}}},I=function(n){var e=function(){};return e.create=function(t){return n(new e,t)},e.prototype={Array:Array,assign:n,JeefoObject:e,$new:function(){return new this.JeefoObject},$copy:function(){return this.assign(new this.JeefoObject,this)}},{fn:function(){return e}}};t.extend("namespace",["$injector","make_injectable"],function(n,e){return function(t){for(var r,i,c=t.split("."),o=c.pop(),u=0,s="";u<c.length;++u)r=c[u],s&&(i=n.resolve_sync(s)),s=s?s+"."+r:r,n.has(s)||(n.register(s,{fn:function(){return{}}}),i&&(i[r]=n.resolve_sync(s)));return n.register(t,e.apply(null,arguments)),s&&(i=n.resolve_sync(s),i[o]=n.resolve_sync(t)),this}}).namespace("transform.dash_case",function(){return r}).namespace("transform.snake_case",function(){return i}).extend("curry",["$injector","make_injectable","transform.snake_case"],function(n,e,t){return function(r){return n.register(t(r+"Curry"),e.apply(null,arguments)),this}}).extend("run",["$injector","$q","Array"],function(n,e,t){var r=this;return function(i,c){if("function"===typeof i)i.call(this);else if("string"===typeof i)n.resolve(i).then(function(n){c.call(r,n)});else{var o=new t(i.length);e.for_each_async(i,function(e,t,r){n.resolve(e).then(function(n){o[t]=n,r()})}).then(function(){c.apply(r,o)})}return this}}).extend("factory",["$injector","make_injectable","transform.snake_case"],function(n,e,t){return function(r){return n.register(t(r+"Factory"),e.apply(null,arguments)),this}}).extend("service",["$injector","make_injectable","transform.snake_case"],function(n,e,t){return function(r){var i=e.apply(null,arguments);return i.is_constructor=!0,n.register(t(r+"Service"),i),this}}).run(["$injector","object.assign"],function(n,t){e||(e=I(t)),n.register("is_date",u).register("is_regex",s).register("is_digit",a).register("is_digit_int",f).register("is_native",_).register("json_parse",l).register("JeefoObject",e)})}),n}; |
{ | ||
"name": "jeefo_core", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"homepage": "https://github.com/je3f0o/jeefo_core", | ||
@@ -5,0 +5,0 @@ "copyright": "2017", |
213
src/core.js
@@ -40,75 +40,128 @@ /* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. | ||
to_string = Object.prototype.toString, | ||
function_to_string = Function.toString, | ||
_to_string = Object.prototype.toString, | ||
_function_to_string = Function.toString, | ||
IS_DIGITS_SIGNED_INT = /^\-?\d+$/, | ||
IS_DIGITS_UNSIGNED_INT = /^\d+$/, | ||
IS_DIGITS_SIGNED_NUMBER = /^\-?\d+(?:.\d+)?$/, | ||
IS_DIGITS_UNSIGNED_NUMNER = /^\d+(?:.\d+)?$/, | ||
is_date = { | ||
fn : function () { | ||
var to_string = _to_string; | ||
// Used to detect host constructors (Safari > 4; really typed array specific) | ||
HOST_CONSTRUCTOR_REGEX = /^\[object .+?Constructor\]$/, | ||
/* | ||
// Compile a regexp using a common native method as a template. | ||
// We chose `Object#toString` because there's a good chance it is not being mucked with. | ||
new RegExp('^' + | ||
// Coerce `Object#toString` to a string | ||
String(to_string). | ||
// Escape any special regexp characters | ||
replace(/[.*+?^${}()|[\]\/\\]/g, "\\$&"). | ||
// Replace mentions of `toString` with `.*?` to keep the template generic. | ||
// Replace thing like `for ...` to support environments like Rhino which add extra info | ||
// such as method arity. | ||
replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + '$' | ||
) | ||
*/ | ||
NATIVE_REGEX = /^function.*?\(\) \{ \[native code\] \}$/, | ||
is_date = function (value) { | ||
return to_string.call(value) === "[object Date]"; | ||
return function (value) { | ||
return to_string.call(value) === "[object Date]"; | ||
}; | ||
} | ||
}, | ||
is_regex = function (value) { | ||
return to_string.call(value) === "[object RegExp]"; | ||
is_regex = { | ||
fn : function () { | ||
var to_string = _to_string; | ||
return function (value) { | ||
return to_string.call(value) === "[object RegExp]"; | ||
}; | ||
} | ||
}, | ||
is_digits = function (value, is_unsigned) { | ||
return (is_unsigned ? IS_DIGITS_UNSIGNED_NUMNER : IS_DIGITS_SIGNED_NUMBER).test(value); | ||
is_digits = { | ||
IS_DIGITS_SIGNED_NUMBER : /^\-?\d+(?:.\d+)?$/, | ||
IS_DIGITS_UNSIGNED_NUMNER : /^\d+(?:.\d+)?$/, | ||
fn : function () { | ||
var IS_DIGITS_SIGNED_NUMBER = this.IS_DIGITS_SIGNED_NUMBER, | ||
IS_DIGITS_UNSIGNED_NUMNER = this.IS_DIGITS_UNSIGNED_NUMNER; | ||
return function (value, is_unsigned) { | ||
return (is_unsigned ? IS_DIGITS_UNSIGNED_NUMNER : IS_DIGITS_SIGNED_NUMBER).test(value); | ||
}; | ||
} | ||
}, | ||
is_digits_int = function (value, is_unsigned) { | ||
return (is_unsigned ? IS_DIGITS_UNSIGNED_INT : IS_DIGITS_SIGNED_INT).test(value); | ||
is_digits_int = { | ||
IS_DIGITS_SIGNED_INT : /^\-?\d+$/, | ||
IS_DIGITS_UNSIGNED_INT : /^\d+$/, | ||
fn : function () { | ||
var IS_DIGITS_SIGNED_INT = this.IS_DIGITS_SIGNED_INT, | ||
IS_DIGITS_UNSIGNED_INT = this.IS_DIGITS_UNSIGNED_INT; | ||
return function (value, is_unsigned) { | ||
return (is_unsigned ? IS_DIGITS_UNSIGNED_INT : IS_DIGITS_SIGNED_INT).test(value); | ||
}; | ||
} | ||
}, | ||
is_native = function (value) { | ||
var type = typeof value; | ||
return type === "function" ? | ||
// Use `Function#toString` to bypass the value's own `toString` method | ||
// and avoid being faked out. | ||
NATIVE_REGEX.test(function_to_string.call(value)) : | ||
// Fallback to a host object check because some environments will represent | ||
// things like typed arrays as DOM methods which may not conform to the | ||
// normal native pattern. | ||
(value && type === "object" && HOST_CONSTRUCTOR_REGEX.test(to_string.call(value))) || false; | ||
is_native = { | ||
// Used to detect host constructors (Safari > 4; really typed array specific) | ||
HOST_CONSTRUCTOR_REGEX : /^\[object .+?Constructor\]$/, | ||
/* | ||
// Compile a regexp using a common native method as a template. | ||
// We chose `Object#toString` because there's a good chance it is not being mucked with. | ||
new RegExp('^' + | ||
// Coerce `Object#toString` to a string | ||
String(to_string). | ||
// Escape any special regexp characters | ||
replace(/[.*+?^${}()|[\]\/\\]/g, "\\$&"). | ||
// Replace mentions of `toString` with `.*?` to keep the template generic. | ||
// Replace thing like `for ...` to support environments like Rhino which add extra info | ||
// such as method arity. | ||
replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + '$' | ||
) | ||
*/ | ||
NATIVE_REGEX : /^function.*?\(\) \{ \[native code\] \}$/, | ||
fn : function () { | ||
var NATIVE_REGEX = this.NATIVE_REGEX, | ||
HOST_CONSTRUCTOR_REGEX = this. HOST_CONSTRUCTOR_REGEX, | ||
to_string = _to_string, | ||
function_to_string = _function_to_string; | ||
return function (value) { | ||
var type = typeof value; | ||
return type === "function" ? | ||
// Use `Function#toString` to bypass the value's own `toString` method | ||
// and avoid being faked out. | ||
NATIVE_REGEX.test(function_to_string.call(value)) : | ||
// Fallback to a host object check because some environments will represent | ||
// things like typed arrays as DOM methods which may not conform to the | ||
// normal native pattern. | ||
(value && type === "object" && HOST_CONSTRUCTOR_REGEX.test(to_string.call(value))) || false; | ||
}; | ||
} | ||
}, | ||
json_parse = function (value) { | ||
try { | ||
return JSON.parse(value); | ||
} catch (e) {} | ||
json_parse = { | ||
JSON : JSON, | ||
fn : function () { | ||
return function (value) { | ||
try { | ||
return this.JSON.parse(value); | ||
} catch (e) {} | ||
}; | ||
} | ||
}, | ||
JeefoObject = function () {}; | ||
createJeefoObject = function (assign) { | ||
var JeefoObject = function () {}; | ||
JeefoObject.prototype = { | ||
Array : Array, | ||
JeefoObject : JeefoObject, | ||
$new : function () { | ||
return new this.JeefoObject(); | ||
}, | ||
$copy : function () { | ||
return this.assign(new this.JeefoObject(), this); | ||
}, | ||
}; | ||
JeefoObject.create = function (object) { | ||
return assign(new JeefoObject(), object); | ||
}; | ||
JeefoObject.prototype = { | ||
Array : Array, | ||
assign : assign, | ||
JeefoObject : JeefoObject, | ||
$new : function () { | ||
return new this.JeefoObject(); | ||
}, | ||
$copy : function () { | ||
return this.assign(new this.JeefoObject(), this); | ||
}, | ||
}; | ||
return { | ||
fn : function () { return JeefoObject; } | ||
}; | ||
}, | ||
jeefo_object; | ||
core_module.extend("namespace", ["$injector", "make_injectable"], function (injector, make_injectable) { | ||
@@ -151,16 +204,2 @@ return function (full_name) { | ||
namespace("JeefoObject", ["object.assign"], function (assign) { | ||
if (JeefoObject.create) { | ||
JeefoObject.create = function (object) { | ||
return assign(new JeefoObject(), object); | ||
}; | ||
} | ||
if (! JeefoObject.prototype.assign) { | ||
JeefoObject.prototype.assign = assign; | ||
} | ||
return JeefoObject; | ||
}). | ||
namespace("transform.dash_case", function () { | ||
@@ -237,23 +276,15 @@ return dash_case; | ||
run("$injector", function ($injector) { | ||
run(["$injector", "object.assign"], function ($injector, assign) { | ||
if (! jeefo_object) { | ||
jeefo_object = createJeefoObject(assign); | ||
} | ||
$injector.register("is_date", { | ||
fn : function () { return is_date; } | ||
}). | ||
register("is_regex", { | ||
fn : function () { return is_regex; } | ||
}). | ||
register("is_digit", { | ||
fn : function () { return is_digits; } | ||
}). | ||
register("is_digit_int", { | ||
fn : function () { return is_digits_int; } | ||
}). | ||
register("is_native", { | ||
fn : function () { return is_native; } | ||
}). | ||
register("json_parse", { | ||
fn : function () { return json_parse; } | ||
}); | ||
$injector. | ||
register("is_date" , is_date). | ||
register("is_regex" , is_regex). | ||
register("is_digit" , is_digits). | ||
register("is_digit_int" , is_digits_int). | ||
register("is_native" , is_native). | ||
register("json_parse" , json_parse). | ||
register("JeefoObject" , jeefo_object); | ||
}); | ||
@@ -260,0 +291,0 @@ |
71850
1496