-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgeneric.js
210 lines (165 loc) · 5.67 KB
/
generic.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
function equals(obj1, obj2){
if((obj1 == null || typeof obj1 != 'object') || (obj2 == null || typeof obj2 != 'object')){
return obj1 == obj2;
}
for(var propName in obj1){
if(obj1.hasOwnProperty(propName) != obj2.hasOwnProperty(propName)){
return false;
}else if(typeof obj1[propName] != typeof obj2[propName]){
return false;
}
}
for(var propName in obj2){
var val = obj1[propName];
var other = obj2[propName];
if(obj1.hasOwnProperty(propName) != obj2.hasOwnProperty(propName)){
return false;
}else if(typeof val != typeof other){
return false;
}
if(!obj1.hasOwnProperty(propName)){
continue;
}
if(!equals(val, other)){
return false;
}
}
return true;
};
module.exports = equals;
},{}],2:[function(require,module,exports){
function isBlank(x){
var val = true;
var length = x['length'];
if(length || length == 0){
val = length == 0;
}else if(x == true || typeof x == 'number'){
val = false;
}else if(x){
val = Object.keys(x).length == 0;
}
return val;
};
module.exports = isBlank;
},{}],3:[function(require,module,exports){
function simpleType(x){
var val = typeof x;
if(val == 'number'){
val = 'Number';
}else if(val == 'string'){
val = 'String';
}else if(val == 'boolean'){
val = 'Boolean';
}else if(!!(x && x.constructor && x.call && x.apply)){
val = 'Function';
}else if(x != null && val == 'object'){
val = Array.isArray(x) ? 'Array' : 'Object';
}
return val;
}
module.exports = simpleType;
},{}],4:[function(require,module,exports){
function warn(type, method, notPrototype){
if(type && method){
console.warn("Rearmed-js Overriding " + type + (notPrototype ? '.' : '.prototype.') + method, '. If this is a built-in browser method please report on Rearmed-js github issues.');
}else{
throw("incorrect number of arguments")
}
};
module.exports = warn;
},{}],5:[function(require,module,exports){
require('./generic/equals');
require('./generic/isBlank');
require('./generic/isPresent');
require('./generic/presence');
require('./generic/simpleType');
require('./generic/try');
},{"./generic/equals":6,"./generic/isBlank":7,"./generic/isPresent":8,"./generic/presence":9,"./generic/simpleType":10,"./generic/try":11}],6:[function(require,module,exports){
(function(){
"use strict";
var warn = require('./../functions/warn');
var equals = require('./../functions/equals');
if(Object.prototype.equals){
warn('Object', 'equals');
}
Object.prototype.equals = function(x){
return equals(this, x);
};
Object.defineProperty(Object.prototype, "equals", {enumerable: false});
}(this));
},{"./../functions/equals":1,"./../functions/warn":4}],7:[function(require,module,exports){
(function(){
"use strict";
var warn = require('./../functions/warn');
var isBlank = require('./../functions/isBlank');
if(Object.prototype.isBlank){
warn('Object', 'isBlank');
}
Object.prototype.isBlank = function(){
return isBlank(this);
};
Object.defineProperty(Object.prototype, "isBlank", {enumerable: false});
}(this));
},{"./../functions/isBlank":2,"./../functions/warn":4}],8:[function(require,module,exports){
(function(){
"use strict";
var warn = require('./../functions/warn');
var isBlank = require('./../functions/isBlank');
if(Object.prototype.isPresent){
warn('Object', 'isPresent');
}
Object.prototype.isPresent = function(){
return !isBlank(this);
};
Object.defineProperty(Object.prototype, "isPresent", {enumerable: false});
}(this));
},{"./../functions/isBlank":2,"./../functions/warn":4}],9:[function(require,module,exports){
(function(){
"use strict";
var warn = require('./../functions/warn');
var isBlank = require('./../functions/isBlank');
if(Object.prototype.presence){
warn('Object', 'presence');
}
Object.prototype.presence = function(){
return !isBlank(this) ? this : false;
};
Object.defineProperty(Object.prototype, "presence", {enumerable: false});
}(this));
},{"./../functions/isBlank":2,"./../functions/warn":4}],10:[function(require,module,exports){
(function(){
"use strict";
var warn = require('./../functions/warn');
var simpleType = require('./../functions/simpleType');
if(Object.prototype.simpleType){
warn('Object', 'simpleType');
}
Object.prototype.simpleType = function(){
return simpleType(this);
};
Object.defineProperty(Object.prototype, "simpleType", {enumerable: false});
}(this));
},{"./../functions/simpleType":3,"./../functions/warn":4}],11:[function(require,module,exports){
(function(){
"use strict";
if(!Object.prototype.try){
var simpleType = require('./../functions/simpleType');
Object.prototype.try = function(x){
var val = this[x];
if(val || val === 0 || val === ''){
if(simpleType(val) === 'Function'){
if(arguments.length > 1){
var args = Array.prototype.slice.call(arguments);
args.shift();
}
val = val.apply(this, args);
}
return (val || val === 0 || val === '') ? val : false;
}
return false;
};
Object.defineProperty(Object.prototype, "try", {enumerable: false});
}
}(this));
},{"./../functions/simpleType":3}]},{},[5]);