UNPKG

3.85 kBTypeScriptView Raw
1import type { WrappedFunction } from '@sentry/types';
2/**
3 * Replace a method in an object with a wrapped version of itself.
4 *
5 * @param source An object that contains a method to be wrapped.
6 * @param name The name of the method to be wrapped.
7 * @param replacementFactory A higher-order function that takes the original version of the given method and returns a
8 * wrapped version. Note: The function returned by `replacementFactory` needs to be a non-arrow function, in order to
9 * preserve the correct value of `this`, and the original method must be called using `origMethod.call(this, <other
10 * args>)` or `origMethod.apply(this, [<other args>])` (rather than being called directly), again to preserve `this`.
11 * @returns void
12 */
13export declare function fill(source: {
14 [key: string]: any;
15}, name: string, replacementFactory: (...args: any[]) => any): void;
16/**
17 * Defines a non-enumerable property on the given object.
18 *
19 * @param obj The object on which to set the property
20 * @param name The name of the property to be set
21 * @param value The value to which to set the property
22 */
23export declare function addNonEnumerableProperty(obj: object, name: string, value: unknown): void;
24/**
25 * Remembers the original function on the wrapped function and
26 * patches up the prototype.
27 *
28 * @param wrapped the wrapper function
29 * @param original the original function that gets wrapped
30 */
31export declare function markFunctionWrapped(wrapped: WrappedFunction, original: WrappedFunction): void;
32/**
33 * This extracts the original function if available. See
34 * `markFunctionWrapped` for more information.
35 *
36 * @param func the function to unwrap
37 * @returns the unwrapped version of the function if available.
38 */
39export declare function getOriginalFunction(func: WrappedFunction): WrappedFunction | undefined;
40/**
41 * Encodes given object into url-friendly format
42 *
43 * @param object An object that contains serializable values
44 * @returns string Encoded
45 */
46export declare function urlEncode(object: {
47 [key: string]: any;
48}): string;
49/**
50 * Transforms any `Error` or `Event` into a plain object with all of their enumerable properties, and some of their
51 * non-enumerable properties attached.
52 *
53 * @param value Initial source that we have to transform in order for it to be usable by the serializer
54 * @returns An Event or Error turned into an object - or the value argurment itself, when value is neither an Event nor
55 * an Error.
56 */
57export declare function convertToPlainObject<V>(value: V): {
58 [ownProps: string]: unknown;
59 type: string;
60 target: string;
61 currentTarget: string;
62 detail?: unknown;
63} | {
64 [ownProps: string]: unknown;
65 message: string;
66 name: string;
67 stack?: string;
68} | V;
69/**
70 * Given any captured exception, extract its keys and create a sorted
71 * and truncated list that will be used inside the event message.
72 * eg. `Non-error exception captured with keys: foo, bar, baz`
73 */
74export declare function extractExceptionKeysForMessage(exception: Record<string, unknown>, maxLength?: number): string;
75/**
76 * Given any object, return a new object having removed all fields whose value was `undefined`.
77 * Works recursively on objects and arrays.
78 *
79 * Attention: This function keeps circular references in the returned object.
80 */
81export declare function dropUndefinedKeys<T>(inputValue: T): T;
82/**
83 * Ensure that something is an object.
84 *
85 * Turns `undefined` and `null` into `String`s and all other primitives into instances of their respective wrapper
86 * classes (String, Boolean, Number, etc.). Acts as the identity function on non-primitives.
87 *
88 * @param wat The subject of the objectification
89 * @returns A version of `wat` which can safely be used with `Object` class methods
90 */
91export declare function objectify(wat: unknown): typeof Object;
92//# sourceMappingURL=object.d.ts.map
\No newline at end of file