index overview

Added in v0.1.0


Table of contents


constructors

Doi

Signature

export declare function Doi<A extends string>(doi: A): A extends `10.${infer R}/${string}` ? Doi<R> : Doi

Example

import { Doi } from 'doi-ts'

const doi = Doi('10.1000/182')

assert.deepStrictEqual(doi, '10.1000/182')

Added in v0.1.10

destructors

toUrl

Signature

export declare const toUrl: (doi: Doi) => URL

Example

import { Doi, toUrl } from 'doi-ts'

const url = toUrl('10.1000/182' as Doi)

assert.deepStrictEqual(url.href, 'https://doi.org/10.1000/182')

Added in v0.1.1

instances

Eq

Signature

export declare const Eq: E.Eq<Doi<string>>

Added in v0.1.1

model

Doi (type alias)

Signature

export type Doi<R extends string = string> = `10.${R}/${string}` & DoiBrand

Added in v0.1.0

refinements

hasRegistrant

Signature

export declare const hasRegistrant: <R extends string>(...registrants: readonly R[]) => Refinement<Doi<string>, Doi<R>>

Added in v0.1.2

isDoi

Signature

export declare const isDoi: Refinement<unknown, Doi<string>>

Added in v0.1.0

utils

getRegistrant

Signature

export declare const getRegistrant: <T extends Doi<string> = Doi<string>>(doi: T) => T extends Doi<infer R> ? R : never

Example

import { Doi, getRegistrant } from 'doi-ts'

const registrant = getRegistrant('10.1000/182' as Doi)

assert.deepStrictEqual(registrant, '1000')

Added in v0.1.2

parse

Signature

export declare const parse: (s: string) => Option<Doi>

Example

import { Doi, parse } from 'doi-ts'
import * as O from 'fp-ts/Option'

assert.deepStrictEqual(parse('https://doi.org/10.1000/182'), O.some('10.1000/182' as Doi))
assert.deepStrictEqual(parse('not a DOI'), O.none)

Added in v0.1.4