Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core)!: Remove arrayify method #14782

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/migration/v8-to-v9.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ It will be removed in a future major version.

- The `getNumberOfUrlSegments` method has been removed. There is no replacement.
- The `validSeverityLevels` export has been removed. There is no replacement.
- The `arrayify` export has been removed. There is no replacement.

### `@sentry/nestjs`

Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/utils-hoist/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ export {
addContextToFrame,
addExceptionMechanism,
addExceptionTypeValue,
// eslint-disable-next-line deprecation/deprecation
arrayify,
checkOrSetAlreadyCaught,
getEventDescription,
parseSemver,
Expand Down
12 changes: 0 additions & 12 deletions packages/core/src/utils-hoist/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,3 @@ function isAlreadyCaptured(exception: unknown): boolean | void {
return (exception as { __sentry_captured__?: boolean }).__sentry_captured__;
} catch {} // eslint-disable-line no-empty
}

/**
* Checks whether the given input is already an array, and if it isn't, wraps it in one.
*
* @param maybeArray Input to turn into an array, if necessary
* @returns The input, if already an array, or an array with the input as the only element, if not
*
* @deprecated This function has been deprecated and will not be replaced.
*/
export function arrayify<T = unknown>(maybeArray: T | T[]): T[] {
return Array.isArray(maybeArray) ? maybeArray : [maybeArray];
}
25 changes: 0 additions & 25 deletions packages/core/test/utils-hoist/misc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { Event, Mechanism, StackFrame } from '../../src/types-hoist';
import {
addContextToFrame,
addExceptionMechanism,
arrayify,
checkOrSetAlreadyCaught,
getEventDescription,
uuid4,
Expand Down Expand Up @@ -363,27 +362,3 @@ describe('uuid4 generation', () => {
}
});
});

describe('arrayify()', () => {
it('returns arrays untouched', () => {
// eslint-disable-next-line deprecation/deprecation
expect(arrayify([])).toEqual([]);
// eslint-disable-next-line deprecation/deprecation
expect(arrayify(['dogs', 'are', 'great'])).toEqual(['dogs', 'are', 'great']);
});

it('wraps non-arrays with an array', () => {
// eslint-disable-next-line deprecation/deprecation
expect(arrayify(1231)).toEqual([1231]);
// eslint-disable-next-line deprecation/deprecation
expect(arrayify('dogs are great')).toEqual(['dogs are great']);
// eslint-disable-next-line deprecation/deprecation
expect(arrayify(true)).toEqual([true]);
// eslint-disable-next-line deprecation/deprecation
expect(arrayify({})).toEqual([{}]);
// eslint-disable-next-line deprecation/deprecation
expect(arrayify(null)).toEqual([null]);
// eslint-disable-next-line deprecation/deprecation
expect(arrayify(undefined)).toEqual([undefined]);
});
});
5 changes: 0 additions & 5 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {
addNormalizedRequestDataToEvent as addNormalizedRequestDataToEvent_imported,
addRequestDataToEvent as addRequestDataToEvent_imported,
applyAggregateErrorsToEvent as applyAggregateErrorsToEvent_imported,
arrayify as arrayify_imported,
baggageHeaderToDynamicSamplingContext as baggageHeaderToDynamicSamplingContext_imported,
basename as basename_imported,
browserPerformanceTimeOrigin as browserPerformanceTimeOrigin_imported,
Expand Down Expand Up @@ -608,10 +607,6 @@ export const flatten = flatten_imported;
// eslint-disable-next-line deprecation/deprecation
export const memoBuilder = memoBuilder_imported;

/** @deprecated Import from `@sentry/core` instead. */
// eslint-disable-next-line deprecation/deprecation
export const arrayify = arrayify_imported;

/** @deprecated Import from `@sentry/core` instead. */
export const normalizeUrlToBase = normalizeUrlToBase_imported;

Expand Down
Loading