-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib_instance.js.html
194 lines (169 loc) · 5.94 KB
/
lib_instance.js.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>lib/instance.js - mitsubishi</title>
<link rel="stylesheet" href="http://yui.yahooapis.com/3.9.1/build/cssgrids/cssgrids-min.css">
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
<link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
<link rel="shortcut icon" type="image/png" href="../assets/favicon.png">
<script src="http://yui.yahooapis.com/combo?3.9.1/build/yui/yui-min.js"></script>
</head>
<body class="yui3-skin-sam">
<div id="doc">
<div id="hd" class="yui3-g header">
<div class="yui3-u-3-4">
<h1><img src="../assets/css/logo.png" title="mitsubishi"></h1>
</div>
<div class="yui3-u-1-4 version">
<em>API Docs for: 0.0.6</em>
</div>
</div>
<div id="bd" class="yui3-g">
<div class="yui3-u-1-4">
<div id="docs-sidebar" class="sidebar apidocs">
<div id="api-list">
<h2 class="off-left">APIs</h2>
<div id="api-tabview" class="tabview">
<ul class="tabs">
<li><a href="#api-classes">Classes</a></li>
<li><a href="#api-modules">Modules</a></li>
</ul>
<div id="api-tabview-filter">
<input type="search" id="api-filter" placeholder="Type to filter APIs">
</div>
<div id="api-tabview-panel">
<ul id="api-classes" class="apis classes">
<li><a href="../classes/mitsubishi.html">mitsubishi</a></li>
<li><a href="../classes/mixinInstance.html">mixinInstance</a></li>
<li><a href="../classes/mixinProto.html">mixinProto</a></li>
</ul>
<ul id="api-modules" class="apis modules">
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="yui3-u-3-4">
<div id="api-options">
Show:
<label for="api-show-inherited">
<input type="checkbox" id="api-show-inherited" checked>
Inherited
</label>
<label for="api-show-protected">
<input type="checkbox" id="api-show-protected">
Protected
</label>
<label for="api-show-private">
<input type="checkbox" id="api-show-private">
Private
</label>
<label for="api-show-deprecated">
<input type="checkbox" id="api-show-deprecated">
Deprecated
</label>
</div>
<div class="apidocs">
<div id="docs-main">
<div class="content">
<h1 class="file-heading">File: lib/instance.js</h1>
<div class="file">
<pre class="code prettyprint linenums">
/**
* Check class is static (ie object literal vs constructor fn obj)
*
* @method validObjectLiteral
*
* @param {Object} item the class/js object to check
*
* @return {Object} boolean
*/
var validObjectLiteral = function (item) {
return (item && item.constructor === Object.prototype.constructor);
};
/**
* copy hasOwn properties from one class to another
*
* @method hasOwnPropsMixin
*
* @param {Object} child the object that you want to gain the extra properties
* @param {Object} parent the object that has the properties to give
*
* @return {Object} the decorated child
*/
var hasOwnPropsMixin = function (child, parent) {
var __hasProp = {}.hasOwnProperty;
// copy instance properties from parent to child
for (var key in parent) {
if (__hasProp.call(parent, key)) {
child[key] = parent[key];
}
}
return child;
};
/**
* Mix in INSTANCE properties from one class to another class (accepts both dynamic and static classes). Will mix in prototype properties if a dynamic class is passed in.
*
* @method instanceSingle
*
* @param {Class} childClass the child class (dynamic or static) to be decorated
* @param {Class} parentClass the parent class (dynamic or static) that has the properties to be mixed in to the child
*
* @return {Class} the decorated child class
*/
var instanceSingle = function (childClass, parentClass) {
return hasOwnPropsMixin(childClass, parentClass);
// childClass = hasOwnPropsMixin(childClass, parentClass);
// return validObjectLiteral(staticProps) ? hasOwnPropsMixin(childClass, staticProps) : childClass;
};
/**
* Mix in INSTANCE properties from array of parent classes to a child class. Basically just a for loop around mitsubshi.instanceSingle().
*
* @method instanceMulti
*
* @param {Class} child class that will be decorated
* @param {Array} arrayParents array of parent classes (can be static or dynamic) that will be giving their properties to the new static class
*
* @return {Object} decorated child static class
*/
var instanceMulti = function(childClass, arrayParents) {
for (var i = arrayParents.length - 1; i >= 0; i--) {
instanceSingle(childClass, arrayParents[i]);
}
return childClass;
};
/**
* mix in instance properties from classes
*
* @class mixinInstance
* @static
*/
var mixinInstance = {
"validObjectLiteral": validObjectLiteral,
"hasOwnPropsMixin": hasOwnPropsMixin,
"instanceSingle": instanceSingle,
"instanceMulti": instanceMulti
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = mixinInstance;
}
</pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="../assets/vendor/prettify/prettify-min.js"></script>
<script>prettyPrint();</script>
<script src="../assets/js/yui-prettify.js"></script>
<script src="../assets/../api.js"></script>
<script src="../assets/js/api-filter.js"></script>
<script src="../assets/js/api-list.js"></script>
<script src="../assets/js/api-search.js"></script>
<script src="../assets/js/apidocs.js"></script>
</body>
</html>