1+ /*
2+ * extend
3+ * Visit http://createjs.com/ for documentation, updates and examples.
4+ *
5+ * Copyright (c) 2010 gskinner.com, inc.
6+ *
7+ * Permission is hereby granted, free of charge, to any person
8+ * obtaining a copy of this software and associated documentation
9+ * files (the "Software"), to deal in the Software without
10+ * restriction, including without limitation the rights to use,
11+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
12+ * copies of the Software, and to permit persons to whom the
13+ * Software is furnished to do so, subject to the following
14+ * conditions:
15+ *
16+ * The above copyright notice and this permission notice shall be
17+ * included in all copies or substantial portions of the Software.
18+ *
19+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
21+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26+ * OTHER DEALINGS IN THE SOFTWARE.
27+ */
28+
29+ /**
30+ * @module CreateJS
31+ */
32+
33+ // namespace:
34+ this . createjs = this . createjs || { } ;
35+
36+ /**
37+ * @class Utility Methods
38+ */
39+
40+ /**
41+ * Wraps deprecated methods so they still be used, but throw warnings to developers.
42+ *
43+ * obj.deprecatedMethod = createjs.deprecate("Old Method Name", obj._fallbackMethod);
44+ *
45+ * The recommended approach for deprecated properties is:
46+ *
47+ * try {
48+ * Obj ect.defineProperties(object, {
49+ * readyOnlyProp: { get: createjs.deprecate("readOnlyProp", function() { return this.alternateProp; }) },
50+ * readWriteProp: {
51+ * get: createjs.deprecate("readOnlyProp", function() { return this.alternateProp; }),
52+ * set: createjs.deprecate("readOnlyProp", function(val) { this.alternateProp = val; })
53+ * });
54+ * } catch (e) {}
55+ *
56+ * @method deprecate
57+ * @param {Function} [fallbackMethod=null] A method to call when the deprecated method is used. See the example for how
58+ * @param {String} [name=null] The name of the method or property to display in the console warning.
59+ * to deprecate properties.
60+ * @return {Function } If a fallbackMethod is supplied, returns a closure that will call the fallback method after
61+ * logging the warning in the console.
62+ */
63+ createjs . deprecate = function ( fallbackMethod , name ) {
64+ "use strict" ;
65+ return function ( ) {
66+ console && ( console . warn || console . log ) ( "Deprecated property or method '" + name + "'. See docs for info." ) ;
67+ return fallbackMethod && fallbackMethod . apply ( this , arguments ) ;
68+ }
69+ } ;
0 commit comments