jeefo_core
Advanced tools
Comparing version 0.0.12 to 0.0.14
/** | ||
* jeefo_core : v0.0.12 | ||
* jeefo_core : v0.0.14 | ||
* 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-10 | ||
* Updated at : 2017-07-22 | ||
* Author : jeefo | ||
@@ -20,3 +20,3 @@ * Purpose : | ||
var core_module = jeefo.module("jeefo_core", []), | ||
var core_module = jeefo.module("jeefo.core", []), | ||
@@ -33,130 +33,4 @@ CAMEL_CASE_REGEXP = /[A-Z]/g, | ||
}); | ||
}, | ||
}; | ||
_to_string = Object.prototype.toString, | ||
_function_to_string = Function.toString, | ||
is_date = { | ||
fn : function () { | ||
var to_string = _to_string; | ||
return 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_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 = { | ||
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 = { | ||
// 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 = { | ||
JSON : JSON, | ||
fn : function () { | ||
return function (value) { | ||
try { | ||
return this.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) { | ||
@@ -210,6 +84,5 @@ return function (full_name) { | ||
"make_injectable", | ||
"transform.snake_case", | ||
], function ($injector, make_injectable, snake_case) { | ||
], function ($injector, make_injectable) { | ||
return function (name) { | ||
$injector.register(snake_case(name + "Curry"), make_injectable.apply(null, arguments)); | ||
$injector.register(name + "_curry", make_injectable.apply(null, arguments)); | ||
return this; | ||
@@ -220,25 +93,13 @@ }; | ||
extend("run", ["$injector", "$q", "Array"], function ($injector, $q, Arr) { | ||
var instance = this; | ||
var self = this; | ||
return function (dependencies, fn) { | ||
if (typeof dependencies === "function") { | ||
dependencies.call(this); | ||
} else if (typeof dependencies === "string") { | ||
$injector.resolve(dependencies).then(function (value) { | ||
fn.call(instance, value); | ||
}); | ||
} else { | ||
var args = new Arr(dependencies.length); | ||
$q.for_each_async(dependencies, function (dependency, index, next) { | ||
$injector.resolve(dependency).then(function (value) { | ||
args[index] = value; | ||
next(); | ||
}); | ||
}).then(function () { | ||
fn.apply(instance, args); | ||
}); | ||
var i = dependencies.length, resolvers = new Arr(i); | ||
while (i--) { | ||
resolvers[i] = $injector.resolve(dependencies[i]); | ||
} | ||
return this; | ||
return $q.all(resolvers).then(function (values) { | ||
return fn.apply(self, values); | ||
}); | ||
}; | ||
@@ -250,6 +111,5 @@ }). | ||
"make_injectable", | ||
"transform.snake_case", | ||
], function ($injector, make_injectable, snake_case) { | ||
], function ($injector, make_injectable) { | ||
return function (name) { | ||
$injector.register(snake_case(name + "Factory"), make_injectable.apply(null, arguments)); | ||
$injector.register(name + "_factory", make_injectable.apply(null, arguments)); | ||
return this; | ||
@@ -262,4 +122,3 @@ }; | ||
"make_injectable", | ||
"transform.snake_case", | ||
], function ($injector, make_injectable, snake_case) { | ||
], function ($injector, make_injectable) { | ||
return function (name) { | ||
@@ -269,3 +128,3 @@ var injectable = make_injectable.apply(null, arguments); | ||
$injector.register(snake_case(name + "Service"), injectable); | ||
$injector.register(name + "_service", injectable); | ||
return this; | ||
@@ -276,16 +135,102 @@ }; | ||
run(["$injector", "object.assign"], function ($injector, assign) { | ||
if (! jeefo_object) { | ||
jeefo_object = createJeefoObject(assign); | ||
} | ||
var to_string = Object.prototype.toString, | ||
JeefoObject = function () {}, | ||
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+)?$/, | ||
// 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]"; | ||
}, | ||
is_regex = function (value) { | ||
return to_string.call(value) === "[object RegExp]"; | ||
}, | ||
is_digit = function (value, is_unsigned) { | ||
return (is_unsigned ? IS_DIGITS_UNSIGNED_NUMNER : IS_DIGITS_SIGNED_NUMBER).test(value); | ||
}, | ||
is_digit_int = 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; | ||
}, | ||
json_parse = function (value) { | ||
try { | ||
return JSON.parse(value); | ||
} catch (e) {} | ||
}; | ||
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); | ||
}, | ||
}; | ||
$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); | ||
register("is_date", { | ||
fn : function () { return is_date; } | ||
}). | ||
register("is_regex", { | ||
fn : function () { return is_regex; } | ||
}). | ||
register("is_digit", { | ||
fn : function () { return is_digit; } | ||
}). | ||
register("is_digit_int", { | ||
fn : function () { return is_digit_int; } | ||
}). | ||
register("is_native", { | ||
fn : function () { return is_native; } | ||
}). | ||
register("json_parse", { | ||
fn : function () { return json_parse; } | ||
}). | ||
register("JeefoObject", { | ||
fn : function () { return JeefoObject; } | ||
}); | ||
}); | ||
}); |
/** | ||
* jeefo_core : v0.0.12 | ||
* jeefo_core : v0.0.14 | ||
* 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,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); | ||
!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()})};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"],function(n,e){return function(t){return n.register(t+"_curry",e.apply(null,arguments)),this}}).extend("run",["$injector","$q","Array"],function(n,e,t){var r=this;return function(i,c){for(var o=i.length,u=new t(o);o--;)u[o]=n.resolve(i[o]);return e.all(u).then(function(n){return c.apply(r,n)})}}).extend("factory",["$injector","make_injectable"],function(n,e){return function(t){return n.register(t+"_factory",e.apply(null,arguments)),this}}).extend("service",["$injector","make_injectable"],function(n,e){return function(t){var r=e.apply(null,arguments);return r.is_constructor=!0,n.register(t+"_service",r),this}}).run(["$injector","object.assign"],function(n,e){var t=Object.prototype.toString,r=function(){},i=Function.toString,c=/^\[object .+?Constructor\]$/,o=/^function.*?\(\) \{ \[native code\] \}$/,u=function(n){return"[object Date]"===t.call(n)},s=function(n){return"[object RegExp]"===t.call(n)},f=function(n,e){return(e?/^\d+(?:.\d+)?$/:/^\-?\d+(?:.\d+)?$/).test(n)},a=function(n,e){return(e?/^\d+$/:/^\-?\d+$/).test(n)},l=function(n){var e=typeof n;return"function"===e?o.test(i.call(n)):n&&"object"===e&&c.test(t.call(n))||!1},p=function(n){try{return JSON.parse(n)}catch(n){}};r.create=function(n){return e(new r,n)},r.prototype={Array:Array,assign:e,JeefoObject:r,$new:function(){return new this.JeefoObject},$copy:function(){return this.assign(new this.JeefoObject,this)}},n.register("is_date",{fn:function(){return u}}).register("is_regex",{fn:function(){return s}}).register("is_digit",{fn:function(){return f}}).register("is_digit_int",{fn:function(){return a}}).register("is_native",{fn:function(){return l}}).register("json_parse",{fn:function(){return p}}).register("JeefoObject",{fn:function(){return r}})})})}(window.jeefo,window,document); |
@@ -7,3 +7,3 @@ | ||
/** | ||
* jeefo_core : v0.0.12 | ||
* jeefo_core : v0.0.14 | ||
* 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-10 | ||
* Updated at : 2017-07-22 | ||
* Author : jeefo | ||
@@ -26,3 +26,3 @@ * Purpose : | ||
var core_module = jeefo.module("jeefo_core", []), | ||
var core_module = jeefo.module("jeefo.core", []), | ||
@@ -39,130 +39,4 @@ CAMEL_CASE_REGEXP = /[A-Z]/g, | ||
}); | ||
}, | ||
}; | ||
_to_string = Object.prototype.toString, | ||
_function_to_string = Function.toString, | ||
is_date = { | ||
fn : function () { | ||
var to_string = _to_string; | ||
return 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_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 = { | ||
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 = { | ||
// 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 = { | ||
JSON : JSON, | ||
fn : function () { | ||
return function (value) { | ||
try { | ||
return this.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) { | ||
@@ -216,6 +90,5 @@ return function (full_name) { | ||
"make_injectable", | ||
"transform.snake_case", | ||
], function ($injector, make_injectable, snake_case) { | ||
], function ($injector, make_injectable) { | ||
return function (name) { | ||
$injector.register(snake_case(name + "Curry"), make_injectable.apply(null, arguments)); | ||
$injector.register(name + "_curry", make_injectable.apply(null, arguments)); | ||
return this; | ||
@@ -226,25 +99,13 @@ }; | ||
extend("run", ["$injector", "$q", "Array"], function ($injector, $q, Arr) { | ||
var instance = this; | ||
var self = this; | ||
return function (dependencies, fn) { | ||
if (typeof dependencies === "function") { | ||
dependencies.call(this); | ||
} else if (typeof dependencies === "string") { | ||
$injector.resolve(dependencies).then(function (value) { | ||
fn.call(instance, value); | ||
}); | ||
} else { | ||
var args = new Arr(dependencies.length); | ||
$q.for_each_async(dependencies, function (dependency, index, next) { | ||
$injector.resolve(dependency).then(function (value) { | ||
args[index] = value; | ||
next(); | ||
}); | ||
}).then(function () { | ||
fn.apply(instance, args); | ||
}); | ||
var i = dependencies.length, resolvers = new Arr(i); | ||
while (i--) { | ||
resolvers[i] = $injector.resolve(dependencies[i]); | ||
} | ||
return this; | ||
return $q.all(resolvers).then(function (values) { | ||
return fn.apply(self, values); | ||
}); | ||
}; | ||
@@ -256,6 +117,5 @@ }). | ||
"make_injectable", | ||
"transform.snake_case", | ||
], function ($injector, make_injectable, snake_case) { | ||
], function ($injector, make_injectable) { | ||
return function (name) { | ||
$injector.register(snake_case(name + "Factory"), make_injectable.apply(null, arguments)); | ||
$injector.register(name + "_factory", make_injectable.apply(null, arguments)); | ||
return this; | ||
@@ -268,4 +128,3 @@ }; | ||
"make_injectable", | ||
"transform.snake_case", | ||
], function ($injector, make_injectable, snake_case) { | ||
], function ($injector, make_injectable) { | ||
return function (name) { | ||
@@ -275,3 +134,3 @@ var injectable = make_injectable.apply(null, arguments); | ||
$injector.register(snake_case(name + "Service"), injectable); | ||
$injector.register(name + "_service", injectable); | ||
return this; | ||
@@ -282,14 +141,100 @@ }; | ||
run(["$injector", "object.assign"], function ($injector, assign) { | ||
if (! jeefo_object) { | ||
jeefo_object = createJeefoObject(assign); | ||
} | ||
var to_string = Object.prototype.toString, | ||
JeefoObject = function () {}, | ||
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+)?$/, | ||
// 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]"; | ||
}, | ||
is_regex = function (value) { | ||
return to_string.call(value) === "[object RegExp]"; | ||
}, | ||
is_digit = function (value, is_unsigned) { | ||
return (is_unsigned ? IS_DIGITS_UNSIGNED_NUMNER : IS_DIGITS_SIGNED_NUMBER).test(value); | ||
}, | ||
is_digit_int = 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; | ||
}, | ||
json_parse = function (value) { | ||
try { | ||
return JSON.parse(value); | ||
} catch (e) {} | ||
}; | ||
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); | ||
}, | ||
}; | ||
$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); | ||
register("is_date", { | ||
fn : function () { return is_date; } | ||
}). | ||
register("is_regex", { | ||
fn : function () { return is_regex; } | ||
}). | ||
register("is_digit", { | ||
fn : function () { return is_digit; } | ||
}). | ||
register("is_digit_int", { | ||
fn : function () { return is_digit_int; } | ||
}). | ||
register("is_native", { | ||
fn : function () { return is_native; } | ||
}). | ||
register("json_parse", { | ||
fn : function () { return json_parse; } | ||
}). | ||
register("JeefoObject", { | ||
fn : function () { return JeefoObject; } | ||
}); | ||
}); | ||
@@ -296,0 +241,0 @@ |
/** | ||
* jeefo_core : v0.0.12 | ||
* jeefo_core : v0.0.14 | ||
* 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,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}; | ||
"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()})};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"],function(n,e){return function(t){return n.register(t+"_curry",e.apply(null,arguments)),this}}).extend("run",["$injector","$q","Array"],function(n,e,t){var r=this;return function(i,c){for(var o=i.length,u=new t(o);o--;)u[o]=n.resolve(i[o]);return e.all(u).then(function(n){return c.apply(r,n)})}}).extend("factory",["$injector","make_injectable"],function(n,e){return function(t){return n.register(t+"_factory",e.apply(null,arguments)),this}}).extend("service",["$injector","make_injectable"],function(n,e){return function(t){var r=e.apply(null,arguments);return r.is_constructor=!0,n.register(t+"_service",r),this}}).run(["$injector","object.assign"],function(n,e){var t=Object.prototype.toString,r=function(){},i=Function.toString,c=/^\[object .+?Constructor\]$/,o=/^function.*?\(\) \{ \[native code\] \}$/,u=function(n){return"[object Date]"===t.call(n)},s=function(n){return"[object RegExp]"===t.call(n)},f=function(n,e){return(e?/^\d+(?:.\d+)?$/:/^\-?\d+(?:.\d+)?$/).test(n)},a=function(n,e){return(e?/^\d+$/:/^\-?\d+$/).test(n)},l=function(n){var e=typeof n;return"function"===e?o.test(i.call(n)):n&&"object"===e&&c.test(t.call(n))||!1},p=function(n){try{return JSON.parse(n)}catch(n){}};r.create=function(n){return e(new r,n)},r.prototype={Array:Array,assign:e,JeefoObject:r,$new:function(){return new this.JeefoObject},$copy:function(){return this.assign(new this.JeefoObject,this)}},n.register("is_date",{fn:function(){return u}}).register("is_regex",{fn:function(){return s}}).register("is_digit",{fn:function(){return f}}).register("is_digit_int",{fn:function(){return a}}).register("is_native",{fn:function(){return l}}).register("json_parse",{fn:function(){return p}}).register("JeefoObject",{fn:function(){return r}})})}),n}; |
{ | ||
"name": "jeefo_core", | ||
"version": "0.0.12", | ||
"version": "0.0.14", | ||
"homepage": "https://github.com/je3f0o/jeefo_core", | ||
@@ -32,3 +32,3 @@ "copyright": "2017", | ||
"dependencies": { | ||
"jeefo": "^0.0.13" | ||
"jeefo": "^0.0.24" | ||
}, | ||
@@ -35,0 +35,0 @@ "uglify_config": { |
318
src/core.js
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. | ||
* File Name : core.js | ||
* Created at : 2017-04-08 | ||
* Updated at : 2017-05-10 | ||
* Updated at : 2017-07-22 | ||
* Author : jeefo | ||
@@ -10,14 +10,6 @@ * Purpose : | ||
//ignore:start | ||
"use strict"; | ||
/* globals -IS_FUNCTION, -IS_STRING */ | ||
/* globals */ | ||
/* exported */ | ||
var IS_FUNCTION = function (x) { | ||
return typeof x === "function"; | ||
}; | ||
var IS_STRING = function (x) { | ||
return typeof x === "string"; | ||
}; | ||
module.exports = function (jeefo) { | ||
@@ -27,3 +19,3 @@ | ||
var core_module = jeefo.module("jeefo_core", []), | ||
var core_module = jeefo.module("jeefo.core", []), | ||
@@ -40,130 +32,4 @@ CAMEL_CASE_REGEXP = /[A-Z]/g, | ||
}); | ||
}, | ||
}; | ||
_to_string = Object.prototype.toString, | ||
_function_to_string = Function.toString, | ||
is_date = { | ||
fn : function () { | ||
var to_string = _to_string; | ||
return 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_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 = { | ||
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 = { | ||
// 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 = { | ||
JSON : JSON, | ||
fn : function () { | ||
return function (value) { | ||
try { | ||
return this.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) { | ||
@@ -217,6 +83,5 @@ return function (full_name) { | ||
"make_injectable", | ||
"transform.snake_case", | ||
], function ($injector, make_injectable, snake_case) { | ||
], function ($injector, make_injectable) { | ||
return function (name) { | ||
$injector.register(snake_case(`${ name }Curry`), make_injectable.apply(null, arguments)); | ||
$injector.register(`${ name }_curry`, make_injectable.apply(null, arguments)); | ||
return this; | ||
@@ -227,25 +92,13 @@ }; | ||
extend("run", ["$injector", "$q", "Array"], function ($injector, $q, Arr) { | ||
var instance = this; | ||
var self = this; | ||
return function (dependencies, fn) { | ||
if (IS_FUNCTION(dependencies)) { | ||
dependencies.call(this); | ||
} else if (IS_STRING(dependencies)) { | ||
$injector.resolve(dependencies).then(function (value) { | ||
fn.call(instance, value); | ||
}); | ||
} else { | ||
var args = new Arr(dependencies.length); | ||
$q.for_each_async(dependencies, function (dependency, index, next) { | ||
$injector.resolve(dependency).then(function (value) { | ||
args[index] = value; | ||
next(); | ||
}); | ||
}).then(function () { | ||
fn.apply(instance, args); | ||
}); | ||
var i = dependencies.length, resolvers = new Arr(i); | ||
while (i--) { | ||
resolvers[i] = $injector.resolve(dependencies[i]); | ||
} | ||
return this; | ||
return $q.all(resolvers).then(function (values) { | ||
return fn.apply(self, values); | ||
}); | ||
}; | ||
@@ -257,6 +110,5 @@ }). | ||
"make_injectable", | ||
"transform.snake_case", | ||
], function ($injector, make_injectable, snake_case) { | ||
], function ($injector, make_injectable) { | ||
return function (name) { | ||
$injector.register(snake_case(`${ name }Factory`), make_injectable.apply(null, arguments)); | ||
$injector.register(`${ name }_factory`, make_injectable.apply(null, arguments)); | ||
return this; | ||
@@ -269,4 +121,3 @@ }; | ||
"make_injectable", | ||
"transform.snake_case", | ||
], function ($injector, make_injectable, snake_case) { | ||
], function ($injector, make_injectable) { | ||
return function (name) { | ||
@@ -276,3 +127,3 @@ var injectable = make_injectable.apply(null, arguments); | ||
$injector.register(snake_case(`${ name }Service`), injectable); | ||
$injector.register(`${ name }_service`, injectable); | ||
return this; | ||
@@ -283,14 +134,100 @@ }; | ||
run(["$injector", "object.assign"], function ($injector, assign) { | ||
if (! jeefo_object) { | ||
jeefo_object = createJeefoObject(assign); | ||
} | ||
var to_string = Object.prototype.toString, | ||
JeefoObject = function () {}, | ||
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+)?$/, | ||
// 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]"; | ||
}, | ||
is_regex = function (value) { | ||
return to_string.call(value) === "[object RegExp]"; | ||
}, | ||
is_digit = function (value, is_unsigned) { | ||
return (is_unsigned ? IS_DIGITS_UNSIGNED_NUMNER : IS_DIGITS_SIGNED_NUMBER).test(value); | ||
}, | ||
is_digit_int = 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; | ||
}, | ||
json_parse = function (value) { | ||
try { | ||
return JSON.parse(value); | ||
} catch (e) {} | ||
}; | ||
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); | ||
}, | ||
}; | ||
$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); | ||
register("is_date", { | ||
fn : function () { return is_date; } | ||
}). | ||
register("is_regex", { | ||
fn : function () { return is_regex; } | ||
}). | ||
register("is_digit", { | ||
fn : function () { return is_digit; } | ||
}). | ||
register("is_digit_int", { | ||
fn : function () { return is_digit_int; } | ||
}). | ||
register("is_native", { | ||
fn : function () { return is_native; } | ||
}). | ||
register("json_parse", { | ||
fn : function () { return json_parse; } | ||
}). | ||
register("JeefoObject", { | ||
fn : function () { return JeefoObject; } | ||
}); | ||
}); | ||
@@ -305,2 +242,31 @@ | ||
var c = jeefo.module("test", ["jeefo.core"]); | ||
c.run([ | ||
"is_date", | ||
], function (is_date) { | ||
console.log("is_date", is_date(new Date())); | ||
}); | ||
c = jeefo.module("test2", ["test"]); | ||
c = jeefo.module("test3", ["test2"]); | ||
c = jeefo.module("test4", ["test3"]); | ||
c.run([ | ||
"is_date", | ||
"is_regex", | ||
"is_digit", | ||
"is_digit_int", | ||
"is_native", | ||
"json_parse", | ||
"JeefoObject", | ||
], function (is_date, is_regex, is_digit, is_digit_int, is_native, json_parse, JeefoObject) { | ||
console.log("is_date", is_date(new Date())); | ||
console.log("is_regex", is_regex(/asd/)); | ||
console.log("is_digit", is_digit("23.33")); | ||
console.log("is_digit_int", is_digit_int("23")); | ||
console.log("is_native", is_native(setTimeout)); | ||
console.log("json_parse", json_parse('{ "s" : 2 }')); | ||
console.log("JeefoObject", new JeefoObject()); | ||
}); | ||
// ignore:end |
Sorry, the diff of this file is not supported yet
67979
1383
+ Addedjeefo@0.0.24(transitive)
- Removedjeefo@0.0.13(transitive)
Updatedjeefo@^0.0.24