Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80698 views
1
'use strict';
2
3
4
function isNothing(subject) {
5
return (typeof subject === 'undefined') || (null === subject);
6
}
7
8
9
function isObject(subject) {
10
return (typeof subject === 'object') && (null !== subject);
11
}
12
13
14
function toArray(sequence) {
15
if (Array.isArray(sequence)) {
16
return sequence;
17
} else if (isNothing(sequence)) {
18
return [];
19
}
20
return [ sequence ];
21
}
22
23
24
function extend(target, source) {
25
var index, length, key, sourceKeys;
26
27
if (source) {
28
sourceKeys = Object.keys(source);
29
30
for (index = 0, length = sourceKeys.length; index < length; index += 1) {
31
key = sourceKeys[index];
32
target[key] = source[key];
33
}
34
}
35
36
return target;
37
}
38
39
40
function repeat(string, count) {
41
var result = '', cycle;
42
43
for (cycle = 0; cycle < count; cycle += 1) {
44
result += string;
45
}
46
47
return result;
48
}
49
50
51
function isNegativeZero(number) {
52
return (0 === number) && (Number.NEGATIVE_INFINITY === 1 / number);
53
}
54
55
56
module.exports.isNothing = isNothing;
57
module.exports.isObject = isObject;
58
module.exports.toArray = toArray;
59
module.exports.repeat = repeat;
60
module.exports.isNegativeZero = isNegativeZero;
61
module.exports.extend = extend;
62
63