0.0.1-alpha.6 • Published 2 years ago

unsplash-ts-fp v0.0.1-alpha.6

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Unsplash FP

Functional Unasplash api client

Playground

You can build the example via the build:example NPM script. Then run via node example/build

Example Snippet

View more in the examples folder

import { pipe } from 'fp-ts/lib/function';
import * as E from 'fp-ts/Either'
import * as TE from 'fp-ts/TaskEither'
import * as A from 'fp-ts/Array'

import Unsplash from '@rawnly/unsplash-fp-ts';

const unsplash = new Unsplash( '' )

const getRandomIds = pipe( { count: 5 }, unsplash.photos.random, TE.map(A.map(photo => photo.id)) )

;(async () => { const result = await getRandomIds();

if ( E.isRight(result) ) {
	const { right: ids } = result;

	console.log(ids) // => string[]
} else {
	console.error('Error', result.left)
}

})()