-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfnc.js
58 lines (45 loc) · 1.22 KB
/
fnc.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
/*
var fnc = require('./fnc');
fnc.log('Hello!')
*/
module.exports = {
log: function ( msg ) {
var errorMsg = "\n---\n";
errorMsg += msg + "\n";
errorMsg += "\n---\n";
console.log( msg );
},
checkTemplate: function(template) {
// Check template exists
if (typeof template === 'undefined') {
var errorMsg = "\n---\n";
errorMsg += "Missing layout: '" + layout + "'\n";
if ( typeof layout === 'object' ) {
errorMsg = errorMsg + "Did you miss the quote marks?";
}
errorMsg += "\n---\n";
throw new Error(errorMsg);
}
},
merge: function(target, source) {
/* Merges two (or more) objects,
giving the last one precedence */
if ( typeof target !== 'object' ) {
target = {};
}
for (var property in source) {
if ( source.hasOwnProperty(property) ) {
var sourceProperty = source[ property ];
if ( typeof sourceProperty === 'object' ) {
target[ property ] = util.merge( target[ property ], sourceProperty );
continue;
}
target[ property ] = sourceProperty;
}
}
for (var a = 2, l = arguments.length; a < l; a++) {
merge(target, arguments[a]);
}
return target;
},
};