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

@cursormove/flow-is-helpers

v2.1.0

Published

Lodash (is) and additional Flow type %checks helpers.

Downloads

9

Readme

Predicate truthy Function via %check

wercker status

Description

This is a Flow helper library for Lodash is and additional Flow predicate type %checks functions. Simply put, this library contains converted truthy predicate functions through the use of Flow %check annotations. By doing so it aids and increases the ability for The Flow Parser to properly check the defined predicate functions.

Why?

Flow and Lodash's predicate functions (is***) don't work well together (if at all in some cases) resulting in duplicate logic. Ideally a fix will be implemented into the main flow-type Lodash library but until that time comes (if ever) this library acts as a stopgap solution. In addition, this library includes some helpful custom predicate check functions.

Install

# npm
npm i --save @cursormove/flow-is-helpers

# yarn
yarn add @cursormove/flow-is-helpers

Usage

This Library is a drop-in replacement for Lodash's predicate functions. You should be able to just swap out Lodash predicate functions like isString with this library. I recommend you take a quick look at the code base just so you have a better understanding of what is going on but the gist of it is pretty simple.

import {
  isString,
} from '@cursormove/flow-is-helpers';

// Flow Type Check & truthy predicate function check
const hello = (val: string) => isString(val) ? `Hello ${val}` : 'Hello Nobody';

hello('World'); // 'Hello World' 
hello(null); // 'Hello Nobody'

API 🠲 Custom Checks

Array Checks

  • isEmptyArray 🠲 Checks if Array is empty.
  • isNonEmptyArray 🠲 Checks if Array is empty.

Function Checks

  • isPromise 🠲 Checks if Function type is a Promise.
  • isAsync 🠲 Checks if Function type is Async.
  • isGenerator 🠲 Checks if Function type is a Generator Iterator.
  • isGeneratorFunction 🠲 Checks if Function type is a Generator.

Plain Object Checks (Not ObjectLike)

  • isEmptyObject 🠲 Checks if Object is empty.
  • isNonEmptyObject 🠲 Checks if Object is not empty.
  • isFrozen 🠲 Checks if Object is Frozen.
  • isFrozen 🠲 Checks if Object is Sealed.
  • isFrozen 🠲 Checks if Object is Extensible.

String Checks

  • isEmptyString 🠲 Checks if String is empty.
  • isNonEmptyString 🠲 Checks if String is not empty.

Number Checks

  • isNan 🠲 Checks if value is not a Number.
  • isInfinity 🠲 Checks if value is either Number.NEGATIVE_INFINITY or Number.POSITIVE_INFINITY.

Nil Checks

  • isNotNil 🠲 Opposite of Lodash's isNil in that it's not null or undefined.

Miscellaneous Checks

  • isIterable 🠲 Checks if value is an Iterable
  • isAction 🠲 Checks if value is a Redux Action

API 🠲 Lodash Checks

Includes all Lodash is Predicate Functions


Best, te