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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@yotie/perhaps

v1.2.2

Published

* [Why Use This?](#why-use-this) * [Getting Started](#getting-started) * [Prerequisites](#prerequisites) * [Installation](#installation) * [Usage](#usage) * [Roadmap](#roadmap) * [Contributing](#contributing)

Readme

Table of Contents

Getting Started

This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.

Installation

$ yarn add @yotie/perhaps

Usage

Use this space to show useful examples of how a project can be used. Additional screenshots, code examples and demos work well in this space. You may also link to more resources.

const user = { name: 'john Doe', age: 21 };

const age = Some(user.age);
const age2 = age.map(num => num * 2);

if (age2.hasValue) {
  console.log(`User has a doubled age of ${age2.value}`)
}

const update = Result.wrapAsync(() =>
  api.post('/user/1234', { age: age2.value }));

if (update.ok) {
  console.log('User has be updated: ', update.value.toJSON())
}

Here's and exmample on how to apply perhaps around negative cases

const user = None();

const addRoles = user.match(
  usr => {
    usr.roles = ['default', 'user:scope'];
    return usr;
  },
  _ => console.warn('No user information is available to display')
);

const authenticate = addRoles.toResult();

if (!authenticate.ok)
  console.log('Could not authenticate user', authenticate.reason)

For more extensive examples, please refer to the tests

Why Use This?

Because Monads are awesome and dont need to be complicated.

There are many great README templates available on GitHub, however, I didn't find one that really suit my needs so I created this enhanced one. I want to create a README template so amazing that it'll be the last one you ever need.

Here's why:

  • Your time should be focused on creating something amazing. A project that solves a problem and helps others
  • You shouldn't be doing the same tasks over and over like creating a README from scratch
  • You should element DRY principles to the rest of your life :smile:

Of course, no one template will serve all projects since your needs may be different. So I'll be adding more in the near future. You may also suggest changes by forking this repo and creating a pull request or opening an issue.

A list of commonly used resources that I find helpful are listed in the acknowledgements.

! Note: Hightlight inspiration from expo result

API

Maybe

Maybe is a container dedicated for the handling of a data which might be missing. Typically, it is used for representation of optional values. It allows prevent usage of Nullable objects

Maybe<T>(T value)

.hasValue

.isNone

.value

.map(fn)

.match(fn, fn)

.toResult()

Some(any value)

None()

Result

A result object represents the result of an operation that can either return a value successfully or fail. Typically we'd simply either return a value or throw an error, but sometimes we perform multiple operations as a batch, some of which may succeed and others fail. Since we can't simultaneously return values and throw errors, we instead return collections of result objects. This allows a batch operation to return values for successful operations and errors for failed ones without loss of information, namely the errors. (from expo/result)

Result<T>(ResultStatus status, T value, string | Error)

Result.wrap<T>(T value)

result(any value)

resultAsync(Promise<any>)

Success<T>(T value)

Failure<T>(string | Error)

Result.Ok<T>(T value)

Result.Fail<T>(string | Error)

Result.wrap<T>(T value)

Result.wrapAsync<T>(T value)

Result.match<T>(T value)

Result.matchAsync<T>(T value)

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feat/amazing-feature)
  3. Commit your Changes (git commit -m 'Add some amazing-feature')
  4. Push to the Branch (git push origin feat/amazing-feature)
  5. Open a Pull Request

Inspiration

  • expo/results
  • amonad