Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80713 views
1
define(
2
["exports"],
3
function(__exports__) {
4
"use strict";
5
/*jshint -W004 */
6
var escape = {
7
"&": "&",
8
"<": "&lt;",
9
">": "&gt;",
10
'"': "&quot;",
11
"'": "&#x27;",
12
"`": "&#x60;"
13
};
14
15
var badChars = /[&<>"'`]/g;
16
var possible = /[&<>"'`]/;
17
18
function escapeChar(chr) {
19
return escape[chr];
20
}
21
22
function extend(obj /* , ...source */) {
23
for (var i = 1; i < arguments.length; i++) {
24
for (var key in arguments[i]) {
25
if (Object.prototype.hasOwnProperty.call(arguments[i], key)) {
26
obj[key] = arguments[i][key];
27
}
28
}
29
}
30
31
return obj;
32
}
33
34
__exports__.extend = extend;var toString = Object.prototype.toString;
35
__exports__.toString = toString;
36
// Sourced from lodash
37
// https://github.com/bestiejs/lodash/blob/master/LICENSE.txt
38
var isFunction = function(value) {
39
return typeof value === 'function';
40
};
41
// fallback for older versions of Chrome and Safari
42
/* istanbul ignore next */
43
if (isFunction(/x/)) {
44
isFunction = function(value) {
45
return typeof value === 'function' && toString.call(value) === '[object Function]';
46
};
47
}
48
var isFunction;
49
__exports__.isFunction = isFunction;
50
/* istanbul ignore next */
51
var isArray = Array.isArray || function(value) {
52
return (value && typeof value === 'object') ? toString.call(value) === '[object Array]' : false;
53
};
54
__exports__.isArray = isArray;
55
// Older IE versions do not directly support indexOf so we must implement our own, sadly.
56
function indexOf(array, value) {
57
for (var i = 0, len = array.length; i < len; i++) {
58
if (array[i] === value) {
59
return i;
60
}
61
}
62
return -1;
63
}
64
65
__exports__.indexOf = indexOf;
66
function escapeExpression(string) {
67
// don't escape SafeStrings, since they're already safe
68
if (string && string.toHTML) {
69
return string.toHTML();
70
} else if (string == null) {
71
return "";
72
} else if (!string) {
73
return string + '';
74
}
75
76
// Force a string conversion as this will be done by the append regardless and
77
// the regex test will do this transparently behind the scenes, causing issues if
78
// an object's to string has escaped characters in it.
79
string = "" + string;
80
81
if(!possible.test(string)) { return string; }
82
return string.replace(badChars, escapeChar);
83
}
84
85
__exports__.escapeExpression = escapeExpression;function isEmpty(value) {
86
if (!value && value !== 0) {
87
return true;
88
} else if (isArray(value) && value.length === 0) {
89
return true;
90
} else {
91
return false;
92
}
93
}
94
95
__exports__.isEmpty = isEmpty;function blockParams(params, ids) {
96
params.path = ids;
97
return params;
98
}
99
100
__exports__.blockParams = blockParams;function appendContextPath(contextPath, id) {
101
return (contextPath ? contextPath + '.' : '') + id;
102
}
103
104
__exports__.appendContextPath = appendContextPath;
105
});
106