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

xerocross.fu

v3.0.1

Published

This is a collection of JavaScript utility functions written in a functional programming style. I just started this. It's still under construction. But what _is_ here is thoroughly tested. The code even contains mathematical proofs of correctness and

Downloads

7

Readme

xerocross.fu

This is a collection of JavaScript utility functions written in a functional programming style. I just started this. It's still under construction. But what is here is thoroughly tested. The code even contains mathematical proofs of correctness and internal verification that will throw errors at runtime if there is an unexpected problem.

It stands to reason that these functions might be noticeably slower than functions written in the traditional JavaScript imperative style. The (possible) lack of speed is a tradeoff for the benefit of functions that can be validated by mathematical proof.

about functional programming in JavaScript

JavaScript interpreters (as of this writing) tend to have a rather small stack limit for function recursion. This is an immovable object, and it forces me to write some functions in a style that is not fully functional. An important example here is number.isNaturalNumber. We cannot recurse down from 35802 to check that this is a natural number by recursion. Instead, I included a small while loop.

author

This is a one-man project so far. I'm the author, Adam Cross, AKA Xerocross. I'm an experienced software engineer and a PhD mathematician.

updates

I don't maintain any project-specific update blog, but I do maintain a blog about all of my programming activities at https://adamcross.blog/. If you are interested in the dev process or any updates about this project, check the blog.

validation and testing

This library has a rather extensive testing suite written in Jest notation. It also uses WeAssert (https://github.com/xerocross/we-assert) for internal validation of data. For example, this library defines a number.isInteger function and many of the other functions use that function internally to verify input data. These functions will throw an error at runtime if the input type is invalid.

npm run test tests the source files

functions

This is a list of the available functions and their signatures and return types. To use them, import the module. const futil = require("xerocross.fu");. Then to access a function, say "array.joinRight", you call futil.array.joinRight.

None of these functions mutate the input data.

function list

Here is the declaration of the exported types and methods

declare type ComparisonFunction = (i: number, j: number) => number;
declare type IsEqualFunction = (left: any, right: any) => boolean;
declare const _default: {
    array: {
        clone: (arr: any[]) => any[];
        isArraysEqual: (arr1: any[], arr2: any[], isEqual: IsEqualFunction) => boolean;
        isSorted: (arr: any[], upTo: number, compareFunction: ComparisonFunction) => boolean;
        joinRight: (arr: any[], newValue: any) => any[];
        joinLeft: (arr: any[], newValue: any) => any[];
        subarrayMax: (arr: any[], max: number) => any[];
        subarrayMin: (arr: any[], min: number) => any[];
        joinTwoArrays: (arr1: any[], arr2: any[]) => any[];
        subarray: (arr: any[], min: number, max: number) => any[];
        replace: (arr: any[], index: number, value: any) => any[];
        swap: (arr: any[], i: number, j: number) => any[];
        bubbleUp: (arr: any[], bubbleIndex: number, compareFunction: ComparisonFunction) => any[];
        bubbleSort: (arr: any[], compareFunction: ComparisonFunction) => any[];
    };
    number: {
        isNaturalNumber: (num: number) => boolean;
        isInteger: (num: number) => boolean;
        multiply: (arr: number[]) => number;
        getFirstFactor: (num: number) => number;
        getPrimeFactorsRecursion: (num: number, knownFactors: number[]) => number[];
        getPrimeFactors: (num: number) => number[];
    };
};