Unify Derivation and Prism 4/n
This commit is contained in:
parent
06808f99e9
commit
a38d96ec95
10 changed files with 26 additions and 26 deletions
|
@ -266,7 +266,7 @@ const identityDerivationWeakMap = new WeakMap<{}, Prism<unknown>>()
|
|||
*
|
||||
* @param pointer - The pointer to return the derivation at.
|
||||
*/
|
||||
export const valueDerivation = <P extends PointerType<$IntentionalAny>>(
|
||||
export const pointerToPrism = <P extends PointerType<$IntentionalAny>>(
|
||||
pointer: P,
|
||||
): Prism<P extends PointerType<infer T> ? T : void> => {
|
||||
const meta = getPointerMeta(pointer)
|
||||
|
@ -276,7 +276,7 @@ export const valueDerivation = <P extends PointerType<$IntentionalAny>>(
|
|||
const root = meta.root
|
||||
if (!isIdentityDerivationProvider(root)) {
|
||||
throw new Error(
|
||||
`Cannot run valueDerivation() on a pointer whose root is not an IdentityChangeProvider`,
|
||||
`Cannot run pointerToPrism() on a pointer whose root is not an IdentityChangeProvider`,
|
||||
)
|
||||
}
|
||||
const {path} = meta
|
||||
|
@ -322,7 +322,7 @@ export const val = <
|
|||
? P
|
||||
: unknown => {
|
||||
if (isPointer(input)) {
|
||||
return valueDerivation(input).getValue() as $IntentionalAny
|
||||
return pointerToPrism(input).getValue() as $IntentionalAny
|
||||
} else if (isPrism(input)) {
|
||||
return input.getValue() as $IntentionalAny
|
||||
} else {
|
||||
|
|
|
@ -26,7 +26,7 @@ export default class PointerProxy<O extends {}>
|
|||
* Convenience pointer pointing to the root of this PointerProxy.
|
||||
*
|
||||
* @remarks
|
||||
* Allows convenient use of {@link valueDerivation} and {@link val}.
|
||||
* Allows convenient use of {@link pointerToPrism} and {@link val}.
|
||||
*/
|
||||
readonly pointer: Pointer<O>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {valueDerivation} from '../Atom'
|
||||
import {pointerToPrism} from '../Atom'
|
||||
import type {Pointer} from '../pointer'
|
||||
import {isPointer} from '../pointer'
|
||||
import type {Prism} from './Interface'
|
||||
|
@ -9,7 +9,7 @@ export default function* iterateAndCountTicks<V>(
|
|||
): Generator<{value: V; ticks: number}, void, void> {
|
||||
let d
|
||||
if (isPointer(pointerOrDerivation)) {
|
||||
d = valueDerivation(pointerOrDerivation) as Prism<V>
|
||||
d = pointerToPrism(pointerOrDerivation) as Prism<V>
|
||||
} else if (isPrism(pointerOrDerivation)) {
|
||||
d = pointerOrDerivation
|
||||
} else {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {valueDerivation} from '../Atom'
|
||||
import {pointerToPrism} from '../Atom'
|
||||
import type {Pointer} from '../pointer'
|
||||
import {isPointer} from '../pointer'
|
||||
import Ticker from '../Ticker'
|
||||
|
@ -10,7 +10,7 @@ export default function* iterateOver<V>(
|
|||
): Generator<V, void, void> {
|
||||
let d
|
||||
if (isPointer(pointerOrDerivation)) {
|
||||
d = valueDerivation(pointerOrDerivation) as Prism<V>
|
||||
d = pointerToPrism(pointerOrDerivation) as Prism<V>
|
||||
} else if (isPrism(pointerOrDerivation)) {
|
||||
d = pointerOrDerivation
|
||||
} else {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
export type {IdentityDerivationProvider} from './Atom'
|
||||
export {default as Atom, val, valueDerivation} from './Atom'
|
||||
export {default as Atom, val, pointerToPrism} from './Atom'
|
||||
export {default as Box} from './Box'
|
||||
export type {IBox} from './Box'
|
||||
export {isPrism} from './derivations/Interface'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue