typescript(option): refactor: now using @thi.ng/compose
Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
parent
0abd53917b
commit
0ef7baa739
|
@ -38,6 +38,7 @@
|
|||
"author": "Matei Adriel",
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"dependencies": {
|
||||
"@thi.ng/compose": "^1.3.6",
|
||||
"tslib": "^1.10.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
dependencies:
|
||||
'@thi.ng/compose': 1.3.6
|
||||
tslib: 1.10.0
|
||||
devDependencies:
|
||||
'@rollup/plugin-commonjs': 11.0.0_rollup@1.27.14
|
||||
|
@ -953,6 +954,21 @@ packages:
|
|||
semantic-release: '>=15.8.0 <16.0.0 || >=16.0.0-beta <17.0.0'
|
||||
resolution:
|
||||
integrity: sha512-LGjgPBGjjmjap/76O0Md3wc04Y7IlLnzZceLsAkcYRwGQdRPTTFUJKqDQTuieWTs7zfHzQoZqsqPfFxEN+g2+Q==
|
||||
/@thi.ng/api/6.6.0:
|
||||
dev: false
|
||||
resolution:
|
||||
integrity: sha512-CG4jxoidxdTNAVdGEGj9nLwOts37BszTWSl3RejFL/K2yOxEkB77c0zfvz19sSZVfUWv5dDWgXewbYwBnHvKlA==
|
||||
/@thi.ng/compose/1.3.6:
|
||||
dependencies:
|
||||
'@thi.ng/api': 6.6.0
|
||||
'@thi.ng/errors': 1.2.2
|
||||
dev: false
|
||||
resolution:
|
||||
integrity: sha512-anCFAQqnfOjPXGkkAptJE9gMBtD4jMJc/2sETLl09M3BUMCj3i6We1tCJ9ljcoXwO+jgscTAaMOopiOwslO0SA==
|
||||
/@thi.ng/errors/1.2.2:
|
||||
dev: false
|
||||
resolution:
|
||||
integrity: sha512-M0T8m+H+FDAFi6Oe8FTYQWTBgx+xrwsstiH4KzSUGjDGmJ7Hi/FSfwmBPIslrRVnrnJKwBk41aYQ1tk3J6CNKw==
|
||||
/@types/color-name/1.1.1:
|
||||
dev: true
|
||||
resolution:
|
||||
|
@ -3631,6 +3647,7 @@ packages:
|
|||
specifiers:
|
||||
'@rollup/plugin-commonjs': ^11.0.0
|
||||
'@rollup/plugin-node-resolve': ^6.0.0
|
||||
'@thi.ng/compose': ^1.3.6
|
||||
'@types/node': ^12.12.21
|
||||
'@wessberg/rollup-plugin-ts': ^1.1.83
|
||||
rimraf: ^3.0.0
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Option } from '../types'
|
||||
import { isSome } from './isSome'
|
||||
import { compL } from '@thi.ng/compose'
|
||||
|
||||
export const count = <T>(option: Option<T>) => Number(isSome(option))
|
||||
export const count = compL(isSome, Number)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { bind } from './bind'
|
||||
import { identity } from '../internals'
|
||||
import { identity } from '@thi.ng/compose'
|
||||
import { Option } from '../types'
|
||||
|
||||
export const flat = <T>(option: Option<Option<T>>): Option<T> => {
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import { match } from './match'
|
||||
import { Mapper } from '../internalTypes'
|
||||
import { Option, Some, None } from '../types'
|
||||
import { compL } from '@thi.ng/compose'
|
||||
|
||||
export const map = <T, U>(
|
||||
mapper: Mapper<T, U>,
|
||||
option: Option<T>
|
||||
): Option<U> => {
|
||||
return match(v => Some(mapper(v)), None, option)
|
||||
return match(compL(mapper, Some), None, option)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { match } from './match'
|
||||
import { identity } from '../internals'
|
||||
import { identity } from '@thi.ng/compose'
|
||||
import { Option } from '../types'
|
||||
|
||||
export const toNullable = <T>(option: Option<T>) => {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { match } from './match'
|
||||
import { identity } from '../internals'
|
||||
import { identity } from '@thi.ng/compose'
|
||||
import { Option } from '../types'
|
||||
|
||||
export const withDefault = <T>(_default: T, option: Option<T>) => {
|
||||
|
|
|
@ -1,3 +1 @@
|
|||
export const identity = <T>(v: T) => v
|
||||
|
||||
export const none = Symbol('none')
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { none, identity } from './internals'
|
||||
import { identity } from '@thi.ng/compose'
|
||||
import { Brand } from 'utility-types'
|
||||
import { none } from './internals'
|
||||
|
||||
// This is never actually used outside of typing so we can just declare it
|
||||
declare const some: unique symbol
|
||||
|
|
Loading…
Reference in a new issue