Skip to content

Commit

Permalink
refactor(common): move maybe out of common/utils
Browse files Browse the repository at this point in the history
  • Loading branch information
exuanbo committed Dec 5, 2023
1 parent f177357 commit b775b9a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { just, maybeNullable, nothing } from '@/common/utils'
import { just, maybeNullable, nothing } from '@/common/maybe'

describe('Maybe', () => {
describe('maybeNullable', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/common/utils/maybe.ts → src/common/maybe.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { Nullable } from './types'
import type { Nullable } from './utils/types'

export interface Maybe<T extends {}> {
isJust: () => boolean
isNothing: () => boolean
map: <U extends {}>(f: (value: T) => U) => Maybe<U>
chain: <U extends {}>(f: (value: T) => Maybe<U>) => Maybe<U>
orDefault: (defaultValue: T) => T
orDefault: <U>(defaultValue: U) => T | U
extract: () => T | undefined
extractNullable: () => T | null
ifJust: (f: (value: T) => void) => this
Expand Down
3 changes: 1 addition & 2 deletions src/common/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export { classNames } from './classNames'
export * from './classNames'
export * from './common'
export * from './maybe'
export * from './merge'
export * from './types'
2 changes: 1 addition & 1 deletion src/features/editor/codemirror/highlightLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { type Extension, StateEffect, StateField } from '@codemirror/state'
import { Decoration, type DecorationSet, EditorView } from '@codemirror/view'
import { filterEffects, mapEffectValue, reduceRangeSet } from '@codemirror-toolkit/utils'

import { maybeNullable } from '@/common/utils'
import { maybeNullable } from '@/common/maybe'

import { ClassName } from './classNames'
import type { RangeSetUpdateFilter } from './rangeSet'
Expand Down
2 changes: 1 addition & 1 deletion src/features/editor/codemirror/wavyUnderline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { type Extension, StateEffect, StateField } from '@codemirror/state'
import { Decoration, type DecorationSet, EditorView } from '@codemirror/view'
import { filterEffects, mapEffectValue } from '@codemirror-toolkit/utils'

import { maybeNullable } from '@/common/utils'
import { maybeNullable } from '@/common/maybe'

import { ClassName } from './classNames'
import type { RangeSetUpdateFilter } from './rangeSet'
Expand Down

0 comments on commit b775b9a

Please sign in to comment.