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

composite-call

v0.2.1

Published

Easily combine your API requests

Downloads

294

Readme

composite-call

Installation

npm i composite-call

If you want to automatically get composed function parameter names, you can use our transformer

The problem

There are situations, when you need to send request to your API, then pass it's result into second request. The solution is to write custom function on your server, to combine these two functions.

Or, you can use composite-call.

composite-call is a tool, for building composite request on the client-side. Using composite-call, you can manually write function on your server to receive sequence of calls and execute it.

Sample usage

import { compose } from 'composite-call';

const findUser = (email: string): User => {
    /* send request */
};

const changePassword = (user: User, newPassword: string): boolean => {
    /* send request */
};

compose(findUser, '[email protected]')
    .then((user) => compose(changePassword, user, 'new pass'))
    .call((sequence) => {
        /* use sequence to send request into your composite api */
    });

Or, if you want to specify default send request function:

import { compose, CompositeCall } from 'composite-call';

CompositeCall.sendRequest = (sequence) => {
    /* send your request */
};

compose(findUser, '[email protected]')
    .then((user) => compose(changePassword, user))
    .call(); // will use default sendRequest

More examples.

Transformer

⚠️ This requires TypeScript version >=2.4.1

Import transformer:

var transformer = require('composite-call/dist/transformer');

And then use it in your bundler. For example, with webpack and ts-loader:

var transformer = require('composite-call/dist/transformer');

module.exports = {
    ...
    module: {
        rules: [
            {
                test: /\.ts$/,
                loader: 'ts-loader',
                options: {
                    getCustomTransformers: (program) => ({
                        before: [transformer(program)],
                    }),
                },
            },
        ],
    },
};

License

MIT © ArtiomTr

Created with aqu 🌊