source: imaps-frontend/node_modules/js-yaml/lib/common.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.1 KB
RevLine 
[d565449]1'use strict';
2
3
4function isNothing(subject) {
5 return (typeof subject === 'undefined') || (subject === null);
6}
7
8
9function isObject(subject) {
10 return (typeof subject === 'object') && (subject !== null);
11}
12
13
14function toArray(sequence) {
15 if (Array.isArray(sequence)) return sequence;
16 else if (isNothing(sequence)) return [];
17
18 return [ sequence ];
19}
20
21
22function extend(target, source) {
23 var index, length, key, sourceKeys;
24
25 if (source) {
26 sourceKeys = Object.keys(source);
27
28 for (index = 0, length = sourceKeys.length; index < length; index += 1) {
29 key = sourceKeys[index];
30 target[key] = source[key];
31 }
32 }
33
34 return target;
35}
36
37
38function repeat(string, count) {
39 var result = '', cycle;
40
41 for (cycle = 0; cycle < count; cycle += 1) {
42 result += string;
43 }
44
45 return result;
46}
47
48
49function isNegativeZero(number) {
50 return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number);
51}
52
53
54module.exports.isNothing = isNothing;
55module.exports.isObject = isObject;
56module.exports.toArray = toArray;
57module.exports.repeat = repeat;
58module.exports.isNegativeZero = isNegativeZero;
59module.exports.extend = extend;
Note: See TracBrowser for help on using the repository browser.