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

@bingo347/fn

v0.3.1

Published

A library for declarative programming with higher order functions

Downloads

15

Readme

fn

A library for declarative programming with higher order functions

Installation

npm i -S @bingo347/fn

or

yarn add @bingo347/fn

Usage example

wrap DOMReady wait to Promise

import makeSubscriber from '@bingo347/fn/make/subscriber';
import extractField from '@bingo347/fn/mappers/extractField';
import chain from '@bingo347/fn/mappers/chain';
import equal from '@bingo347/fn/logic/equal';
import or from '@bingo347/fn/logic/or';

const subscribe = makeSubscriber('addEventListener', 'removeEventListener');
const isDocumentReady = chain(
    extractField('readyState'),
    or(equal('complete'), equal('interactive'))
);

function domReady(doc = document) {
    return (isDocumentReady(doc)
        ? Promise.resolve()
        : new Promise(resolve => {
            const doResolve = () => resolvers.forEach(resolver => resolver());
            const resolvers = [
                subscribe(doc, 'DOMContentLoaded', doResolve),
                subscribe(doc.defaultView, 'load', doResolve),
                resolve
            ];
        })
    );
}

domReady().then(() => {
    //current document is ready
});
domReady(iframe.contentDocument).then(() => {
    //iframe document is ready
});

Two module systems support

All library functions are provided in two variants:

  • ES6 modules with .mjs extension, for use with module bundler (webpack) or use in node.js with --experimental-modules flag or with esm
  • commonJS modules with .js extension, for use in node.js without any helpers

ES5 support

All library functions are provided in ES6 (ES2015) compatible code.
It don't transpiled, but you can use webpack with babel for transpile it for old browsers

// webpack.config.js
module.exports = {
    module: {
        rules: [
            {
                test: /\.m?js$/,
                include: modulePath => {
                    if(modulePath.includes('node_modules/@bingo347/fn')) {
                        // transpile this library
                        return true;
                    }
                    if(modulePath.includes('node_modules')) {
                        // don't transpile other libraries
                        return false;
                    }
                    // transpile your code
                    return true;
                },
                use: [{
                    loader: 'babel-loader',
                    options: {
                        presets: [['env', {modules: false}]]
                    }
                }]
            },
            // your other webpack module.rules
        ]
    },
    // your other webpack options
}

Documentation

See on the github

License

MIT