| | |
| | | const deprecationCache = new Map(); |
| | | |
| | | /** |
| | | * Defines the fake hook marker type used by this module. |
| | | * @typedef {object} FakeHookMarker |
| | | * @property {true} _fakeHook it's a fake hook |
| | | */ |
| | | |
| | | /** |
| | | * Defines the shared type used by this module. |
| | | * @template T |
| | | * @typedef {T & FakeHookMarker} FakeHook<T> |
| | | */ |
| | | |
| | | /** |
| | | * Creates a deprecation. |
| | | * @param {string} message deprecation message |
| | | * @param {string} code deprecation code |
| | | * @returns {() => void} function to trigger deprecation |
| | |
| | | ]; |
| | | |
| | | /** |
| | | * Defines the set with deprecated array methods type used by this module. |
| | | * @template T |
| | | * @typedef {Set<T> & { [Symbol.isConcatSpreadable]: boolean } & { push: (...items: T[]) => void, length?: number } & { [P in DISABLED_METHODS_NAMES]: () => void } & { [P in COPY_METHODS_NAMES]: P extends keyof Array<T> ? () => Pick<Array<T>, P> : never }} SetWithDeprecatedArrayMethods |
| | | */ |
| | | |
| | | /** |
| | | * Processes the provided set. |
| | | * @template T |
| | | * @param {Set<T>} set new set |
| | | * @param {string} name property name |
| | |
| | | }; |
| | | } |
| | | /** |
| | | * Creates an index getter. |
| | | * @param {number} index index |
| | | * @returns {() => T | undefined} value |
| | | */ |
| | | const createIndexGetter = (index) => { |
| | | /** |
| | | * Returns the value at this location. |
| | | * @this {Set<T>} a Set |
| | | * @returns {T | undefined} the value at this location |
| | | */ |
| | |
| | | return fn; |
| | | }; |
| | | /** |
| | | * Define index getter. |
| | | * @param {number} index index |
| | | */ |
| | | const defineIndexGetter = (index) => { |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Returns } SetDeprecatedArray. |
| | | * @template T |
| | | * @param {string} name name |
| | | * @returns {{ new <T = any>(values?: ReadonlyArray<T> | null): SetDeprecatedArray<T> }} SetDeprecatedArray |
| | | * @returns {{ new <T = EXPECTED_ANY>(values?: ReadonlyArray<T> | null): SetDeprecatedArray<T> }} SetDeprecatedArray |
| | | */ |
| | | module.exports.createArrayToSetDeprecationSet = (name) => { |
| | | let initialized = false; |
| | | |
| | | /** |
| | | * Represents SetDeprecatedArray. |
| | | * @template T |
| | | */ |
| | | class SetDeprecatedArray extends Set { |
| | | /** |
| | | * Creates an instance of SetDeprecatedArray. |
| | | * @param {ReadonlyArray<T> | null=} items items |
| | | */ |
| | | constructor(items) { |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Returns fake hook which redirects. |
| | | * @template {object} T |
| | | * @param {T} fakeHook fake hook implementation |
| | | * @param {string=} message deprecation message (not deprecated when unset) |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Deprecate all properties. |
| | | * @template T |
| | | * @param {T} obj object |
| | | * @param {string} message deprecation message |
| | |
| | | set: descriptor.writable |
| | | ? util.deprecate( |
| | | /** |
| | | * Handles the callback logic for this hook. |
| | | * @template T |
| | | * @param {T} v value |
| | | * @returns {T} result |
| | |
| | | module.exports.deprecateAllProperties = deprecateAllProperties; |
| | | |
| | | /** |
| | | * Returns frozen object with deprecation when modifying. |
| | | * @template {object} T |
| | | * @param {T} obj object |
| | | * @param {string} name property name |
| | |
| | | new Proxy(obj, { |
| | | set: util.deprecate( |
| | | /** |
| | | * Handles the callback logic for this hook. |
| | | * @param {object} target target |
| | | * @param {string | symbol} property property |
| | | * @param {EXPECTED_ANY} value value |
| | |
| | | ), |
| | | defineProperty: util.deprecate( |
| | | /** |
| | | * Handles the define property callback for this hook. |
| | | * @param {object} target target |
| | | * @param {string | symbol} property property |
| | | * @param {PropertyDescriptor} descriptor descriptor |
| | |
| | | ), |
| | | deleteProperty: util.deprecate( |
| | | /** |
| | | * Handles the delete property callback for this hook. |
| | | * @param {object} target target |
| | | * @param {string | symbol} property property |
| | | * @returns {boolean} result |
| | |
| | | ), |
| | | setPrototypeOf: util.deprecate( |
| | | /** |
| | | * Updates prototype of using the provided target. |
| | | * @param {object} target target |
| | | * @param {EXPECTED_OBJECT | null} proto proto |
| | | * @returns {boolean} result |