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

bentoo

v1.37.0

Published

food

Downloads

17

Readme

Bento

🍱🍚🍣🍤🍡🍥🍛🍢🍙🍘 alwayss be hangry...

Usage

Box

Javascript utility belt

import box from 'bentoo/box';

dig

box.dig({ a: { b: { c: '🍖' } } }, 'a', 'b', 'c');
=> 🍖
box.dig({ a: { b: { d: '🍖' } } }, 'a', 'b', 'c');
=> null

except

box.except({ corn: '🌽', pizza: '🍅', bagel: '🥑' }, ['corn', 'bagel']);
=> { pizza: '🍅' }

intersection

box.intersection(['🍖', '🍅', '🍥', '🥑'], ['🍥', '🌽', '🥑', '🍘']);
=> ['🍥', '🥑']

pad

box.pad('5', 3, '*');
=> '**5'

slice

box.slice({ corn: '🌽', pizza: '🍅', bagel: '🥑' }, ['corn', 'bagel']);
=> { corn: '🌽', bagel: '🥑' }

HOCs

Custom React higher order components.

import {
  createContainer,
  createAutoloadingContainer,
  mergeActions
} from "bentoo/hocs";

createContainer

createContainer is a HOC used for calling promise actions that we don't require to update Redux. createContainer uses its own reducer, and passes back it's own specific state associated with the API call.

In the following example, a container is created around the editPassword promiseAction. When the user calls the submit function, the callApi function created by createContainer will run the promiseAction.

CreateContainer will inject the following props to your component:

  • data: the data that is returned.

  • isLoading: a boolean used to determine whether the API call is still loading.

  • error: the error returned by the backend.

  • errorType: a string of one of the following:

    • ['client_timeout', 'unauthorized', 'illegal', 'expired', 'network_error', 'not_found', 'invalid']
  • validationErrors: an object that returns validations on a set of fields. For example, if your password is invalid, validationErrors would return back an object like this:

    • validationError: {
        password: "This password is invalid",
        passwordConfirmation: "This doesn't match the password"
      }
Example
export default compose(
  createContainer(editPassword),
  mergeActions(({ actions, token, email }) => ({
    submit: async model => {
      await actions.callApi({ ...model, resetPasswordToken: token, email });
      window.location = "/contractors/dashboard";
    }
  }))
)(ChangePassword);

createAutoloadingContainer

createAutoloadingContainer is a variation on createContainer, except that the promise action is called when the component mounts.

export default compose(
  createAutoloadingContainer(contractorAutologin, ({ email, token }) => [
    email,
    token
  ]),
  withRouter
)(Autologin);

mergeActions

mergeActions is a HOC that merges a collection of actions into a new actions object.

actions = {
  signup: () => {}
}

compose(
  mergeActions(({ actions }) => ({
    submit: async () => {
      await actions.signup();
    },
  }))
);
=> {
  actions: {
    signup: () => {},
    submit: async () => {
      await actions.signup();
    }
  }
}

Hooks

useContainer

The useContainer hook is a copy of the createContainer HOC. The only difference is that there will no longer be an 'actionName' parameter.

const result = useContainer(promiseAction);

// Call the API
result.callApi();

// The result has the following attributes:
const result = { isLoading: false,
      error: AuthorizationError { message: 'bar', type: 'unauthorized' },
      errorType: 'unauthorized',
      validationErrors: {},
      isSuccessful: false,
      callApi: [Function: callApi] }

Contributing

Bento currently supports Node version 10.15.3. Make sure when setting up:

nvm install 10
yarn install

Release

yarn release

select next version.

Test

yarn test