Skip to content

Commit

Permalink
Merge pull request #19103 from dartess/remove-stable
Browse files Browse the repository at this point in the history
Remove deprecated `stable` dependency
  • Loading branch information
shilman authored Sep 5, 2022
2 parents d5bce2c + 78484c3 commit 9546989
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 12 deletions.
3 changes: 2 additions & 1 deletion code/lib/addons/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ export type IndexEntry = StoryIndexEntry | DocsIndexEntry;

// The `any` here is the story store's `StoreItem` record. Ideally we should probably only
// pass a defined subset of that full data, but we pass it all so far :shrug:
export type StorySortComparator = Comparator<[StoryId, any, Parameters, Parameters]>;
export type IndexEntryLegacy = [StoryId, any, Parameters, Parameters];
export type StorySortComparator = Comparator<IndexEntryLegacy>;
export type StorySortParameter = StorySortComparator | StorySortObjectParameter;
export type StorySortComparatorV7 = Comparator<IndexEntry>;
export type StorySortParameterV7 = StorySortComparatorV7 | StorySortObjectParameter;
Expand Down
1 change: 0 additions & 1 deletion code/lib/builder-vite/src/optimizeDeps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ const INCLUDE_CANDIDATES = [
'refractor/lang/yaml.js',
'regenerator-runtime/runtime.js',
'slash',
'stable',
'store2',
'synchronous-promise',
'telejson',
Expand Down
1 change: 0 additions & 1 deletion code/lib/builder-webpack5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
"html-webpack-plugin": "^5.5.0",
"path-browserify": "^1.0.1",
"process": "^0.11.10",
"stable": "^0.1.8",
"style-loader": "^3.3.1",
"terser-webpack-plugin": "^5.3.1",
"ts-dedent": "^2.0.0",
Expand Down
1 change: 0 additions & 1 deletion code/lib/store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"lodash": "^4.17.21",
"memoizerific": "^1.11.3",
"slash": "^3.0.0",
"stable": "^0.1.8",
"synchronous-promise": "^2.0.15",
"ts-dedent": "^2.0.0",
"util-deprecate": "^1.0.2"
Expand Down
15 changes: 9 additions & 6 deletions code/lib/store/src/sortStories.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import stable from 'stable';
import { dedent } from 'ts-dedent';
import type { Comparator, StorySortParameter, StorySortParameterV7 } from '@storybook/addons';
import type {
Comparator,
IndexEntryLegacy,
StorySortParameter,
StorySortParameterV7,
} from '@storybook/addons';
import { storySort } from './storySort';
import type { Story, StoryIndexEntry, IndexEntry, Path, Parameters } from './types';

Expand All @@ -16,10 +20,9 @@ const sortStoriesCommon = (
} else {
sortFn = storySort(storySortParameter);
}
stable.inplace(stories, sortFn);
stories.sort(sortFn as (a: IndexEntry, b: IndexEntry) => number);
} else {
stable.inplace(
stories,
stories.sort(
(s1, s2) => fileNameOrder.indexOf(s1.importPath) - fileNameOrder.indexOf(s2.importPath)
);
}
Expand Down Expand Up @@ -57,7 +60,7 @@ export const sortStoriesV6 = (
fileNameOrder: Path[]
) => {
if (storySortParameter && typeof storySortParameter === 'function') {
stable.inplace(stories, storySortParameter);
stories.sort(storySortParameter as (a: IndexEntryLegacy, b: IndexEntryLegacy) => number);
return stories.map((s) => toIndexEntry(s[1]));
}

Expand Down
2 changes: 0 additions & 2 deletions code/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7758,7 +7758,6 @@ __metadata:
html-webpack-plugin: ^5.5.0
path-browserify: ^1.0.1
process: ^0.11.10
stable: ^0.1.8
style-loader: ^3.3.1
terser-webpack-plugin: ^5.3.1
ts-dedent: ^2.0.0
Expand Down Expand Up @@ -9381,7 +9380,6 @@ __metadata:
lodash: ^4.17.21
memoizerific: ^1.11.3
slash: ^3.0.0
stable: ^0.1.8
synchronous-promise: ^2.0.15
ts-dedent: ^2.0.0
typescript: ~4.6.3
Expand Down

0 comments on commit 9546989

Please sign in to comment.