Skip to content

Commit

Permalink
feat(core)!: Remove arrayify method (#14782)
Browse files Browse the repository at this point in the history
ref: #14268

Deprecation PR:
#14405

Removes `arrayify`. This has no replacement.
  • Loading branch information
AbhiPrasad authored Dec 18, 2024
1 parent 2d4f8e9 commit 43f37df
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 44 deletions.
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

0 comments on commit 43f37df

Please sign in to comment.