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

jsfunx

v1.1.2

Published

JavaScript utility functions for cleaner, more readable code

Readme

jsfunx

npm version License Downloads

The main reason why this library was created is to:

use

import { isType, number } from "jsfunx"; // ESM

// or

// "use strict"; // CJS

// const { isType, number } = require("jsfunx"); // CJS

/**
 * Adds two numbers together and returns the result.
 *
 * @param {number} num1 - The first number.
 * @param {number} num2 - The second number.
 * @returns {number} The sum of `num1` and `num2`.
 * @throws {TypeError} If one or both arguments are not numbers.
 */

function add(num1, num2) {
  // 35 char

  if (isType([num1, num2], number)) {
    return num1 + num2;
  }

  throw new TypeError("invalid arguments types");
}

console.log(add(1, 3));

// or

console.log(add(Number(1), Number(3)));

in place of

// "use strict"; // CJS

/**
 * Adds two numbers together and returns the result.
 *
 * @param {number} num1 - The first number.
 * @param {number} num2 - The second number.
 * @returns {number} The sum of `num1` and `num2`.
 * @throws {TypeError} If one or both arguments are not numbers.
 */

function add(num1, num2) {
  // 59 char

  if (typeof num1 === "number" && typeof num2 === "number") {
    return num1 + num2;
  }

  throw new TypeError("invalid arguments types");
}

console.log(add(1, 3));

// or

console.log(add(Number(1), Number(3)));

and

import { isType, number, string } from "jsfunx"; // ESM

// or

// "use strict"; // CJS

// const { isType, number, string } = require("jsfunx"); // CJS

/**
 * Prints a message with the given name and age.
 *
 * @param {string} name - The person's name.
 * @param {number} age - The person's age.
 * @returns {void} This function does not return a value.
 * @throws {TypeError} If `name` is not a string or `age` is not a number.
 */

function fun(name, age) {
  // 44 char

  if (isType([name, age], [string, number])) {
    console.log(`your name is ${name} and your age is ${age}`);
    return;
  }

  throw new TypeError("invalid arguments types");
}

fun("mohamed", 23);

// or

fun(String("mohamed"), Number(23));

in place of

// "use strict"; // CJS

/**
 * Prints a message with the given name and age.
 *
 * @param {string} name - The person's name.
 * @param {number} age - The person's age.
 * @returns {void} This function does not return a value.
 * @throws {TypeError} If `name` is not a string or `age` is not a number.
 */

function fun(name, age) {
  // 58 char

  if (typeof name === "string" && typeof age === "number") {
    console.log(`your name is ${name} and your age is ${age}`);
    return;
  }

  throw new TypeError("invalid arguments types");
}

fun("mohamed", 23);

// or

fun(String("mohamed"), Number(23));

and

import { instancesof } from "jsfunx"; // ESM

// or

// "use strict"; // CJS

// const { instancesof } = require("jsfunx"); // CJS

/**
 * Adds two numbers together and returns the result.
 *
 * @param {Number} num1 - The first number.
 * @param {Number} num2 - The second number.
 * @returns {Number} The sum of `num1` and `num2`.
 * @throws {TypeError} If one or both arguments are not numbers objects.
 */

function add(num1, num2) {
  // 40 char

  if (instancesof([num1, num2], Number)) {
    return new Number(num1 + num2);
  }

  throw new TypeError("invalid arguments types");
}

console.log(add(new Number(1), new Number(3)));

in place of

// "use strict"; // CJS

/**
 * Adds two numbers together and returns the result.
 *
 * @param {Number} num1 - The first number.
 * @param {Number} num2 - The second number.
 * @returns {Number} The sum of `num1` and `num2`.
 * @throws {TypeError} If one or both arguments are not numbers objects.
 */

function add(num1, num2) {
  // 55 char

  if (num1 instanceof Number && num2 instanceof Number) {
    return new Number(num1 + num2);
  }

  throw new TypeError("invalid arguments types");
}

console.log(add(new Number(1), new Number(3)));

and

import { instancesof } from "jsfunx"; // ESM

// or

// "use strict"; // CJS

// const { instancesof } = require("jsfunx"); // CJS

/**
 * Prints a message with the given name and age.
 *
 * @param {String} name - The person's name.
 * @param {Number} age - The person's age.
 * @returns {void} This function does not return a value.
 * @throws {TypeError} If `name` is not a string object or `age` is not a number object.
 */

function fun(name, age) {
  // 49 char

  if (instancesof([name, age], [String, Number])) {
    console.log(`your name is ${name} and your age is ${age}`);
    return;
  }

  throw new TypeError("invalid arguments types");
}

fun(new String("mohamed"), new Number(23));

in place of

// "use strict"; // CJS

/**
 * Prints a message with the given name and age.
 *
 * @param {String} name - The person's name.
 * @param {Number} age - The person's age.
 * @returns {void} This function does not return a value.
 * @throws {TypeError} If `name` is not a string object or `age` is not a number object.
 */

function fun(name, age) {
  // 54 char

  if (name instanceof String && age instanceof Number) {
    console.log(`your name is ${name} and your age is ${age}`);
    return;
  }

  throw new TypeError("invalid arguments types");
}

fun(new String("mohamed"), new Number(23));

but not just this there is other funcs you can see the source code and check all the tests in the main fun.

Installation

You can install jsfunx via npm:

npm install jsfunx

License

This project is licensed under the MIT LICENSE - see the LICENSE for more details.