6 module.exports = deprecate;
9 * Mark that a method should not be used.
10 * Returns a modified function which warns once by default.
12 * If `localStorage.noDeprecation = true` is set, then it is a no-op.
14 * If `localStorage.throwDeprecation = true` is set, then deprecated functions
15 * will throw an Error when invoked.
17 * If `localStorage.traceDeprecation = true` is set, then deprecated functions
18 * will invoke `console.trace()` instead of `console.error()`.
20 * @param {Function} fn - the function to deprecate
21 * @param {String} msg - the string to print to the console when `fn` is invoked
22 * @returns {Function} a new "deprecated" version of `fn`
26 function deprecate (fn, msg) {
27 if (config('noDeprecation')) {
32 function deprecated() {
34 if (config('throwDeprecation')) {
36 } else if (config('traceDeprecation')) {
43 return fn.apply(this, arguments);
50 * Checks `localStorage` for boolean values for the given `name`.
52 * @param {String} name
57 function config (name) {
58 // accessing global.localStorage can trigger a DOMException in sandboxed iframes
60 if (!global.localStorage) return false;
64 var val = global.localStorage[name];
65 if (null == val) return false;
66 return String(val).toLowerCase() === 'true';