UNPKG

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