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

functioner

v0.2.1

Published

A node.js module containing a set of higher order functions

Readme

functioner

A Node.js module containing a set of higher order functions

functioner is a library mainly focused on higher-order functions, like the map, filter, and forEach functions used on arrays.

This functional programming methodology can be more easily embraced with a large set of higher-order functions allowing more compact anonymous function creation.

functioner contains a set of assertion functions, a lot like other libraries; however, these functions are higher-order which allows for unique usage in modules like dependon.

Install

$ npm install functioner

Usage

assert

var f = require('functioner').assert;
var numbers = [0, 1, 2, 3, 4, 5];

var lessThan3 = numbers.filter(f.lessThan(3));
//    => [ 0, 1, 2 ]

var odds = numbers.filter(f.odd);
//    => [1, 3, 5]

var between1and4 = numbers.filter(f.between(1, 4));
//    => [2, 3]
var types = [1, 'abc', {}, [1,2,3], false];

var iters = types.filter(f.type('iterable'));
//    => [ 'abc', [ 1, 2, 3 ] ]
  • type(string): returns a function that checks the types variables given to the function.
  • greaterThan(number): returns a function that checks if a number is greater than the original number given.
  • gt(number): short notation for greaterThan
  • greaterThanOrEqualTo(number): returns a function that checks if a number is greater than or equal to the original number given.
  • gte(number): short notation for greaterThanOrEqualTo
  • lessThan(number): returns a function that checks if a number is less than the original number given.
  • lt(number): short notation for lessThan
  • lessThanOrEqualTo(number): returns a function that checks if a number is less than or equal to the original number given.
  • lte(number): short notation for lessThanOrEqualTo
  • equalTo(value): returns a function that checks if a given value is equal to the original.
  • eq(value): short notation for equalTo
  • null(value): returns true if value equals null, false otherwise.
  • undefined(value): returns true if value equals undefined, false otherwise.
  • assigned(value): returns true if value does not equal undefined, false otherwise.
  • has(prop): returns a function that returns true if a given object has the property initially given.
  • includes(value): returns a function that returns true if a given array has the value initially specified.
  • contains(substring): returns a function that returns true if a given string has the substring initially given.
  • match(regex): returns a function that returns true if a given string matches a given regular expression.
  • positive(number): returns true if value is greater than 0, false otherwise.
  • negative(number): returns true if value is less than 0, false otherwise.
  • zero(number): returns true if value is equal to 0, false otherwise.
  • infinity(number): returns true if value is equal to Infinity, false otherwise.
  • finite(number): returns true if value is not equal to Infinity, false otherwise.
  • between(number, number): returns a function that returns true, if a given value is between the two numbers initially given.
  • even(number): returns true if value is even, false otherwise.
  • odd(number): returns true if value is odd, false otherwise.

math

var f = require('functioner').math;
var numbers = [0, 1, 2, 3, 4];

var add2 = numbers.map(f.add(2));
//    => [2, 3, 4, 5, 6]

var clamped = numbers.map(f.clamp(1, 3));
//    => [ 1, 1, 2, 3, 3 ]

var scaled = numbers.map(f.scale(0, 4, 0, 1));
//    => [ 0, 0.25, 0.5, 0.75, 1 ]
  • add(number): returns a function that adds the number given to any value given to the function.
  • subtract(number): returns a function that subtracts the number given to any value given to the function.
  • divide(number): returns a function that divides any number given to the function by the number initially given.
  • multiply(number): returns a function that multiplies any number given to the function by the number initially given.
  • pow(number): returns a function that takes the power of any number given to the function to the exponent of the number initially given.
  • sum(function): takes a function and returns a function that calculates the sum from the given parameters from n0 to n
  • scale(inMin, inMax, outMin, outMax): returns a function that scales a the number given, according to the in range and out range.
  • clamp(min, max): returns a function that clamps the value given in the range initially given.
  • compose(...functions): returns a function composed of all the functions given, like so: f0(f1(f2(fn)))

extras

  • accessor(string): returns a function that gives the value at an objects has. Example: accessor('length')(str) would return the length of str.
  • index(integer): returns a function that returns the index given of a given array.
  • print(value): console.log(value)