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

juissy

v1.0.32

Published

Juissy ====

Downloads

68

Readme

Juissy

Juissy is a minimal experimental JSON API client for Drupal.

Features:

  • Zero-configuration
  • Automatic pagination
  • Late-binding filter compiler
  • ???

Example:

// A client only needs a base URL. It doesn't need to know anything else!
const client = new JuissyClient('http://jsonapi.test:8080');

// It's best to read the code beneath these comments, then fill in your gaps in
// understading with these comments.

// `client.all()` returns a Promise. You may specify a limit for number of
// resources to retrieve, sorting rules, and filters too! If no limit is given
// the client will *lazily* resolve every resource on the server!
  // The Promise returned by `client.all()` resolves to a feed.
    // You "consume" resources by specifying a function to run for every
    // resolved resource. This will run for every resource up to the given
    // maximum or until there are no more resources available.
      // `consume` itself returns a Promise that will resolve to either a
      // function or `false` if there are no more resources available.
          // The `more` function lets you increase the number of resources to be
          // resolved.
          // Once the maximum has been increased, you may consume the additional
          // resources.
            // While the second `consume` call is "nested" here for the sake of
            // example, you need not do the same. Just take care that `consume`
            // is not called again before the first `consume` has completed.

client.all('node--recipe', { limit: 3, sort: 'title' })
  .then(feed => {
    return feed.consume(print('Initial'))
      .then(more => {
        console.log(`There are ${more ? 'more' : 'no more'} resources!`);
        if (more) {
          more(10);
          feed
            .consume(print('Additional'))
            .then(evenMore => {
              console.log(`There are ${evenMore ? 'more' : 'no more'} resources!`);
            });
        }
      });
  })
  .catch(error => console.log('Error:', error));

// This will just print the title of every recieved resource.
const print = (label) => {
  return resource => console.log(`${label}:`, resource.attributes.title);
};

If the server had a total of 7 resources, the above would print:

Initial: Deep mediterranean quiche
Initial: Gluten free pizza
Initial: Super easy vegetarian pasta bake
There are more resources!
Additional: Thai green curry
Additional: Vegan chocolate brownies
Additional: Victoria sponge cake
Additional: Watercress soup
There are no more resources!

If we want to add a custom filter, we would do so like this:

// `client.filter` receives a function that is passed all the components of a
// query builder.
const filter = client.filter((c, and, or, param) => {
  // Use the `and` and `or` function to build groups.
    // `c` is a shorthand for `c.eq`.
    // Nested groups are perfectly fine.
      // You can express other operators by calling methods on `c`.
      // You can 'parameterize' your queries with the param method.
      // You can even parameterize your operators!
  return and(
    c('status', 1),
    or(
      c.startsWith('title', 'Thai'),
      c.contains('title', param('myValueParam')),
      c.condition('title', 'chocolate', param('myOperatorParam')),
    ),
  );
});

const options = {
  limit: 3,
  sort: 'title',

  // `compile` will build a filter query string and replace your parameters.
  filter: filter.compile({
    myValueParam: 'easy',
    myOperatorParam: '<>',
  }),
};