npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

conductor

v1.9.0

Published

A modern & functional JavaScript utility library

Downloads

511

Readme

Introduction

conductor

Conductor on npmjs Conductor download stats on npmjs Codeship Status for WaldoJeffers/conductor codecov

conductor is a modern utility library to help you control the execution flow using functional programming.

🤵 description

It provides a set of utility functions which can be used both with asynchronous and synchronous code, allowing you to control your execution flow very clearly and with a minimum of code. The library is designed in a functional programming spirit, to provide a coherent API and highly composable functions. Think of it as if Ramda & Async had a baby.

Read more on Why I'm building conductor.

🔧 installation

npm install conductor

✨ examples

Here are a few examples of what you can do with conductor.

use asynchronous functions seamlessly

import { map } from 'conductor'

const fetchCharacter = id => fetch(`https://swapi.co/api/people/${id}`).then(res => res.json())
const character_ids = [1, 2, 3]
await map(fetchCharacter, character_ids) // [{id: 1, name: 'Luke'}, ...]

You can use map with an asynchronous mapper and directly use the await keyword. No need to use Promise.all like you need to with Array.prototype.map or lodash.map.

compose things

import { compose, get } from 'conductor'

const character_id = 1
const fetchCharacter = id => fetch(`https://swapi.co/api/people/${id}`).then(res => res.json())
const fetchPlanet = url => fetch(url).then(res => res.json())
const getHomeworldName = compose(get('name'), fetchPlanet, get('homeworld'), fetchCharacter)

await getHomeworldName(character_id) // Tatooine

You can compose functions seamlessly, without ever wondering if you need to use Promise.prototype.then because one function returns a Promise. Simply add await before compose if one your functions is asynchronous.

functional by design

import { compose, equals, get, join, map, filter } from 'conductor'

const jedis = [
  { name: 'Luke', side: 'light' },
  { name: 'Yoda', side: 'light' },
  { name: 'Darth Vader', side: 'dark' },
]
const isGood = filter(compose(equals('light'), get('side')))
const getName = map(get('name'))
const concat = join(', ')

compose(concat, getName, isGood)(jedis) // 'Luke, Yoda'

All functions in conductor are curried by default, which means they can be used in a partially applied form to define very modular and composable blocks in your code. In the example above, we have an array of jedis, and we want to retrieve a concatenated string of all the good guys' name. We first define an isGood function, which will filter out the bad guys. Then, we create a mapping functiongetNamewhich will retrieve each jedi's name. Finally, we create a concatenating function called concat. We can now easily compose them and pass thejedis array to the resulting function. Notice how we created small & modular point-free functions, and only passed the input data when we actually needed to.

📖 documentation

🗿 influences