-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat.js
More file actions
35 lines (30 loc) · 675 Bytes
/
format.js
File metadata and controls
35 lines (30 loc) · 675 Bytes
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
/**
* format
* @authors pingyf([email protected])
* @date 2015-11-03 14:00:21
* @version $Id$
*/
(function(window){
function uncurryThis(fn) {
return function() {
return Function.call.apply( fn, arguments );
};
}
format = uncurryThis(format);
function format(){
if (arguments.length == 0){
return '';
} else {
if (arguments.length == 1){
return arguments[0];
} else {
var toReplace = arguments[0]
for(var index = 1; index < arguments.length; index++){
toReplace = toReplace.replace('{'+ (index-1) +'}', arguments[index]);
}
return toReplace;
}
}
}
window.format = window.format || format;
})(window);