Skip to content

Commit

Permalink
Fix isObject regex; add console.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Juriy Zaytsev committed Feb 22, 2009
1 parent f3d1dcd commit cb8325f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
37 changes: 37 additions & 0 deletions console.js
@@ -0,0 +1,37 @@
(function(global){

var global = this;

var methods = (function(){
var timeTable = { };
function time(id) {
timeTable['_' + id] = new Date();
}
function timeEnd(id) {
var _id = '_' + id;
if (timeTable[_id]) {
console.log(id + ': ' + (new Date() - timeTable[_id]) + 'ms');
delete timeTable[_id];
}
}
return {
time: time,
timeEnd: timeEnd
}
})();

if (!global.console) {
global.console = { }
}
if (!global.console.log) {
global.console.log = (global.opera && global.opera.postError)
? global.opera.postError
: function(){ }
}
if (!global.console.time) {
global.console.time = methods.time;
}
if (!global.console.timeEnd) {
global.console.timeEnd = methods.timeEnd;
}
})();
4 changes: 2 additions & 2 deletions object.extensions.js
Expand Up @@ -118,7 +118,7 @@ Object.isNodeList = function(object) {
};

Object.isPrimitive = function(o) {
return (o == null || /number|string|boolean/.test(typeof o));
return (o == null || /^(number|string|boolean)$/.test(typeof o));
};

Object.hasMagicLength = function(o) {
Expand All @@ -141,7 +141,7 @@ Object.hasMagicLength = function(o) {
Object.create = (function(){
function F(){};
function isObject(o) {
return !!o && !/undefined|boolean|string|number/.test(typeof o);
return (o != null && !/^(boolean|string|number)$/.test(typeof o));
}
return function(parent, properties) {
if (!isObject(parent) || !isObject(properties)) {
Expand Down

0 comments on commit cb8325f

Please sign in to comment.