3 * Copyright(c) 2015 Douglas Christopher Wilson
17 * Create deprecate for namespace in caller.
20 function depd(namespace) {
22 throw new TypeError('argument namespace is required')
25 function deprecate(message) {
29 deprecate._file = undefined
30 deprecate._ignored = true
31 deprecate._namespace = namespace
32 deprecate._traced = false
33 deprecate._warned = Object.create(null)
35 deprecate.function = wrapfunction
36 deprecate.property = wrapproperty
42 * Return a wrapped function in a deprecation message.
44 * This is a no-op version of the wrapper, which does nothing but call
48 function wrapfunction(fn, message) {
49 if (typeof fn !== 'function') {
50 throw new TypeError('argument fn must be a function')
57 * Wrap property in a deprecation message.
59 * This is a no-op version of the wrapper, which does nothing but call
63 function wrapproperty(obj, prop, message) {
64 if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) {
65 throw new TypeError('argument obj must be object')
68 var descriptor = Object.getOwnPropertyDescriptor(obj, prop)
71 throw new TypeError('must call property on owner object')
74 if (!descriptor.configurable) {
75 throw new TypeError('property must be configurable')