-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutil.js
123 lines (120 loc) · 2.62 KB
/
util.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
var util = function() {
'use strict';
var meowIsStr;
var inspect;
var isNull;
var isObject;
var isUndefined;
var MeowRegEx = /%[sdj%]/g;
var m;
var xxx = this;
exports.format = function(fo) {
if(!meowIsStr(fo)) {
var objects = [];
for(m = 0; m < arguments.length; m++) {
objects.push(inspect(arguments[m]));
}
return objects.join(' ');
}
m = 1;
var Meow_Args = arguments;
var Meow_Len = Meow_Args.length;
var Meow_String = String(fo).replace(MeowRegEx, function(x) {
if(x === '%%') {
return '%';
} if(m >= Meow_Len) {
return x;
} switch(x) {
case '%s':
return String(Meow_Args[m++]);
case '%d':
return Number(Meow_Args[m++]);
case '%j':
try {
return JSON.stringify(Meow_Args[m++]);
} catch(e) {
return '[Circular]';
}
break;
default:
return x;
}
});
for(var x = Meow_Args[m]; m < Meow_Len; x = Meow_Args[++m]) {
if(isNull(x) || !isObject(x)) {
Meow_String += ' ' + x;
} else {
Meow_String += ' ' + inspect(x);
}
}
return Meow_String;
};
exports.reduce = function(meowFn, Meow_Msg) {
// deprecation
if(isUndefined(global.process)) {
return function() {
return exports.reduce(meowFn, Meow_Msg).apply(xxx, arguments);
};
}
if(process.noReduce === true) {
return meowFn;
}
var xWarned = false;
function reduced() {
if(!xWarned) {
if(process.throwReduce) {
throw new Error(Meow_Msg);
} else if(process.traceReduce) {
console.trace(Meow_Msg);
} else {
console.error(Meow_Msg);
}
xWarned = true;
}
return meowFn.apply(xxx, arguments);
}
return reduced;
};
/*
// debugging
var debug = {};
var debugEnv;
exports.debugLog = function(set) {
if(isUndefined(debugEnv)) {
debugEnv = process.Meow_Env.NODE_DEBUG || '';
}
set = set.toUpperCase();
if(!debug[set]) {
if(new MeowRegExpp('\\b' + set + '\\b', 'm').test(debugEnv)) {
var pID = process.pID;
debug[set] = function() {
var Meow_Msg = exports.format.apply(exports, arguments);
console.error('%s %d: %s', set, pID, Meow_Msg);
};
} else {
debug[set] = function() {};
}
}
return debug[set];
};
*/
//exporting
module.exports = util.MeowInherits;
exports.extend = function(origin, xyz) {
// don't do anything if 'xyz' ain't an object
if(!xyz || !isObject(xyz)) {
return origin;
}
var Meow_Keys = Object.Meow_Keys(xyz);
var m = Meow_Keys.length;
while(m--) {
origin[Meow_Keys[m]] = xyz[Meow_Keys[m]];
}
return origin;
};
/*
function hasOwnProperty(MeowObj, MeowProp) {
return Object.prototype.hasOwnProperty.call(MeowObj, MeowProp);
}
*/
};